Mercurial > hg > GearsTemplate
annotate src/parallel_execution/test/multiDimIterator_test.cbc @ 464:7d67c9cf09ee
Rename from Time interface to Timer interface
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 21 Dec 2017 00:07:27 +0900 |
parents | 2b36a1878c6f |
children | 831b7f6fd687 |
rev | line source |
---|---|
376
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 #include <stdio.h> |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 #include <string.h> |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 #include <stdlib.h> |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 #include <unistd.h> |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 #include "../../context.h" |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 int cpu_num = 1; |
402
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
9 int length = 1; |
376
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 int gpu_num = 0; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 int CPU_ANY = -1; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 int CPU_CUDA = -1; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 // loopCounter->tree = createRedBlackTree(context); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 loopCounter->i = 0; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 goto meta(context, C_code1); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 } |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 __code initDataGears_stub(struct Context* context) { |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 struct TaskManager* taskManager = Gearef(context, TaskManager); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 taskManager->taskManager = 0; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 struct LoopCounter* loopCounter = Gearef(context, LoopCounter); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 goto initDataGears(context, loopCounter, taskManager); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 } |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 |
464
7d67c9cf09ee
Rename from Time interface to Timer interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
457
diff
changeset
|
28 __code code1() { |
376
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 printf("cpus:\t\t%d\n", cpu_num); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 printf("gpus:\t\t%d\n", gpu_num); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 printf("length:\t\t%d\n", length); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 /* puts("queue"); */ |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 /* print_queue(context->data[ActiveQueue]->queue.first); */ |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 /* puts("tree"); */ |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 /* print_tree(context->data[Tree]->tree.root); */ |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 /* puts("result"); */ |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 |
464
7d67c9cf09ee
Rename from Time interface to Timer interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
457
diff
changeset
|
38 goto createTask1(); |
376
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 } |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 |
464
7d67c9cf09ee
Rename from Time interface to Timer interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
457
diff
changeset
|
41 __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { |
376
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 int i = loopCounter->i; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 if (i < length) { |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 loopCounter->i++; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 goto meta(context, C_createTask2); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 } |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 loopCounter->i = 0; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 taskManager->next = C_exit_code; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 goto meta(context, taskManager->taskManager->TaskManager.shutdown); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 } |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 |
401
408b4aab7610
Supported par goto iterate statement for perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
379
diff
changeset
|
54 __code createTask2(struct TaskManager* taskManager) { |
403
83c9aeb1fe3e
Generate MultiDimIterator by perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
55 par goto printIterator(iterate(2), exit); |
83c9aeb1fe3e
Generate MultiDimIterator by perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
56 par goto printIterator(iterate(2, 2), exit); |
402
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
57 par goto printIterator(iterate(2, 2, 2), exit); |
401
408b4aab7610
Supported par goto iterate statement for perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
379
diff
changeset
|
58 goto createTask1(); |
376
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 } |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
60 |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
61 void init(int argc, char** argv) { |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
62 for (int i = 1; argv[i]; ++i) { |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 if (strcmp(argv[i], "-cpu") == 0) |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64 cpu_num = (int)atoi(argv[i+1]); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 else if (strcmp(argv[i], "-l") == 0) |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
66 length = (int)atoi(argv[i+1]); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
67 else if (strcmp(argv[i], "-cuda") == 0) { |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
68 gpu_num = 1; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
69 CPU_CUDA = 0; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
70 } |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
71 } |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72 } |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 int main(int argc, char** argv) { |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 init(argc, argv); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
76 struct Context* main_context = NEW(struct Context); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77 initContext(main_context); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
78 main_context->next = C_initDataGears; |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
79 goto start_code(main_context); |
b46f38645587
Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
80 } |