[clang] [llvm] [OpenMP] Adds omp_target_is_accessible routine (PR #138294)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 31 09:07:39 PDT 2025


================
@@ -93,7 +93,8 @@ EXTERN int omp_get_device_num(void) {
 EXTERN int omp_get_initial_device(void) {
   TIMESCOPE();
   OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
-  int HostDevice = omp_get_num_devices();
+  int NumDevices = omp_get_num_devices();
+  int HostDevice = NumDevices == 0 ? -1 : NumDevices;
----------------
jprotze wrote:

The application will always see the value provided from libomp, which is 0 if no other device is present: https://github.com/llvm/llvm-project/blob/c05611f1917ca01371e7f7915f4c94055c5a19cf/openmp/runtime/src/kmp_ftn_entry.h#L1197

Only the get_num_devices call is deligated to libomptarget

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


More information about the llvm-commits mailing list