Mercurial > hg > Game > Cerium
changeset 1438:3c787a21ff10 draft
add GpuScheduler::run()
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 07 Apr 2012 11:25:06 +0900 |
parents | fa6723e7d329 |
children | 20e935f170c1 |
files | TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuScheduler.h TaskManager/Gpu/GpuThreads.cc TaskManager/Gpu/GpuThreads.h |
diffstat | 4 files changed, 16 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Sat Apr 07 09:29:09 2012 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Sat Apr 07 11:25:06 2012 +0900 @@ -12,7 +12,6 @@ int GpuScheduler::run() { - // command_queueにここで、enqueueする? memaddr params_addr = connector->task_list_mail_read(); if ((memaddr)params_addr == (memaddr)MY_SPE_COMMAND_EXIT) { @@ -22,12 +21,18 @@ TaskListPtr *tasklist = (TaskListPtr)connector->dma_load(tasklist, params_addr, sizeof(TaskList), DMA_READ_TASKLIST); + GpuThreads gputhreads = GpuThreads::getInstance(); + cl_command_queue& command_queue = &gputhreads.cl_command_queue; + for (int cur_index = 0; cur_index < tasklist->length; cur_index++) { - + TaskPtr task = tasklist.tasks[cur_index]; + cl_kernel& kernel = task_list[task->command].kernel; + // メモリオブジェクトの生成? GpuThreadsでやるのがよい? + // カーネル引数の設定 + clEnqueueTask(command_queue, kernel, 0, NULL, NULL); + // メモリオブジェクトからの読み込み } - - - + // TaskArrayの処理 } @@ -36,7 +41,8 @@ gpu_register_task(int cmd, char* filename, char* functionname) { GpuThreads gputhreads = GpuThreads::getInstance(); - context = &gputhreads.context + cl_context& context = &gputhreads.context; + cl_device_id& device_id = &gputhreads.device_id; FILE *fp; char *souce_str; @@ -52,8 +58,6 @@ source_size = fread(source_str, 1, MAX_SOURCE_SIZE, fp); fclose(fp); - // contextとか、device_idはどうやって取る? - // gpuの情報はグローバルで持つべきなのか… cl_program program = NULL; cl_int ret; program = clCreateProgramWithSource(context, 1, (const char **)&source_str,
--- a/TaskManager/Gpu/GpuScheduler.h Sat Apr 07 09:29:09 2012 +0900 +++ b/TaskManager/Gpu/GpuScheduler.h Sat Apr 07 11:25:06 2012 +0900 @@ -12,9 +12,9 @@ class GpuScheduler : public Scheduler { public: void init_impl(int useRefDma); + int run(); private: - cl_context* context; };
--- a/TaskManager/Gpu/GpuThreads.cc Sat Apr 07 09:29:09 2012 +0900 +++ b/TaskManager/Gpu/GpuThreads.cc Sat Apr 07 11:25:06 2012 +0900 @@ -23,12 +23,11 @@ if( ret_num_devices == 0) { exit(EXIT_FAILURE); } - context = clCreateContext(NULL, 1, device_id, NULL, NULL, &ret); - command_queue = clCreateCommandQueue(context, *device_id, 0, &ret); + context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &ret); + command_queue = clCreateCommandQueue(context, device_id, 0, &ret); args.scheduler = new GpuScheduler(); args.useRefDma = use_refdma; - args.command_queue = command_queue; pthread_create(&threads, NULL, &cpu_thread_run, (void*)&args); @@ -39,12 +38,9 @@ { gpu_arg *argt = (gpu_arg *) args; Scheduler *g_scheduler = argt->scheduler; - // command_queueがThreadセーフじゃない。 - cl_command_queue *command_queue = argt->command_queue; TaskManagerImpl *manager = new GpuTaskManagerImpl(); g_scheduler->init(manager, argt->useRefDma); - g_scheduler->set_command_queue(command_queue); manager->set_scheduler(g_scheduler);
--- a/TaskManager/Gpu/GpuThreads.h Sat Apr 07 09:29:09 2012 +0900 +++ b/TaskManager/Gpu/GpuThreads.h Sat Apr 07 11:25:06 2012 +0900 @@ -13,7 +13,6 @@ // Singleton Pattern struct gpu_arg { GpuScheduler *scheduler; - cl_command_queue *command_queue; int useRefDma; } @@ -37,7 +36,7 @@ cl_device_id device_id; cl_uint ret_num_platforms; cl_uint ret_num_devices; - cl_device_id* device_id; + cl_device_id device_id; cl_context context; cl_command_queue command_queue;