Last change
on this file since 97f9619 was
0d41b2e,
checked in by caparson <caparson@…>, 12 months ago
|
switched test to use new cofor syntax
|
-
Property mode set to
100644
|
File size:
722 bytes
|
Rev | Line | |
---|
[1ed5e9e] | 1 | #include <cofor.hfa> |
---|
| 2 | |
---|
[26dfce5] | 3 | void add_num( long * total, long val ) { __atomic_fetch_add( total, (long)val, __ATOMIC_SEQ_CST ); } |
---|
[1ed5e9e] | 4 | |
---|
| 5 | int main() { |
---|
| 6 | printf("start\n"); |
---|
| 7 | processor p[4]; |
---|
[26dfce5] | 8 | long total = 0; |
---|
[0d41b2e] | 9 | cofor( i; 10 ) { |
---|
| 10 | __atomic_fetch_add( &total, i, __ATOMIC_SEQ_CST ); |
---|
| 11 | } |
---|
[26dfce5] | 12 | { |
---|
| 13 | corun; // does nothing |
---|
| 14 | corun{}; // does nothing |
---|
| 15 | corun add_num( &total, 11 ); |
---|
| 16 | corun { add_num( &total, 12 ); } |
---|
| 17 | corun __atomic_fetch_add( &total, 13, __ATOMIC_SEQ_CST ); |
---|
| 18 | corun { __atomic_fetch_add( &total, 14, __ATOMIC_SEQ_CST ); } |
---|
| 19 | __atomic_fetch_add( &total, 15, __ATOMIC_SEQ_CST ); // run by main thd |
---|
| 20 | } |
---|
[1ed5e9e] | 21 | printf("total: %ld\n", total); |
---|
| 22 | printf("done\n"); |
---|
[5a1ae14] | 23 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.