1 | // RUN: %libomp-compile-and-run |
2 | #include <string.h> |
3 | #include <stdlib.h> |
4 | |
5 | enum kmp_target_offload_kind { |
6 | tgt_disabled = 0, |
7 | tgt_default = 1, |
8 | tgt_mandatory = 2 |
9 | }; |
10 | |
11 | extern int __kmpc_get_target_offload(); |
12 | extern void kmp_set_defaults(char const *str); |
13 | |
14 | const char *disabled_examples[] = { |
15 | // Allowed inputs |
16 | "disabled" , "DISABLED" , "Disabled" , "dIsAbLeD" , "DiSaBlEd" }; |
17 | |
18 | const char *default_examples[] = { |
19 | // Allowed inputs |
20 | "default" , "DEFAULT" , "Default" , "deFAulT" , "DEfaULt" , |
21 | // These should be changed to default (failed match) |
22 | "mandatry" , "defaults" , "disable" , "enabled" , "mandatorynot" }; |
23 | |
24 | const char *mandatory_examples[] = { |
25 | // Allowed inputs |
26 | "mandatory" , "MANDATORY" , "Mandatory" , "manDatoRy" , "MANdATOry" }; |
27 | |
28 | // Return target-offload-var ICV |
29 | int get_target_offload_icv() { |
30 | #pragma omp parallel |
31 | {} |
32 | return __kmpc_get_target_offload(); |
33 | } |
34 | |
35 | int main() { |
36 | int i; |
37 | const char *omp_target_offload = "OMP_TARGET_OFFLOAD=" ; |
38 | char buf[80]; |
39 | |
40 | for (i = 0; i < sizeof(disabled_examples) / sizeof(char *); ++i) { |
41 | strcpy(dest: buf, src: omp_target_offload); |
42 | strcat(dest: buf, src: disabled_examples[i]); |
43 | kmp_set_defaults(str: buf); |
44 | if (tgt_disabled != get_target_offload_icv()) |
45 | return EXIT_FAILURE; |
46 | } |
47 | for (i = 0; i < sizeof(default_examples) / sizeof(char *); ++i) { |
48 | strcpy(dest: buf, src: omp_target_offload); |
49 | strcat(dest: buf, src: default_examples[i]); |
50 | kmp_set_defaults(str: buf); |
51 | if (tgt_default != get_target_offload_icv()) |
52 | return EXIT_FAILURE; |
53 | } |
54 | for (i = 0; i < sizeof(mandatory_examples) / sizeof(char *); ++i) { |
55 | strcpy(dest: buf, src: omp_target_offload); |
56 | strcat(dest: buf, src: mandatory_examples[i]); |
57 | kmp_set_defaults(str: buf); |
58 | if (tgt_mandatory != get_target_offload_icv()) |
59 | return EXIT_FAILURE; |
60 | } |
61 | |
62 | return EXIT_SUCCESS; |
63 | } |
64 | |