Mercurial > hg > Game > Cerium
annotate TaskManager/Gpu/GpuThreads.cc @ 1641:289378e5abf8 draft
add print flag
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 18 Jun 2013 18:52:42 +0900 |
parents | 93569219173e |
children | f73ca57cdc81 |
rev | line source |
---|---|
1433 | 1 #include "GpuThreads.h" |
1434 | 2 #include "GpuScheduler.h" |
3 #include "TaskManagerImpl.h" | |
1477
5ca4e9469c65
remove GpuTaskManagerImpl
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1454
diff
changeset
|
4 #include "SpeTaskManagerImpl.h" |
1433 | 5 |
1501
8d6fee66ff65
it looks like working...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1499
diff
changeset
|
6 const int gpu_num = 1; |
1482 | 7 |
8 GpuThreads::GpuThreads(int useRefDma) : use_refdma(useRefDma) | |
1433 | 9 { |
1501
8d6fee66ff65
it looks like working...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1499
diff
changeset
|
10 threads = new pthread_t[gpu_num]; |
1482 | 11 args = new gpu_thread_arg_t; |
1433 | 12 } |
13 | |
14 GpuThreads::~GpuThreads() | |
15 { | |
1499 | 16 memaddr mail = (memaddr)MY_SPE_COMMAND_EXIT; |
17 send_mail(0,1,&mail); | |
1501
8d6fee66ff65
it looks like working...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1499
diff
changeset
|
18 pthread_join(threads[0], NULL); |
1499 | 19 |
1434 | 20 delete threads; |
21 delete args; | |
1433 | 22 } |
23 | |
24 void | |
1482 | 25 GpuThreads::set_wait(SemPtr wait) |
26 { | |
27 args->wait=wait; | |
28 } | |
29 | |
30 void | |
1436
42057124fb44
change to Singleton Pattern
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1435
diff
changeset
|
31 GpuThreads::init() |
1433 | 32 { |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1501
diff
changeset
|
33 args->scheduler = new GpuScheduler(); |
1447 | 34 args->useRefDma = use_refdma; |
1433 | 35 |
1501
8d6fee66ff65
it looks like working...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1499
diff
changeset
|
36 pthread_create(&threads[0], NULL, &gpu_thread_run, args); |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1501
diff
changeset
|
37 |
1433 | 38 } |
39 | |
40 void * | |
41 GpuThreads::gpu_thread_run(void *args) | |
42 { | |
1482 | 43 gpu_thread_arg_t *argt = (gpu_thread_arg_t *) args; |
1434 | 44 Scheduler *g_scheduler = argt->scheduler; |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1501
diff
changeset
|
45 |
1477
5ca4e9469c65
remove GpuTaskManagerImpl
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1454
diff
changeset
|
46 TaskManagerImpl *manager = new SpeTaskManagerImpl(); |
1434 | 47 g_scheduler->init(manager, argt->useRefDma); |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1501
diff
changeset
|
48 |
1434 | 49 manager->set_scheduler(g_scheduler); |
50 | |
1482 | 51 argt->wait->sem_v(); |
52 | |
1434 | 53 g_scheduler->run(); |
54 g_scheduler->finish(); | |
55 | |
1447 | 56 return NULL; |
1433 | 57 } |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
58 |
1641 | 59 int |
1580
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1561
diff
changeset
|
60 GpuThreads::spawn_task(int id, TaskListPtr p) { |
1583 | 61 send_mail(id, 1, (memaddr*)p); |
1641 | 62 return 0; |
1580
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1561
diff
changeset
|
63 } |
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1561
diff
changeset
|
64 |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
65 int |
1443
dff9b3f388e2
debug GpuScheduler.cc
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1442
diff
changeset
|
66 GpuThreads::get_mail(int speid, int count, memaddr *ret) |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
67 { |
1447 | 68 *ret = args->scheduler->mail_read_from_host(); |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
69 return 1; |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
70 } |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
71 |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
72 int |
1443
dff9b3f388e2
debug GpuScheduler.cc
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1442
diff
changeset
|
73 GpuThreads::has_mail(int speid, int count, memaddr *ret) |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
74 { |
1447 | 75 if (args->scheduler->has_mail_from_host() != 0) { |
1443
dff9b3f388e2
debug GpuScheduler.cc
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1442
diff
changeset
|
76 return get_mail(0, 0, ret); |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
77 } else { |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
78 return 0; |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
79 } |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
80 } |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
81 |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
82 void |
1452 | 83 GpuThreads::send_mail(int speid, int num, memaddr *data) |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
84 { |
1447 | 85 args->scheduler->mail_write_from_host(*data); |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1436
diff
changeset
|
86 } |
1443
dff9b3f388e2
debug GpuScheduler.cc
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1442
diff
changeset
|
87 |
dff9b3f388e2
debug GpuScheduler.cc
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1442
diff
changeset
|
88 void |
dff9b3f388e2
debug GpuScheduler.cc
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1442
diff
changeset
|
89 GpuThreads::add_output_tasklist(int command, memaddr buff, int alloc_size) |
dff9b3f388e2
debug GpuScheduler.cc
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1442
diff
changeset
|
90 { |
dff9b3f388e2
debug GpuScheduler.cc
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1442
diff
changeset
|
91 } |