-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple_master.cpp
More file actions
42 lines (35 loc) · 922 Bytes
/
Copy pathsimple_master.cpp
File metadata and controls
42 lines (35 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <omp.h>
#include <stdio.h>
#include <faasm/faasm.h>
bool fail = false;
bool accessed = false;
int main(int argc, char* argv[])
{
int mainNum = omp_get_thread_num();
#pragma omp parallel default(none) shared(mainNum)
{
#pragma omp master
{
#pragma omp critical
{
if (accessed) {
printf("Master section was entered multiple times\n");
fail = true;
}
accessed = true;
}
int localNum = omp_get_thread_num();
if (mainNum != localNum) {
printf("Master section not executed by master thread. "
"Got %d, expected %d\n",
localNum,
mainNum);
fail = true;
}
}
}
if (fail) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}