diff --git a/openmp/runtime/src/exports_so.txt b/openmp/runtime/src/exports_so.txt --- a/openmp/runtime/src/exports_so.txt +++ b/openmp/runtime/src/exports_so.txt @@ -107,6 +107,8 @@ } OMP_3.1; OMP_4.5 { } OMP_4.0; +OMP_5.0 { +} OMP_4.5; # sets up GCC GOMP_ version dependency chain GOMP_1.0 { diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -4012,6 +4012,11 @@ KMP_EXPORT void KMPC_CONVENTION kmpc_set_library(int); KMP_EXPORT void KMPC_CONVENTION kmpc_set_defaults(char const *); KMP_EXPORT void KMPC_CONVENTION kmpc_set_disp_num_buffers(int); +void KMP_EXPAND_NAME(ompc_set_affinity_format)(char const *format); +size_t KMP_EXPAND_NAME(ompc_get_affinity_format)(char *buffer, size_t size); +void KMP_EXPAND_NAME(ompc_display_affinity)(char const *format); +size_t KMP_EXPAND_NAME(ompc_capture_affinity)(char *buffer, size_t buf_size, + char const *format); enum kmp_target_offload_kind { tgt_disabled = 0, diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp --- a/openmp/runtime/src/kmp_csupport.cpp +++ b/openmp/runtime/src/kmp_csupport.cpp @@ -1997,8 +1997,7 @@ } /* OpenMP 5.0 Affinity Format API */ - -void ompc_set_affinity_format(char const *format) { +void KMP_EXPAND_NAME(ompc_set_affinity_format)(char const *format) { if (!__kmp_init_serial) { __kmp_serial_initialize(); } @@ -2006,7 +2005,7 @@ format, KMP_STRLEN(format) + 1); } -size_t ompc_get_affinity_format(char *buffer, size_t size) { +size_t KMP_EXPAND_NAME(ompc_get_affinity_format)(char *buffer, size_t size) { size_t format_size; if (!__kmp_init_serial) { __kmp_serial_initialize(); @@ -2019,7 +2018,7 @@ return format_size; } -void ompc_display_affinity(char const *format) { +void KMP_EXPAND_NAME(ompc_display_affinity)(char const *format) { int gtid; if (!TCR_4(__kmp_init_middle)) { __kmp_middle_initialize(); @@ -2029,8 +2028,8 @@ __kmp_aux_display_affinity(gtid, format); } -size_t ompc_capture_affinity(char *buffer, size_t buf_size, - char const *format) { +size_t KMP_EXPAND_NAME(ompc_capture_affinity)(char *buffer, size_t buf_size, + char const *format) { int gtid; size_t num_required; kmp_str_buf_t capture_buf; @@ -4401,3 +4400,35 @@ __kmp_str_free(&src_loc); } + +#ifdef KMP_USE_VERSION_SYMBOLS +// For GOMP compatibility there are two versions of each omp_* API. +// One is the plain C symbol and one is the Fortran symbol with an appended +// underscore. When we implement a specific ompc_* version of an omp_* +// function, we want the plain GOMP versioned symbol to alias the ompc_* version +// instead of the Fortran versions in kmp_ftn_entry.h +extern "C" { +// Have to undef these from omp.h so they aren't translated into +// their ompc counterparts in the KMP_VERSION_OMPC_SYMBOL macros below +#ifdef omp_set_affinity_format +#undef omp_set_affinity_format +#endif +#ifdef omp_get_affinity_format +#undef omp_get_affinity_format +#endif +#ifdef omp_display_affinity +#undef omp_display_affinity +#endif +#ifdef omp_capture_affinity +#undef omp_capture_affinity +#endif +KMP_VERSION_OMPC_SYMBOL(ompc_set_affinity_format, omp_set_affinity_format, 50, + "OMP_5.0"); +KMP_VERSION_OMPC_SYMBOL(ompc_get_affinity_format, omp_get_affinity_format, 50, + "OMP_5.0"); +KMP_VERSION_OMPC_SYMBOL(ompc_display_affinity, omp_display_affinity, 50, + "OMP_5.0"); +KMP_VERSION_OMPC_SYMBOL(ompc_capture_affinity, omp_capture_affinity, 50, + "OMP_5.0"); +} // extern "C" +#endif diff --git a/openmp/runtime/src/kmp_ftn_entry.h b/openmp/runtime/src/kmp_ftn_entry.h --- a/openmp/runtime/src/kmp_ftn_entry.h +++ b/openmp/runtime/src/kmp_ftn_entry.h @@ -58,6 +58,16 @@ #define KMP_DEREF * #endif +// For API with specific C vs. Fortran interfaces (ompc_* exists in +// kmp_csupport.cpp), only create GOMP versioned symbols of the API for the +// APPEND Fortran entries in this file. The GOMP versioned symbols of the C API +// will take place where the ompc_* functions are defined. +#if KMP_FTN_ENTRIES == KMP_FTN_APPEND +#define KMP_EXPAND_NAME_IF_APPEND(name) KMP_EXPAND_NAME(name) +#else +#define KMP_EXPAND_NAME_IF_APPEND(name) name +#endif + void FTN_STDCALL FTN_SET_STACKSIZE(int KMP_DEREF arg) { #ifdef KMP_STUB __kmps_set_stacksize(KMP_DEREF arg); @@ -445,7 +455,8 @@ * Set the value of the affinity-format-var ICV on the current device to the * format specified in the argument. */ -void FTN_STDCALL FTN_SET_AFFINITY_FORMAT(char const *format, size_t size) { +void FTN_STDCALL KMP_EXPAND_NAME_IF_APPEND(FTN_SET_AFFINITY_FORMAT)( + char const *format, size_t size) { #ifdef KMP_STUB return; #else @@ -466,7 +477,8 @@ * affinity-format-var ICV on the current device to buffer. If the return value * is larger than size, the affinity format specification is truncated. */ -size_t FTN_STDCALL FTN_GET_AFFINITY_FORMAT(char *buffer, size_t size) { +size_t FTN_STDCALL KMP_EXPAND_NAME_IF_APPEND(FTN_GET_AFFINITY_FORMAT)( + char *buffer, size_t size) { #ifdef KMP_STUB return 0; #else @@ -488,7 +500,8 @@ * specified by the format argument. If the format is NULL or a zero-length * string, the value of the affinity-format-var ICV is used. */ -void FTN_STDCALL FTN_DISPLAY_AFFINITY(char const *format, size_t size) { +void FTN_STDCALL KMP_EXPAND_NAME_IF_APPEND(FTN_DISPLAY_AFFINITY)( + char const *format, size_t size) { #ifdef KMP_STUB return; #else @@ -513,8 +526,8 @@ * return value is larger than size, the affinity format specification is * truncated. */ -size_t FTN_STDCALL FTN_CAPTURE_AFFINITY(char *buffer, char const *format, - size_t buf_size, size_t for_size) { +size_t FTN_STDCALL KMP_EXPAND_NAME_IF_APPEND(FTN_CAPTURE_AFFINITY)( + char *buffer, char const *format, size_t buf_size, size_t for_size) { #if defined(KMP_STUB) return 0; #else @@ -1345,7 +1358,8 @@ } // Compiler will ensure that this is only called from host in sequential region -int FTN_STDCALL FTN_PAUSE_RESOURCE(kmp_pause_status_t kind, int device_num) { +int FTN_STDCALL KMP_EXPAND_NAME(FTN_PAUSE_RESOURCE)(kmp_pause_status_t kind, + int device_num) { #ifdef KMP_STUB return 1; // just fail #else @@ -1362,7 +1376,8 @@ } // Compiler will ensure that this is only called from host in sequential region -int FTN_STDCALL FTN_PAUSE_RESOURCE_ALL(kmp_pause_status_t kind) { +int FTN_STDCALL + KMP_EXPAND_NAME(FTN_PAUSE_RESOURCE_ALL)(kmp_pause_status_t kind) { #ifdef KMP_STUB return 1; // just fail #else @@ -1536,8 +1551,15 @@ // OMP_5.0 versioned symbols // KMP_VERSION_SYMBOL(FTN_GET_DEVICE_NUM, 50, "OMP_5.0"); -// KMP_VERSION_SYMBOL(FTN_PAUSE_RESOURCE, 50, "OMP_5.0"); -// KMP_VERSION_SYMBOL(FTN_PAUSE_RESOURCE_ALL, 50, "OMP_5.0"); +KMP_VERSION_SYMBOL(FTN_PAUSE_RESOURCE, 50, "OMP_5.0"); +KMP_VERSION_SYMBOL(FTN_PAUSE_RESOURCE_ALL, 50, "OMP_5.0"); +// The C versions (KMP_FTN_PLAIN) of these symbols are in kmp_csupport.c +#if KMP_FTN_ENTRIES == KMP_FTN_APPEND +KMP_VERSION_SYMBOL(FTN_CAPTURE_AFFINITY, 50, "OMP_5.0"); +KMP_VERSION_SYMBOL(FTN_DISPLAY_AFFINITY, 50, "OMP_5.0"); +KMP_VERSION_SYMBOL(FTN_GET_AFFINITY_FORMAT, 50, "OMP_5.0"); +KMP_VERSION_SYMBOL(FTN_SET_AFFINITY_FORMAT, 50, "OMP_5.0"); +#endif // KMP_VERSION_SYMBOL(FTN_GET_SUPPORTED_ACTIVE_LEVELS, 50, "OMP_5.0"); // KMP_VERSION_SYMBOL(FTN_FULFILL_EVENT, 50, "OMP_5.0"); diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h --- a/openmp/runtime/src/kmp_os.h +++ b/openmp/runtime/src/kmp_os.h @@ -406,9 +406,24 @@ api_name) "@" ver_str "\n\t"); \ __asm__(".symver " KMP_STR(__kmp_api_##api_name) "," KMP_STR( \ api_name) "@@" default_ver "\n\t") + +#define KMP_VERSION_OMPC_SYMBOL(apic_name, api_name, ver_num, ver_str) \ + _KMP_VERSION_OMPC_SYMBOL(apic_name, api_name, ver_num, ver_str, "VERSION") +#define _KMP_VERSION_OMPC_SYMBOL(apic_name, api_name, ver_num, ver_str, \ + default_ver) \ + __typeof__(__kmp_api_##apic_name) __kmp_api_##apic_name##_##ver_num##_alias \ + __attribute__((alias(KMP_STR(__kmp_api_##apic_name)))); \ + __asm__(".symver " KMP_STR(__kmp_api_##apic_name) "," KMP_STR( \ + apic_name) "@@" default_ver "\n\t"); \ + __asm__( \ + ".symver " KMP_STR(__kmp_api_##apic_name##_##ver_num##_alias) "," KMP_STR( \ + api_name) "@" ver_str "\n\t") + #else // KMP_USE_VERSION_SYMBOLS #define KMP_EXPAND_NAME(api_name) api_name #define KMP_VERSION_SYMBOL(api_name, ver_num, ver_str) /* Nothing */ +#define KMP_VERSION_OMPC_SYMBOL(apic_name, api_name, ver_num, \ + ver_str) /* Nothing */ #endif // KMP_USE_VERSION_SYMBOLS /* Temporary note: if performance testing of this passes, we can remove