source:
CIVL/examples/translation/openclversion2.1/openSimp.cvl@
1acabb5
| Last change on this file since 1acabb5 was 1acabb5, checked in by , 12 years ago | |
|---|---|
|
|
| File size: 532 bytes | |
| Rev | Line | |
|---|---|---|
| [da70bc2] | 1 | #include <civlc.h> |
| [1acabb5] | 2 | void square(int global_id, float input[], float output[], int count) |
| [da70bc2] | 3 | { |
| 4 | int i = global_id; | |
| 5 | if (i < count) | |
| 6 | { | |
| 7 | output[i] = input[i] * input[i]; | |
| 8 | } | |
| 9 | } | |
| [1acabb5] | 10 | int main(int argc, char** argv) |
| [da70bc2] | 11 | { |
| [1acabb5] | 12 | int global = 4; |
| 13 | ||
| 14 | float input[global]; | |
| 15 | float output[global]; | |
| 16 | ||
| 17 | for(int i = 0; i < global; i++) | |
| [da70bc2] | 18 | { |
| [1acabb5] | 19 | input[i] = i; |
| [da70bc2] | 20 | } |
| 21 | ||
| [1acabb5] | 22 | $proc procs[global]; |
| 23 | for(int i = 0; i < global; i++) | |
| [da70bc2] | 24 | { |
| [1acabb5] | 25 | procs[i] = $spawn square(i, input, output, global); |
| [da70bc2] | 26 | } |
| 27 | ||
| [1acabb5] | 28 | for(int i = 0; i < global; i++) |
| [da70bc2] | 29 | { |
| [1acabb5] | 30 | $wait(procs[i]); |
| [da70bc2] | 31 | } |
| 32 | } |
Note:
See TracBrowser
for help on using the repository browser.
