main
test-branch
| Rev | Line | |
|---|
| [181ebba] | 1 | #include<comm.cvh>
|
|---|
| 2 |
|
|---|
| 3 | $input int N=2;
|
|---|
| 4 | $input int M=2;
|
|---|
| 5 |
|
|---|
| 6 | $gcomm gcomm=$gcomm_create($here, N);
|
|---|
| 7 |
|
|---|
| 8 | void process(int id){
|
|---|
| 9 | $comm comm=$comm_create($here, gcomm, id);
|
|---|
| 10 |
|
|---|
| 11 | void thread(int tid){
|
|---|
| 12 | int size, src;
|
|---|
| 13 | $message msg;
|
|---|
| 14 | int data=(id+1)*(id+1);
|
|---|
| 15 |
|
|---|
| 16 | size=$comm_size(comm);
|
|---|
| 17 | src=$comm_place(comm);
|
|---|
| 18 | msg=$message_pack(src, (src+1)%N, 0, &data, sizeof(int));
|
|---|
| 19 | $comm_enqueue(comm, msg);
|
|---|
| 20 | msg=$comm_dequeue(comm, (src-1)%N, 0);
|
|---|
| 21 | }
|
|---|
| 22 | $parfor(int i: 0 .. M-1)
|
|---|
| 23 | thread(i);
|
|---|
| 24 | $comm_destroy(comm);
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | int main(void){
|
|---|
| 28 | $parfor(int i: 0 .. N-1)
|
|---|
| 29 | process(i);
|
|---|
| 30 | $gcomm_destroy(gcomm, NULL);
|
|---|
| 31 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.