LLVM OpenMP
20.0.0git
runtime
test
affinity
format
api.c
Go to the documentation of this file.
1
// RUN: %libomp-compile-and-run
2
// RUN: %libomp-run | %python %S/check.py -c 'CHECK' %s
3
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <string.h>
7
#include <omp.h>
8
9
#define XSTR(x) #x
10
#define STR(x) XSTR(x)
11
12
#define streqls(s1, s2) (!strcmp(s1, s2))
13
14
#define check(condition) \
15
if (!(condition)) { \
16
fprintf(stderr, "error: %s: %d: "
STR(condition) "\n", __FILE__, \
17
__LINE__); \
18
exit(1); \
19
}
20
21
#define BUFFER_SIZE 1024
22
23
int
main
(
int
argc,
char
** argv) {
24
char
buf
[
BUFFER_SIZE
];
25
size_t
needed;
26
27
omp_set_affinity_format
(
"0123456789"
);
28
29
needed =
omp_get_affinity_format
(
buf
,
BUFFER_SIZE
);
30
check
(
streqls
(
buf
,
"0123456789"
));
31
check
(needed == 10)
32
33
// Check that it is truncated properly
34
omp_get_affinity_format
(
buf
, 5);
35
check
(
streqls
(
buf
,
"0123"
));
36
37
#pragma omp parallel
38
{
39
char
my_buf[512];
40
size_t
needed =
omp_capture_affinity
(my_buf, 512, NULL);
41
check
(
streqls
(my_buf,
"0123456789"
));
42
check
(needed == 10);
43
// Check that it is truncated properly
44
omp_capture_affinity
(my_buf, 5, NULL);
45
check
(
streqls
(my_buf,
"0123"
));
46
}
47
48
#pragma omp parallel num_threads(4)
49
{
50
omp_display_affinity
(NULL);
51
}
52
53
return
0;
54
}
55
56
// CHECK: num_threads=4 0123456789
buf
char buf[BUFFER_SIZE]
Definition:
affinity_values.c:34
BUFFER_SIZE
#define BUFFER_SIZE
Definition:
api.c:21
streqls
#define streqls(s1, s2)
Definition:
api.c:12
check
#define check(condition)
Definition:
api.c:14
omp_get_affinity_format
#define omp_get_affinity_format
Definition:
kmp_stub.cpp:38
omp_set_affinity_format
#define omp_set_affinity_format
Definition:
kmp_stub.cpp:37
omp_display_affinity
#define omp_display_affinity
Definition:
kmp_stub.cpp:39
omp_capture_affinity
#define omp_capture_affinity
Definition:
kmp_stub.cpp:40
main
int main()
Definition:
test-touch.c:21
Generated on Wed Jan 29 2025 20:58:00 for LLVM OpenMP by
1.9.6