Skip to content

Commit 25dca6a

Browse files
ro-iHoney Goyal
authored andcommitted
Fix Windows OpenMP build (llvm#170142)
fixes Windows build issue in llvm#168554
1 parent 44feed0 commit 25dca6a

File tree

5 files changed

+45
-32
lines changed

5 files changed

+45
-32
lines changed

openmp/runtime/src/exports_so.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ OMP_4.5 {
105105
} OMP_4.0;
106106
OMP_5.0 {
107107
} OMP_4.5;
108+
OMP_6.0 {
109+
} OMP_5.0;
108110

109111
# sets up GCC GOMP_ version dependency chain
110112
GOMP_1.0 {

openmp/runtime/src/exports_test_so.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ OMP_4.5 {
3636
} OMP_4.0;
3737
OMP_5.0 {
3838
} OMP_4.5;
39+
OMP_6.0 {
40+
} OMP_5.0;
3941

4042
# sets up GCC GOMP_ version dependency chain
4143
GOMP_1.0 {

openmp/runtime/src/kmp_ftn_cdecl.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,6 @@ char const __kmp_version_ftncdecl[] =
2929
#define FTN_STDCALL /* no stdcall */
3030
#include "kmp_ftn_os.h"
3131
#include "kmp_ftn_entry.h"
32-
33-
// FIXME: this is a hack to get the UID functions working for C.
34-
// It will be moved and also made available for Fortran in a follow-up patch.
35-
extern "C" {
36-
const char *FTN_STDCALL omp_get_uid_from_device(int device_num)
37-
KMP_WEAK_ATTRIBUTE_EXTERNAL;
38-
const char *FTN_STDCALL omp_get_uid_from_device(int device_num) {
39-
#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)
40-
return nullptr;
41-
#else
42-
const char *(*fptr)(int);
43-
if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_uid_from_device")))
44-
return (*fptr)(device_num);
45-
// Returns the same string as used by libomptarget
46-
return "HOST";
47-
#endif
48-
}
49-
int FTN_STDCALL omp_get_device_from_uid(const char *device_uid)
50-
KMP_WEAK_ATTRIBUTE_EXTERNAL;
51-
int FTN_STDCALL omp_get_device_from_uid(const char *device_uid) {
52-
#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)
53-
return omp_invalid_device;
54-
#else
55-
int (*fptr)(const char *);
56-
if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_device_from_uid")))
57-
return (*fptr)(device_uid);
58-
return KMP_EXPAND_NAME(FTN_GET_INITIAL_DEVICE)();
59-
#endif
60-
}
61-
}
6232
#else
6333
"no";
6434
#endif /* KMP_FTN_ENTRIES */

openmp/runtime/src/kmp_ftn_entry.h

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,13 +1543,40 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_MAX_TASK_PRIORITY)(void) {
15431543
#endif
15441544
}
15451545

1546-
// This function will be defined in libomptarget. When libomptarget is not
1547-
// loaded, we assume we are on the host and return KMP_HOST_DEVICE.
1546+
// These functions will be defined in libomptarget. When libomptarget is not
1547+
// loaded, we assume we are on the host.
15481548
// Compiler/libomptarget will handle this if called inside target.
15491549
int FTN_STDCALL FTN_GET_DEVICE_NUM(void) KMP_WEAK_ATTRIBUTE_EXTERNAL;
15501550
int FTN_STDCALL FTN_GET_DEVICE_NUM(void) {
15511551
return KMP_EXPAND_NAME(FTN_GET_INITIAL_DEVICE)();
15521552
}
1553+
const char *FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_UID_FROM_DEVICE)(int device_num)
1554+
KMP_WEAK_ATTRIBUTE_EXTERNAL;
1555+
const char *FTN_STDCALL
1556+
KMP_EXPAND_NAME(FTN_GET_UID_FROM_DEVICE)(int device_num) {
1557+
#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)
1558+
return nullptr;
1559+
#else
1560+
const char *(*fptr)(int);
1561+
if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_uid_from_device")))
1562+
return (*fptr)(device_num);
1563+
// Returns the same string as used by libomptarget
1564+
return "HOST";
1565+
#endif
1566+
}
1567+
int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_DEVICE_FROM_UID)(const char *device_uid)
1568+
KMP_WEAK_ATTRIBUTE_EXTERNAL;
1569+
int FTN_STDCALL
1570+
KMP_EXPAND_NAME(FTN_GET_DEVICE_FROM_UID)(const char *device_uid) {
1571+
#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)
1572+
return omp_invalid_device;
1573+
#else
1574+
int (*fptr)(const char *);
1575+
if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_device_from_uid")))
1576+
return (*fptr)(device_uid);
1577+
return KMP_EXPAND_NAME(FTN_GET_INITIAL_DEVICE)();
1578+
#endif
1579+
}
15531580

15541581
// Compiler will ensure that this is only called from host in sequential region
15551582
int FTN_STDCALL KMP_EXPAND_NAME(FTN_PAUSE_RESOURCE)(kmp_pause_status_t kind,
@@ -1906,6 +1933,10 @@ KMP_VERSION_SYMBOL(FTN_SET_AFFINITY_FORMAT, 50, "OMP_5.0");
19061933
// KMP_VERSION_SYMBOL(FTN_GET_SUPPORTED_ACTIVE_LEVELS, 50, "OMP_5.0");
19071934
// KMP_VERSION_SYMBOL(FTN_FULFILL_EVENT, 50, "OMP_5.0");
19081935

1936+
// OMP_6.0 versioned symbols
1937+
KMP_VERSION_SYMBOL(FTN_GET_UID_FROM_DEVICE, 60, "OMP_6.0");
1938+
KMP_VERSION_SYMBOL(FTN_GET_DEVICE_FROM_UID, 60, "OMP_6.0");
1939+
19091940
#endif // KMP_USE_VERSION_SYMBOLS
19101941

19111942
#ifdef __cplusplus

openmp/runtime/src/kmp_ftn_os.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@
140140
#define FTN_GET_MEMSPACE_NUM_RESOURCES omp_get_memspace_num_resources
141141
#define FTN_GET_SUBMEMSPACE omp_get_submemspace
142142
#define FTN_GET_DEVICE_NUM omp_get_device_num
143+
#define FTN_GET_UID_FROM_DEVICE omp_get_uid_from_device
144+
#define FTN_GET_DEVICE_FROM_UID omp_get_device_from_uid
143145
#define FTN_SET_AFFINITY_FORMAT omp_set_affinity_format
144146
#define FTN_GET_AFFINITY_FORMAT omp_get_affinity_format
145147
#define FTN_DISPLAY_AFFINITY omp_display_affinity
@@ -289,6 +291,8 @@
289291
#define FTN_ALLOC omp_alloc_
290292
#define FTN_FREE omp_free_
291293
#define FTN_GET_DEVICE_NUM omp_get_device_num_
294+
#define FTN_GET_UID_FROM_DEVICE omp_get_uid_from_device_
295+
#define FTN_GET_DEVICE_FROM_UID omp_get_device_from_uid_
292296
#define FTN_SET_AFFINITY_FORMAT omp_set_affinity_format_
293297
#define FTN_GET_AFFINITY_FORMAT omp_get_affinity_format_
294298
#define FTN_DISPLAY_AFFINITY omp_display_affinity_
@@ -436,6 +440,8 @@
436440
#define FTN_GET_MEMSPACE_NUM_RESOURCES OMP_GET_MEMSPACE_NUM_RESOURCES
437441
#define FTN_GET_SUBMEMSPACE OMP_GET_SUBMEMSPACE
438442
#define FTN_GET_DEVICE_NUM OMP_GET_DEVICE_NUM
443+
#define FTN_GET_UID_FROM_DEVICE OMP_GET_UID_FROM_DEVICE
444+
#define FTN_GET_DEVICE_FROM_UID OMP_GET_DEVICE_FROM_UID
439445
#define FTN_SET_AFFINITY_FORMAT OMP_SET_AFFINITY_FORMAT
440446
#define FTN_GET_AFFINITY_FORMAT OMP_GET_AFFINITY_FORMAT
441447
#define FTN_DISPLAY_AFFINITY OMP_DISPLAY_AFFINITY
@@ -585,6 +591,8 @@
585591
#define FTN_ALLOC OMP_ALLOC_
586592
#define FTN_FREE OMP_FREE_
587593
#define FTN_GET_DEVICE_NUM OMP_GET_DEVICE_NUM_
594+
#define FTN_GET_UID_FROM_DEVICE OMP_GET_UID_FROM_DEVICE_
595+
#define FTN_GET_DEVICE_FROM_UID OMP_GET_DEVICE_FROM_UID_
588596
#define FTN_SET_AFFINITY_FORMAT OMP_SET_AFFINITY_FORMAT_
589597
#define FTN_GET_AFFINITY_FORMAT OMP_GET_AFFINITY_FORMAT_
590598
#define FTN_DISPLAY_AFFINITY OMP_DISPLAY_AFFINITY_

0 commit comments

Comments
 (0)