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

Jan Patrick Lehr via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 30 13:30:22 PDT 2025


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

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.

>From 45b7bab693ca0d64d3f795e603035c2ea6395602 Mon Sep 17 00:00:00 2001
From: JP Lehr <JanPatrick.Lehr at amd.com>
Date: Tue, 30 Sep 2025 15:23:29 -0500
Subject: [PATCH] [OpenMP] Add test to print interop identifiers

The test covers some of the identifier symbols in the interop runtime.
---
 offload/test/offloading/interop-print.c | 74 +++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 offload/test/offloading/interop-print.c

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;
+}



More information about the llvm-commits mailing list