Skip to content

Commit a8b09cf

Browse files
committed
fix libomptarget symbol lookup similar to how other functions handle it
1 parent eed9b95 commit a8b09cf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

openmp/runtime/src/kmp_ftn_entry.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,13 +1553,27 @@ int FTN_STDCALL FTN_GET_DEVICE_NUM(void) {
15531553
const char *FTN_STDCALL FTN_GET_UID_FROM_DEVICE(int device_num)
15541554
KMP_WEAK_ATTRIBUTE_EXTERNAL;
15551555
const char *FTN_STDCALL FTN_GET_UID_FROM_DEVICE(int device_num) {
1556+
#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)
1557+
return nullptr;
1558+
#else
1559+
const char *(*fptr)(int);
1560+
if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_uid_from_device")))
1561+
return (*fptr)(device_num);
15561562
// Returns the same string as used by libomptarget
15571563
return "HOST";
1564+
#endif
15581565
}
15591566
int FTN_STDCALL FTN_GET_DEVICE_FROM_UID(const char *device_uid)
15601567
KMP_WEAK_ATTRIBUTE_EXTERNAL;
15611568
int FTN_STDCALL FTN_GET_DEVICE_FROM_UID(const char *device_uid) {
1569+
#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)
1570+
return omp_invalid_device;
1571+
#else
1572+
int (*fptr)(const char *);
1573+
if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_device_from_uid")))
1574+
return (*fptr)(device_uid);
15621575
return KMP_EXPAND_NAME(FTN_GET_INITIAL_DEVICE)();
1576+
#endif
15631577
}
15641578

15651579
// Compiler will ensure that this is only called from host in sequential region

0 commit comments

Comments
 (0)