Mercurial > hg > Game > Cerium
view TaskManager/Gpu/GpuThreads.cc @ 1561:e8c9a7099bcc draft
add set NDRange param
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 12 Mar 2013 16:52:49 +0900 |
parents | 027d99ecb50e |
children | 806b4658ced6 |
line wrap: on
line source
#include "GpuThreads.h" #include "GpuScheduler.h" #include "TaskManagerImpl.h" #include "SpeTaskManagerImpl.h" const int gpu_num = 1; GpuThreads::GpuThreads(int useRefDma) : use_refdma(useRefDma) { threads = new pthread_t[gpu_num]; args = new gpu_thread_arg_t; } GpuThreads::~GpuThreads() { memaddr mail = (memaddr)MY_SPE_COMMAND_EXIT; send_mail(0,1,&mail); pthread_join(threads[0], NULL); delete threads; delete args; } void GpuThreads::set_wait(SemPtr wait) { args->wait=wait; } void GpuThreads::set_NDRange(void* ndr) { args->scheduler->set_NDRange(ndr); } void GpuThreads::init() { args->scheduler = new GpuScheduler(); args->useRefDma = use_refdma; pthread_create(&threads[0], NULL, &gpu_thread_run, args); } void * GpuThreads::gpu_thread_run(void *args) { gpu_thread_arg_t *argt = (gpu_thread_arg_t *) args; Scheduler *g_scheduler = argt->scheduler; TaskManagerImpl *manager = new SpeTaskManagerImpl(); g_scheduler->init(manager, argt->useRefDma); manager->set_scheduler(g_scheduler); argt->wait->sem_v(); 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 GpuThreads::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) { }