source: CIVL/examples/opencl/2.14/parfor.cvl

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 765 bytes
RevLine 
[0fbd024]1
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5#include <civlc.h>
6
7void square(int id, int arr[])
8{
9 arr[id] = arr[id] * arr[id];
10 printf("my id is %d with value %d\n", id, arr[id]);
11}
12
13
14int main(int argc, char** argv)
15{
16 int count = 2;
17 int data[count];
18
19 for(int i = 0; i < count; i++)
20 {
21 data[i] = i;
22 }
23
24 $proc procs[count];
25
[5693398]26 int choose = 0;
[0fbd024]27
28 if (choose == 1)
29 {
30 for(int i = 0; i < count; i++)
31 {
32 //printf("i is %d\n", i);
33 procs[i] = $spawn square(i, data);
34 }
35
36 for(int i = 0; i < count; i++)
37 {
38 $wait(procs[i]);
39 }
40 }
41
42 else
43 {
44 $domain(1) dom = {0 .. count - 1};
45 $parfor(int i: dom)
46 {
47 //printf("i is %d\n", i);
48 square(i, data);
49 }
50 }
51
52 return 0;
53}
Note: See TracBrowser for help on using the repository browser.