Last change
on this file since 82ff201a 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
|
Line | |
---|
1 | #include <cofor.hfa> |
---|
2 | |
---|
3 | void add_num( long * total, long val ) { __atomic_fetch_add( total, (long)val, __ATOMIC_SEQ_CST ); } |
---|
4 | |
---|
5 | int main() { |
---|
6 | printf("start\n"); |
---|
7 | processor p[4]; |
---|
8 | long total = 0; |
---|
9 | cofor( i; 10 ) { |
---|
10 | __atomic_fetch_add( &total, i, __ATOMIC_SEQ_CST ); |
---|
11 | } |
---|
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 | } |
---|
21 | printf("total: %ld\n", total); |
---|
22 | printf("done\n"); |
---|
23 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.