Skip to content

Conversation

@ye-luo
Copy link
Contributor

@ye-luo ye-luo commented Jun 30, 2025

closes #144786

@llvmbot
Copy link
Member

llvmbot commented Jun 30, 2025

@llvm/pr-subscribers-offload

Author: Ye Luo (ye-luo)

Changes

closes #144786


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

1 Files Affected:

  • (added) offload/test/offloading/disable_default_device.c (+22)
diff --git a/offload/test/offloading/disable_default_device.c b/offload/test/offloading/disable_default_device.c
new file mode 100644
index 0000000000000..77ea9d4669f19
--- /dev/null
+++ b/offload/test/offloading/disable_default_device.c
@@ -0,0 +1,22 @@
+// RUN: %libomptarget-compile-generic
+// RUN:   env OMP_TARGET_OFFLOAD=disabled %libomptarget-run-generic 2>&1 |
+// %fcheck-generic
+
+#include <omp.h>
+#include <stdio.h>
+
+// Sanity checks to make sure that this works and is thread safe.
+int main() {
+  // CHECK: number of devices 0
+  printf("number of devices %d\n", omp_get_num_devices());
+  // CHECK:initial device 0
+  printf("initial device %d\n", omp_get_initial_device());
+  // CHECK:default device 0
+  printf("default device %d\n", omp_get_default_device());
+  // CHECK: PASS
+  if (omp_get_initial_device() == omp_get_default_device()) {
+    printf("PASS\n");
+    return 0;
+  }
+  return 1;
+}

@ye-luo ye-luo merged commit 536ba87 into llvm:main Jun 30, 2025
9 checks passed
@ye-luo ye-luo deleted the add-test branch June 30, 2025 18:29
@@ -0,0 +1,22 @@
// RUN: %libomptarget-compile-generic
// RUN: env OMP_TARGET_OFFLOAD=disabled %libomptarget-run-generic 2>&1 |
Copy link
Member

@Meinersbur Meinersbur Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is nobody testing this? Fails unconditionally with

# shell parser error on RUN: at line 2: env OMP_TARGET_OFFLOAD=disabled /home/meinersbur/src/llvm/work/release/runtimes/runtimes-bins/offload/test/x86_64-unknown-linux-gnu-LTO/offloading/Output/disable_default_device.c.tmp 2>&1 |

FileCheck %s is missing at the end of the line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, didn't catch that. The OpenMP testing situation is a travesty and has been for several years.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow clang-format added a new line and break the added test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[libomptarget] omp_get_default_device doesn't returning host device in the case of OMP_TARGET_OFFLOAD=disabled

4 participants