source: CIVL/examples/compare/max/max_par.cvl@ ecfe5bf

1.23 2.0 main test-branch
Last change on this file since ecfe5bf was 5af87592, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

implemented new command line specification, added grammar for command line specification, supported linking and command line macros now, improved the clarity of compare command.

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

  • Property mode set to 100644
File size: 543 bytes
Line 
1#include<civlc.cvh>
2
3$input int BLOCK_SIZE;
4$input int NPROCS;
5
6int getMax(int* array, int length){
7 int myMax = 0;
8 $proc procs[NPROCS];
9
10 void max_worker(int id){
11 for(int i = 0; i < BLOCK_SIZE; i++){
12 int currentIndex = BLOCK_SIZE * id + i;
13
14 if(currentIndex >= length)
15 break;
16 if(myMax < array[currentIndex])
17 myMax = array[currentIndex];
18 }
19 }
20 for(int i = 0; i < NPROCS; i++){
21 procs[i] = $spawn max_worker(i);
22 }
23 for(int i = 0; i < NPROCS; i++){
24 $wait(procs[i]);
25 }
26 return myMax;
27}
Note: See TracBrowser for help on using the repository browser.