[llvm] [OpenMP] Add test to print interop identifiers (PR #161434)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 30 13:30:57 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-offload

Author: Jan Patrick Lehr (jplehr)

<details>
<summary>Changes</summary>

The test covers some of the identifier symbols in the interop runtime.

This test, for now, is to guard against complete breakage, which was the result of the other `interop.c` test not being enabled on AMD and thus, not caught by our buildbots.
It can certainly be improved. :)

Depends on https://github.com/llvm/llvm-project/pull/161429 to restore functionality.

---
Full diff: https://github.com/llvm/llvm-project/pull/161434.diff


1 Files Affected:

- (added) offload/test/offloading/interop-print.c (+74) 


``````````diff
diff --git a/offload/test/offloading/interop-print.c b/offload/test/offloading/interop-print.c
new file mode 100644
index 0000000000000..a474501649777
--- /dev/null
+++ b/offload/test/offloading/interop-print.c
@@ -0,0 +1,74 @@
+// RUN: %libomptarget-compile-amdgcn-amd-amdhsa
+// RUN:   %libomptarget-run-generic 2>&1 | \
+// RUN:   %fcheck-generic -check-prefix=AMDCHECK
+
+// REQUIRES: amdgpu
+
+#include <omp.h>
+#include <stdio.h>
+
+const char* interop_int_to_string( const int interop_int )
+{
+    switch( interop_int )
+    {
+        case 1:
+            return "cuda";
+        case 2:
+            return "cuda_driver";
+        case 3:
+            return "opencl";
+        case 4:
+            return "sycl";
+        case 5:
+            return "hip";
+        case 6:
+            return "level_zero";
+        case 7:
+            return "hsa";
+        default:
+            return "unknown";
+    }
+}
+
+int main( int argc, char** argv )
+{
+    omp_interop_t iobj = omp_interop_none;
+    #pragma omp interop init(targetsync: iobj)
+
+    int err;
+    int interop_int = omp_get_interop_int( iobj, omp_ipr_fr_id, &err );
+
+    if( err )
+    {
+        fprintf( stderr, "omp_get_interop_int failed: %d\n", err );
+        return -1;
+    }
+
+  // FIXME: This should be hsa instead of hip
+  // AMDCHECK: {{.*}} hip
+    printf( "omp_get_interop_int returned %s\n", interop_int_to_string( interop_int ) );
+
+    const char* interop_vendor = omp_get_interop_str( iobj, omp_ipr_vendor_name, &err );
+    if( err )
+    {
+        fprintf( stderr, "omp_get_interop_str failed: %d\n", err );
+        return -1;
+    }
+
+  // AMDCHECK: {{.*}} amd
+    printf( "omp_get_interop_str returned %s\n", interop_vendor );
+
+    const char* interop_fr_name = omp_get_interop_str( iobj, omp_ipr_fr_name, &err );
+    if( err )
+    {
+        fprintf( stderr, "omp_get_interop_str failed: %d\n", err );
+        return -1;
+    }
+
+  // FIXME: This should be hsa instead of hip
+  // AMDCHECK: {{.*}} hip
+    printf( "omp_get_interop_str returned %s\n", interop_fr_name );
+
+    #pragma omp interop destroy(iobj)
+    return 0;
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/161434


More information about the llvm-commits mailing list