[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / affinity / format / api.c
blob08805e7a520b2326dfe3bbe2e262af026e12bcd8
1 // RUN: %libomp-compile-and-run
2 // RUN: %libomp-run | %python %S/check.py -c 'CHECK' %s
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <omp.h>
9 #define XSTR(x) #x
10 #define STR(x) XSTR(x)
12 #define streqls(s1, s2) (!strcmp(s1, s2))
14 #define check(condition) \
15 if (!(condition)) { \
16 fprintf(stderr, "error: %s: %d: " STR(condition) "\n", __FILE__, \
17 __LINE__); \
18 exit(1); \
21 #define BUFFER_SIZE 1024
23 int main(int argc, char** argv) {
24 char buf[BUFFER_SIZE];
25 size_t needed;
27 omp_set_affinity_format("0123456789");
29 needed = omp_get_affinity_format(buf, BUFFER_SIZE);
30 check(streqls(buf, "0123456789"));
31 check(needed == 10)
33 // Check that it is truncated properly
34 omp_get_affinity_format(buf, 5);
35 check(streqls(buf, "0123"));
37 #pragma omp parallel
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"));
48 #pragma omp parallel num_threads(4)
50 omp_display_affinity(NULL);
53 return 0;
56 // CHECK: num_threads=4 0123456789