1.23
2.0
acw/focus-triggers
main
test-branch
| Line | |
|---|
| 1 | #include <civlc.h>
|
|---|
| 2 | void square(int global_id, float input[], float output[], int count)
|
|---|
| 3 | {
|
|---|
| 4 | int i = global_id;
|
|---|
| 5 | if (i < count)
|
|---|
| 6 | {
|
|---|
| 7 | output[i] = input[i] * input[i];
|
|---|
| 8 | }
|
|---|
| 9 | }
|
|---|
| 10 | int main(int argc, char** argv)
|
|---|
| 11 | {
|
|---|
| 12 | int global = 4;
|
|---|
| 13 |
|
|---|
| 14 | float input[global];
|
|---|
| 15 | float output[global];
|
|---|
| 16 |
|
|---|
| 17 | for(int i = 0; i < global; i++)
|
|---|
| 18 | {
|
|---|
| 19 | input[i] = i;
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | $proc procs[global];
|
|---|
| 23 | for(int i = 0; i < global; i++)
|
|---|
| 24 | {
|
|---|
| 25 | procs[i] = $spawn square(i, input, output, global);
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | for(int i = 0; i < global; i++)
|
|---|
| 29 | {
|
|---|
| 30 | $wait(procs[i]);
|
|---|
| 31 | }
|
|---|
| 32 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.