Mercurial > hg > Game > Cerium
view TaskManager/Gpu/GpuThreads.cc @ 1443:dff9b3f388e2 draft
debug GpuScheduler.cc
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 23 Apr 2012 21:38:42 +0900 |
parents | db8a954fcfb3 |
children | e8ff87511f46 |
line wrap: on
line source
#include "GpuThreads.h" #include "GpuScheduler.h" #include "TaskManagerImpl.h" GpuThreads::GpuThreads() { threads = new pthread_t; args = new gpu_arg; } GpuThreads::~GpuThreads() { delete threads; delete args; clReleaseCommandQueue(command_queue); clReleaseContext(context); } void GpuThreads::init() { clGetPlatformIDs(1, &platfrom_id, &ret_num_platforms); clGetDeviceIds(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &ret_num_devices); // unavailable GPU 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); args.scheduler = new GpuScheduler(); args.useRefDma = use_refdma; pthread_create(&threads, NULL, &cpu_thread_run, (void*)&args); } void * GpuThreads::gpu_thread_run(void *args) { gpu_arg *argt = (gpu_arg *) args; Scheduler *g_scheduler = argt->scheduler; TaskManagerImpl *manager = new GpuTaskManagerImpl(); g_scheduler->init(manager, argt->useRefDma); manager->set_scheduler(g_scheduler); g_scheduler->run(); g_scheduler->finish(); return NULL } int GpuThreads::get_mail(int speid, int count, memaddr *ret) { *ret = args.scheduler->mail_read_from_host(); return 1; } int GpuThreads::has_mail(int speid, int count, memaddr *ret) { if (args.scheduler->has_mail_from_host() != 0) { return get_mail(0, 0, ret); } else { return 0; } } void CpuThreads::send_mail(int speid, int num, memaddr *data) { args.scheduler->mail_write_from_host(*data); } void GpuThreads::add_output_tasklist(int command, memaddr buff, int alloc_size) { }