# HG changeset patch # User Yuhi TOMARI # Date 1383121700 -32400 # Node ID d6f18ee58e0e3a7e154c6b8fb498a997d464ce51 # Parent a07d4773012d0d55f7dc7543c8b5249e4808f458 use the method of opencl diff -r a07d4773012d -r d6f18ee58e0e TaskManager/Gpu/GpuScheduler.cc --- a/TaskManager/Gpu/GpuScheduler.cc Tue Oct 22 19:19:41 2013 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Wed Oct 30 17:28:20 2013 +0900 @@ -49,7 +49,7 @@ exit(EXIT_FAILURE); } context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &ret); - command_queue = clCreateCommandQueue(context, device_id, 0,&ret); + command_queue = clCreateCommandQueue(context, device_id, CL_QUEUE_PROFILING_ENABLE, &ret); if (ret<0) { const char *msg=convert_error_status(ret); error(msg); @@ -68,7 +68,6 @@ GpuScheduler::wait_for_event(cl_event* event,memaddr* reply,int cur) { if (event[1-cur] != NULL) { int ret=clWaitForEvents(1,&event[1-cur]); - clReleaseEvent(event[1-cur]); if (ret<0) { const char *msg=convert_error_status(ret); error(msg); @@ -77,7 +76,6 @@ connector->mail_write(reply[1-cur]); reply[1-cur]=0; } - event[1-cur]=NULL; } } @@ -277,8 +275,14 @@ wait_for_event(event,reply,cur); if (tasklist[1-cur]!=NULL) { - tasklist[1-cur]->task_end_time = gettime(); + cl_ulong start = 0; + cl_ulong end = 0; + clGetEventProfilingInfo(event[1-cur],CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &start, NULL); + clGetEventProfilingInfo(event[1-cur],CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &end, NULL); + tasklist[1-cur]->task_start_time = start; + tasklist[1-cur]->task_end_time = end; } + event[1-cur] = NULL; //clFlush(command_queue); // waiting for queued task // clFlush(command_queue); @@ -294,7 +298,15 @@ cur = 1 - cur; } wait_for_event(event,reply,cur); - tasklist[1-cur]->task_end_time = gettime(); + if (tasklist[cur]!=NULL) { + cl_ulong start = 0; + cl_ulong end = 0; + clGetEventProfilingInfo(event[cur],CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &start, NULL); + clGetEventProfilingInfo(event[cur],CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &end, NULL); + tasklist[cur]->task_start_time = start; + tasklist[cur]->task_end_time = end; + event[cur] = NULL; + } //clFlush(command_queue); // waiting for queued task //clFinish(command_queue); // waiting for queued task unsigned long long wait = 0; diff -r a07d4773012d -r d6f18ee58e0e TaskManager/kernel/schedule/Scheduler.cc --- a/TaskManager/kernel/schedule/Scheduler.cc Tue Oct 22 19:19:41 2013 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Wed Oct 30 17:28:20 2013 +0900 @@ -184,7 +184,7 @@ if (table) { MemorySegment* here = (MemorySegment*)( manager->allocate(sizeof(MemorySegment))); - here->data = (void*)(table->vma); + here->data = &table->vma; here->size = size; here->address = (memaddr)here; code_segment_pool->addLast(here);