Skip to content

Commit 54544d9

Browse files
committed
[OpenMP] Add test to print interop identifiers
The test covers some of the identifier symbols in the interop runtime.
1 parent 8ae0a20 commit 54544d9

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// RUN: %libomptarget-compile-amdgcn-amd-amdhsa
2+
// RUN: %libomptarget-run-generic 2>&1 | \
3+
// RUN: %fcheck-generic -check-prefix=AMDCHECK
4+
5+
// REQUIRES: amdgpu
6+
7+
#include <omp.h>
8+
#include <stdio.h>
9+
10+
const char *interop_int_to_string(const int interop_int) {
11+
switch (interop_int) {
12+
case 1:
13+
return "cuda";
14+
case 2:
15+
return "cuda_driver";
16+
case 3:
17+
return "opencl";
18+
case 4:
19+
return "sycl";
20+
case 5:
21+
return "hip";
22+
case 6:
23+
return "level_zero";
24+
case 7:
25+
return "hsa";
26+
default:
27+
return "unknown";
28+
}
29+
}
30+
31+
int main(int argc, char **argv) {
32+
omp_interop_t iobj = omp_interop_none;
33+
#pragma omp interop init(targetsync : iobj)
34+
35+
int err;
36+
int interop_int = omp_get_interop_int(iobj, omp_ipr_fr_id, &err);
37+
38+
if (err) {
39+
fprintf(stderr, "omp_get_interop_int failed: %d\n", err);
40+
return -1;
41+
}
42+
43+
// FIXME: This should be hsa instead of hip
44+
// AMDCHECK: {{.*}} hip
45+
printf("omp_get_interop_int returned %s\n",
46+
interop_int_to_string(interop_int));
47+
48+
const char *interop_vendor =
49+
omp_get_interop_str(iobj, omp_ipr_vendor_name, &err);
50+
if (err) {
51+
fprintf(stderr, "omp_get_interop_str failed: %d\n", err);
52+
return -1;
53+
}
54+
55+
// AMDCHECK: {{.*}} amd
56+
printf("omp_get_interop_str returned %s\n", interop_vendor);
57+
58+
const char *interop_fr_name =
59+
omp_get_interop_str(iobj, omp_ipr_fr_name, &err);
60+
if (err) {
61+
fprintf(stderr, "omp_get_interop_str failed: %d\n", err);
62+
return -1;
63+
}
64+
65+
// FIXME: This should be hsa instead of hip
66+
// AMDCHECK: {{.*}} hip
67+
printf("omp_get_interop_str returned %s\n", interop_fr_name);
68+
69+
#pragma omp interop destroy(iobj)
70+
return 0;
71+
}

0 commit comments

Comments
 (0)