Skip various cmp-mem-const tests on lp64 hppa*-*-*
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / display-affinity-1.c
bloba67bb37f1f0a582488beb204d3f4b1a9908f5e16
1 /* { dg-set-target-env-var OMP_PROC_BIND "spread,close" } */
2 /* { dg-set-target-env-var OMP_PLACES "cores" } */
3 /* { dg-set-target-env-var OMP_NUM_THREADS "4" } */
4 /* { dg-set-target-env-var OMP_AFFINITY_FORMAT "hello" } */
6 #include <omp.h>
7 #include <string.h>
8 #include <stdlib.h>
10 int
11 main ()
13 #define FMT "L:%0.5L%%%n>%32H<!%.33{host}!%.6P_%i_%0.18i_%0.7{ancestor_tnum} %18A"
14 char buf[] = FMT, hostname[256], buf2[512 + 32], *q;
15 size_t l, l2, l3;
16 char *r = getenv ("OMP_AFFINITY_FORMAT");
17 if (r && strcmp (r, "hello") == 0)
19 if (omp_get_affinity_format (NULL, 0) != 5)
20 abort ();
21 if (omp_get_affinity_format (buf2, 3) != 5
22 || strcmp (buf2, "he") != 0)
23 abort ();
24 if (omp_get_affinity_format (buf2, 6) != 5
25 || strcmp (buf2, "hello") != 0)
26 abort ();
28 omp_set_affinity_format (buf);
29 memset (buf, '^', sizeof (buf));
30 if (omp_get_affinity_format (NULL, 0) != sizeof (buf) - 1)
31 abort ();
32 if (omp_get_affinity_format (buf, 3) != sizeof (buf) - 1
33 || buf[0] != FMT[0] || buf[1] != FMT[1] || buf[2] != '\0')
34 abort ();
35 memset (buf, ' ', sizeof (buf));
36 if (omp_get_affinity_format (buf, sizeof (buf) - 1) != sizeof (buf) - 1
37 || strncmp (buf, FMT, sizeof (buf) - 2) != 0
38 || buf[sizeof (buf) - 2] != '\0')
39 abort ();
40 memset (buf, '-', sizeof (buf));
41 if (omp_get_affinity_format (buf, sizeof (buf)) != sizeof (buf) - 1
42 || strcmp (buf, FMT) != 0)
43 abort ();
44 memset (buf, '0', sizeof (buf));
45 omp_display_affinity (NULL);
46 omp_display_affinity ("");
47 omp_display_affinity ("%%%0.9N");
48 omp_set_affinity_format ("%{host}");
49 l = omp_capture_affinity (hostname, sizeof hostname, NULL);
50 if (l < sizeof (hostname))
52 if (strlen (hostname) != l)
53 abort ();
54 l2 = omp_capture_affinity (NULL, 0,
55 "%0.5{nesting_level}%%%32{host}|||%.33H"
56 "%0.7a%3N!%N!");
57 if (l2 != (5 + 1 + (l > 32 ? l : 32) + 3 + (l > 33 ? l : 33)
58 + 7 + 3 + 1 + 1 + 1))
59 abort ();
60 omp_set_affinity_format ("%.5L%%%32H|||%.33{host}%0.7{ancestor_tnum}"
61 "%3{num_threads}!%{num_threads}!");
62 l3 = omp_capture_affinity (buf2, sizeof buf2, "");
63 if (l3 != l2)
64 abort ();
65 if (memcmp (buf2, " 0%", 5 + 1) != 0)
66 abort ();
67 q = buf2 + 6;
68 if (memcmp (q, hostname, l) != 0)
69 abort ();
70 q += l;
71 if (l < 32)
72 for (l3 = 32 - l; l3; l3--)
73 if (*q++ != ' ')
74 abort ();
75 if (memcmp (q, "|||", 3) != 0)
76 abort ();
77 q += 3;
78 if (l < 33)
79 for (l3 = 33 - l; l3; l3--)
80 if (*q++ != ' ')
81 abort ();
82 if (memcmp (q, hostname, l) != 0)
83 abort ();
84 q += l;
85 if (strcmp (q, "-0000011 !1!") != 0)
86 abort ();
88 #pragma omp parallel num_threads (4) proc_bind(spread)
89 omp_display_affinity ("%0.2a!%n!%.4L!%N;%.2t;%0.2T;%{team_num};%{num_teams};%A");
90 return 0;