source: tests/concurrent/barrier/order.cfa@ 93b8cf4

ADT ast-experimental enum pthread-emulation qualifiedEnum stuck-waitfor-destruct
Last change on this file since 93b8cf4 was 93b8cf4, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Added a simple barrier and accompagnying tests.

  • Property mode set to 100644
File size: 1.1 KB
Line 
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/order.cfa -- validates barriers the return value of
8// barrier block
9//
10// Author : Thierry Delisle
11// Created On : Fri Apr 01 11:39:09 2022
12// Last Modified By :
13// Last Modified On :
14// Update Count :
15//
16
17#include <concurrency/barrier.hfa>
18#include <fstream.hfa>
19#include <mutex_stmt.hfa>
20#include <thread.hfa>
21
22const int NUM_LAPS = 173;
23const int NUM_THREADS = 11;
24
25barrier bar = { NUM_THREADS };
26volatile int * generation;
27
28thread Tester {};
29void main( Tester & ) {
30 for(l; NUM_LAPS) {
31 int ret = block(bar);
32 int g = generation[ret];
33 if(g != l) {
34 sout | "Gen" | l | ": Expeced generation at" | ret | "to be" | l | "was" | g;
35 }
36 generation[ret] = g+1;
37 }
38}
39
40int main() {
41 volatile int gen_data[NUM_THREADS];
42 for(t; NUM_THREADS)
43 gen_data[t] = 0;
44
45 generation = gen_data;
46
47 processor p[4];
48 {
49 Tester testers[NUM_THREADS];
50 }
51 sout | "done";
52}
Note: See TracBrowser for help on using the repository browser.