-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathheader_api_support.cpp
More file actions
46 lines (40 loc) · 1.12 KB
/
Copy pathheader_api_support.cpp
File metadata and controls
46 lines (40 loc) · 1.12 KB
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
43
44
45
46
#include <faasm/faasm.h>
#include <omp.h>
#include <stdio.h>
bool failed = false;
struct ThreadInfo
{
int32_t thread_num;
int32_t local_thread_num;
} __attribute__((aligned(64)));
int main(int argc, char* argv[])
{
int max = omp_get_max_threads();
auto infos = new ThreadInfo[max];
#pragma omp parallel num_threads(max) default(none) shared(infos)
{
int thread_num = omp_get_thread_num();
infos[thread_num].thread_num = thread_num;
infos[thread_num].local_thread_num = omp_get_num_threads();
}
for (int i = 0; i < max; i++) {
auto thread = infos[i];
if (thread.thread_num != i) {
printf("Expected thread_num to be %d but got %d\n",
i,
infos[i].thread_num);
failed = true;
}
if (thread.local_thread_num != max) {
printf("Expected local_thread_num to be %d but got %d\n",
max,
thread.local_thread_num);
failed = true;
}
}
delete[] infos;
if (failed) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}