Last change
on this file since e4c3819 was e3784a50, checked in by caparsons <caparson@…>, 2 years ago |
updated cofor test to use macro
|
-
Property mode
set to
100644
|
File size:
596 bytes
|
Rev | Line | |
---|
[1ed5e9e] | 1 | #include <cofor.hfa>
|
---|
| 2 |
|
---|
| 3 | long total = 0;
|
---|
| 4 | void inner_loop( long i ) { __atomic_fetch_add( &total, i, __ATOMIC_SEQ_CST ); }
|
---|
| 5 | void add_num( void * arg ) { __atomic_fetch_add( &total, (long)arg, __ATOMIC_SEQ_CST ); }
|
---|
| 6 |
|
---|
| 7 | int main() {
|
---|
| 8 | printf("start\n");
|
---|
| 9 | processor p[4];
|
---|
[e3784a50] | 10 | COFOR( i, 0, 10, __atomic_fetch_add( &total, i, __ATOMIC_SEQ_CST ); );
|
---|
[1ed5e9e] | 11 | parallel_stmt_t stmts[5] = { add_num, add_num, add_num, add_num, add_num };
|
---|
| 12 | void * nums[5] = { (void *)11, (void *)12, (void *)13, (void *)14, (void *)15 };
|
---|
| 13 | parallel( stmts, nums, 5 );
|
---|
| 14 | printf("total: %ld\n", total);
|
---|
| 15 | printf("done\n");
|
---|
| 16 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.