LLVM OpenMP
runtime
test
env
omp_num_threads_dev_all_fallback.c
Go to the documentation of this file.
1
// RUN: %libomp-compile && env OMP_NUM_THREADS_ALL=8 %libomp-run
2
//
3
// OpenMP 6.0: every non-host device falls through to `_ALL` when no
4
// `_DEV[_d]` is set.
5
6
#include <omp.h>
7
#include <stdio.h>
8
#include <string.h>
9
10
extern
const
char
*
__kmpc_get_device_env
(
const
char
*
name
,
int
device_id);
11
12
static
int
check
(
int
device_id,
const
char
*got,
const
char
*expect) {
13
if
(!got || strcmp(got, expect) != 0) {
14
fprintf(stderr,
"FAIL: device_id=%d got '%s' expected '%s'\n"
, device_id,
15
got ? got :
"(null)"
, expect);
16
return
1;
17
}
18
return
0;
19
}
20
21
int
main
(
void
) {
22
int
rc = 0;
23
if
(
omp_get_max_threads
() != 8) {
24
fprintf(stderr,
"FAIL: host omp_get_max_threads()=%d, expected 8\n"
,
25
omp_get_max_threads
());
26
return
1;
27
}
28
rc |=
check
(0,
__kmpc_get_device_env
(
"OMP_NUM_THREADS"
, 0),
"8"
);
29
rc |=
check
(1,
__kmpc_get_device_env
(
"OMP_NUM_THREADS"
, 1),
"8"
);
30
rc |=
check
(2,
__kmpc_get_device_env
(
"OMP_NUM_THREADS"
, 2),
"8"
);
31
return
rc;
32
}
check
#define check(condition)
Definition
affinity_values.c:19
name
__itt_string_handle * name
Definition
ittnotify.h:3305
main
int main(void)
Definition
omp_num_threads_dev_all_fallback.c:21
__kmpc_get_device_env
const char * __kmpc_get_device_env(const char *name, int device_id)
Definition
kmp_device_env.cpp:311
omp_get_max_threads
int omp_get_max_threads()
Generated on
for LLVM OpenMP by
1.14.0