1 // RUN: %libomp-compile-and-run
2 // RUN: %libomp-run | %python %S/check.py -c 'CHECK' %s
10 #define STR(x) XSTR(x)
12 #define streqls(s1, s2) (!strcmp(s1, s2))
14 #define check(condition) \
16 fprintf(stderr, "error: %s: %d: " STR(condition) "\n", __FILE__, \
21 #define BUFFER_SIZE 1024
23 int main(int argc
, char** argv
) {
24 char buf
[BUFFER_SIZE
];
27 omp_set_affinity_format("0123456789");
29 needed
= omp_get_affinity_format(buf
, BUFFER_SIZE
);
30 check(streqls(buf
, "0123456789"));
33 // Check that it is truncated properly
34 omp_get_affinity_format(buf
, 5);
35 check(streqls(buf
, "0123"));
40 size_t needed
= omp_capture_affinity(my_buf
, 512, NULL
);
41 check(streqls(my_buf
, "0123456789"));
43 // Check that it is truncated properly
44 omp_capture_affinity(my_buf
, 5, NULL
);
45 check(streqls(my_buf
, "0123"));
48 #pragma omp parallel num_threads(4)
50 omp_display_affinity(NULL
);
56 // CHECK: num_threads=4 0123456789