LLVM OpenMP
runtime
test
env
omp_num_threads_dev_resolve.c
Go to the documentation of this file.
1
// RUN: %libomp-compile && \
2
// RUN: env OMP_NUM_THREADS_ALL=8 OMP_NUM_THREADS_DEV=64 \
3
// RUN: OMP_NUM_THREADS_DEV_0=128 %libomp-run
4
//
5
// OpenMP 6.0 non-host precedence: `_DEV_<d>` > `_DEV` > `_ALL` > default.
6
7
#include <omp.h>
8
#include <stdio.h>
9
#include <string.h>
10
11
extern
const
char
*
__kmpc_get_device_env
(
const
char
*
name
,
int
device_id);
12
13
static
int
check
(
const
char
*got,
int
device_id,
const
char
*expect) {
14
if
(got == NULL || strcmp(got, expect) != 0) {
15
fprintf(stderr,
"FAIL: device_id=%d resolved to '%s', expected '%s'\n"
,
16
device_id, got ? got :
"(null)"
, expect);
17
return
1;
18
}
19
return
0;
20
}
21
22
int
main
(
void
) {
23
int
rc = 0;
24
if
(
omp_get_max_threads
() != 8) {
25
fprintf(stderr,
"FAIL: host omp_get_max_threads()=%d, expected 8\n"
,
26
omp_get_max_threads
());
27
return
1;
28
}
29
rc |=
check
(
__kmpc_get_device_env
(
"OMP_NUM_THREADS"
, 0), 0,
"128"
);
// _DEV_0
30
rc |=
check
(
__kmpc_get_device_env
(
"OMP_NUM_THREADS"
, 1), 1,
"64"
);
// _DEV
31
rc |=
check
(
__kmpc_get_device_env
(
"OMP_NUM_THREADS"
, 2), 2,
"64"
);
// _DEV
32
return
rc;
33
}
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_resolve.c:22
__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