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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1433
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include "GpuThreads.h"
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
2 #include "GpuScheduler.h"
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
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
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
7
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
8 GpuThreads::GpuThreads(int useRefDma) : use_refdma(useRefDma)
1433
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
11 args = new gpu_thread_arg_t;
1433
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 }
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 GpuThreads::~GpuThreads()
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1490
diff changeset
16 memaddr mail = (memaddr)MY_SPE_COMMAND_EXIT;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1490
diff changeset
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
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1490
diff changeset
19
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
20 delete threads;
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
21 delete args;
1433
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 }
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 void
1482
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
25 GpuThreads::set_wait(SemPtr wait)
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
26 {
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
27 args->wait=wait;
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
28 }
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
29
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
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
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1443
diff changeset
34 args->useRefDma = use_refdma;
1433
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 }
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 void *
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 GpuThreads::gpu_thread_run(void *args)
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 {
1482
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
43 gpu_thread_arg_t *argt = (gpu_thread_arg_t *) args;
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
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
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
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
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
49 manager->set_scheduler(g_scheduler);
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
50
1482
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
51 argt->wait->sem_v();
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1481
diff changeset
52
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
53 g_scheduler->run();
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
54 g_scheduler->finish();
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1433
diff changeset
55
1447
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1443
diff changeset
56 return NULL;
1433
11dcd8165424 add GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 }
1437
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1436
diff changeset
58
1641
289378e5abf8 add print flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1614
diff changeset
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
40a3504126a4 fix HTask.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1580
diff changeset
61 send_mail(id, 1, (memaddr*)p);
1641
289378e5abf8 add print flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1614
diff changeset
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
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1443
diff changeset
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
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1443
diff changeset
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
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1447
diff changeset
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
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1443
diff changeset
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 }