source: tests/concurrency/cofor.cfa @ 52a5262e

Last change on this file since 52a5262e was 26dfce5, checked in by caparsons <caparson@…>, 13 months ago

Updated cofor test to use new corun statement

  • Property mode set to 100644
File size: 712 bytes
Line 
1#include <cofor.hfa>
2
3
4void add_num( long * total, long val ) { __atomic_fetch_add( total, (long)val, __ATOMIC_SEQ_CST ); }
5
6int main() {
7    printf("start\n");
8    processor p[4];
9    long total = 0;
10    COFOR( i, 0, 10, __atomic_fetch_add( &total, i, __ATOMIC_SEQ_CST ); );
11    {
12        corun;      // does nothing
13        corun{};    // does nothing
14        corun add_num( &total, 11 );
15        corun { add_num( &total, 12 ); }
16        corun __atomic_fetch_add( &total, 13, __ATOMIC_SEQ_CST );
17        corun { __atomic_fetch_add( &total, 14, __ATOMIC_SEQ_CST ); }
18        __atomic_fetch_add( &total, 15, __ATOMIC_SEQ_CST ); // run by main thd
19    }
20    printf("total: %ld\n", total);
21    printf("done\n");
22}
Note: See TracBrowser for help on using the repository browser.