Mercurial > hg > Members > Moririn
annotate src/parallel_execution/examples/twice/createArray.cbc @ 438:7679093bdd72
Work CUDAtwice
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 06 Nov 2017 00:11:43 +0900 |
parents | 85b0ddbf458e |
children | 7d67c9cf09ee |
rev | line source |
---|---|
409
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 #include <stdio.h> |
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 #include "../../../context.h" |
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 |
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 extern int length; |
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 extern int split; |
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 |
438
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
7 __code createArray(__code next(struct Array* output, struct Time* output1, ...), struct LoopCounter* loopCounter) { |
409
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 struct Array* output = *O_output; |
438
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
9 struct Time* output1 = *O_output1; |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
10 int i = loopCounter->i; |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
11 if (i == 0){ |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
12 output->array = (Int*)ALLOCATE_ARRAY(context, Int, length); |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
13 output->prefix = length/split; |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
14 } |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
15 if (i == GET_LEN(output->array)){ |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
16 printf("created Array\n"); |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
17 loopCounter->i = 0; |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
18 Gearef(context, Time)->time = (union Data*)output1; |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
19 Gearef(context, Time)->next = context->next; |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
20 *O_output = output; |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
21 *O_output1 = output1; |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
22 goto meta(context, output1->start); |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
23 } |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
24 output->array[i] = i; |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
25 loopCounter->i++; |
409
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 *O_output = output; |
438
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
27 *O_output1 = output1; |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
28 goto meta(context, C_createArray); |
409
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 } |
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 |
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 __code createArray_stub(struct Context* context) { |
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 Array** O_output = (struct Array **)&context->data[context->odg]; |
438
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
33 Time** O_output1 = (struct Time**)&context->data[context->odg+1]; |
409
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 goto createArray(context, |
438
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
35 context->next, |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
36 O_output, |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
37 O_output1, |
7679093bdd72
Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
410
diff
changeset
|
38 Gearef(context, LoopCounter)); |
409
4d1e3697a6b8
Add twice cbc file
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 } |