source: tests/concurrent/barrier/generation.cfa @ a32a887

ADTast-experimental
Last change on this file since a32a887 was 7bc84b8, checked in by Peter A. Buhr <pabuhr@…>, 2 years ago

remove unsigned cast for prng calls

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[93b8cf4]1//
2// Cforall Version 1.0.0 Copyright (C) 2022 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// concurrent/barrier/generation.cfa -- simple test that validates barriers by printing
8//                                      alphabetical generations
9//
10// Author           : Thierry Delisle
11// Created On       : Thu Mar 31 16:43:45 2022
12// Last Modified By :
13// Last Modified On :
14// Update Count     :
15//
16
[31ef267]17// Test validates barrier by having each thread print ABCD...
18// If the barrier is correct it should print all As, all Bs, etc.
[93b8cf4]19
[31ef267]20unsigned NUM_THREADS = 9;
21unsigned NUM_LAPS = 53;
[93b8cf4]22
23#include <concurrency/barrier.hfa>
24#include <fstream.hfa>
25#include <mutex_stmt.hfa>
26#include <thread.hfa>
27
[31ef267]28// The barrier we are testing
[93b8cf4]29barrier bar = { NUM_THREADS };
30
[31ef267]31
[93b8cf4]32thread Tester {};
33void main( Tester & this ) {
[31ef267]34        // Repeat the experiment a few times
[93b8cf4]35        for(NUM_LAPS)
[31ef267]36                // For each letters
[93b8cf4]37                for(c; 'A' ~= 'Z') {
[31ef267]38                        // Yield for chaos
[7bc84b8]39                        yield( prng(this, 10) );
[31ef267]40
41                        // Print the generation, no newline because
[93b8cf4]42                        mutex(sout) sout | c | nonl;
[31ef267]43
44                        // Yield again for more chaos
[7bc84b8]45                        yield( prng(this, 10) );
[31ef267]46
47                        // Block on the barrier
[93b8cf4]48                        block(bar);
49                }
50}
51
52int main() {
53        processor p[4];
54        {
55                Tester testers[NUM_THREADS];
56        }
57        sout | nl;
[d2ad151]58}
Note: See TracBrowser for help on using the repository browser.