[Openmp-commits] [openmp] r328046 - Read OMP_TARGET_OFFLOAD and provide API to access ICV
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Tue Mar 20 14:18:18 PDT 2018
Author: jlpeyton
Date: Tue Mar 20 14:18:17 2018
New Revision: 328046
URL: http://llvm.org/viewvc/llvm-project?rev=328046&view=rev
Log:
Read OMP_TARGET_OFFLOAD and provide API to access ICV
Added settings code to read OMP_TARGET_OFFLOAD environment variable. Added
target-offload-var ICV as __kmp_target_offload, set via OMP_TARGET_OFFLOAD,
if available, otherwise defaulting to DEFAULT. Valid values for the ICV are
specified as enum values {0,1,2} for disabled, default, and mandatory. An
internal API access function __kmpc_get_target_offload is provided.
Patch by Terry Wilmarth
Differential Revision: https://reviews.llvm.org/D44577
Modified:
openmp/trunk/runtime/src/dllexports
openmp/trunk/runtime/src/kmp.h
openmp/trunk/runtime/src/kmp_csupport.cpp
openmp/trunk/runtime/src/kmp_global.cpp
openmp/trunk/runtime/src/kmp_settings.cpp
Modified: openmp/trunk/runtime/src/dllexports
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/dllexports?rev=328046&r1=328045&r2=328046&view=diff
==============================================================================
--- openmp/trunk/runtime/src/dllexports (original)
+++ openmp/trunk/runtime/src/dllexports Tue Mar 20 14:18:17 2018
@@ -403,6 +403,7 @@ kmpc_set_disp_num_buffers
%ifdef OMP_45
__kmpc_task_reduction_init 268
__kmpc_task_reduction_get_th_data 269
+ __kmpc_get_target_offload 271
%endif
%endif
Modified: openmp/trunk/runtime/src/kmp.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp.h?rev=328046&r1=328045&r2=328046&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp.h (original)
+++ openmp/trunk/runtime/src/kmp.h Tue Mar 20 14:18:17 2018
@@ -3813,6 +3813,18 @@ KMP_EXPORT void KMPC_CONVENTION kmpc_set
KMP_EXPORT void KMPC_CONVENTION kmpc_set_defaults(char const *);
KMP_EXPORT void KMPC_CONVENTION kmpc_set_disp_num_buffers(int);
+#if OMP_50_ENABLED
+enum kmp_target_offload_kind {
+ tgt_disabled = 0,
+ tgt_default = 1,
+ tgt_mandatory = 2
+};
+typedef enum kmp_target_offload_kind kmp_target_offload_kind_t;
+// Set via OMP_TARGET_OFFLOAD if specified, defaults to tgt_default otherwise
+extern kmp_target_offload_kind_t __kmp_target_offload;
+extern int __kmpc_get_target_offload();
+#endif
+
#ifdef __cplusplus
}
#endif
Modified: openmp/trunk/runtime/src/kmp_csupport.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_csupport.cpp?rev=328046&r1=328045&r2=328046&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_csupport.cpp (original)
+++ openmp/trunk/runtime/src/kmp_csupport.cpp Tue Mar 20 14:18:17 2018
@@ -4065,4 +4065,8 @@ void __kmpc_doacross_fini(ident_t *loc,
}
#endif
+#if OMP_50_ENABLED
+int __kmpc_get_target_offload(void) { return __kmp_target_offload; }
+#endif // OMP_50_ENABLED
+
// end of file //
Modified: openmp/trunk/runtime/src/kmp_global.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_global.cpp?rev=328046&r1=328045&r2=328046&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_global.cpp (original)
+++ openmp/trunk/runtime/src/kmp_global.cpp Tue Mar 20 14:18:17 2018
@@ -502,4 +502,7 @@ int _You_must_link_with_Intel_OpenMP_lib
int _You_must_link_with_Microsoft_OpenMP_library = 1;
#endif
+#if OMP_50_ENABLED
+kmp_target_offload_kind_t __kmp_target_offload = tgt_default;
+#endif
// end of file //
Modified: openmp/trunk/runtime/src/kmp_settings.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_settings.cpp?rev=328046&r1=328045&r2=328046&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_settings.cpp (original)
+++ openmp/trunk/runtime/src/kmp_settings.cpp Tue Mar 20 14:18:17 2018
@@ -1179,6 +1179,46 @@ static void __kmp_stg_print_default_devi
} // __kmp_stg_print_default_device
#endif
+#if OMP_50_ENABLED
+// -----------------------------------------------------------------------------
+// OpenMP 5.0: OMP_TARGET_OFFLOAD
+static void __kmp_stg_parse_target_offload(char const *name, char const *value,
+ void *data) {
+ const char *next = value;
+ const char *scan = next;
+
+ __kmp_target_offload = tgt_default;
+ SKIP_WS(next);
+ if (*next == '\0')
+ return;
+ scan = next;
+ if (__kmp_match_str("MANDATORY", scan, &next)) {
+ __kmp_target_offload = tgt_mandatory;
+ } else if (__kmp_match_str("DISABLED", scan, &next)) {
+ __kmp_target_offload = tgt_disabled;
+ } else if (__kmp_match_str("DEFAULT", scan, &next)) {
+ __kmp_target_offload = tgt_default;
+ } else {
+ KMP_WARNING(SyntaxErrorUsing, name, "DEFAULT");
+ }
+
+} // __kmp_stg_parse_target_offload
+
+static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer,
+ char const *name, void *data) {
+ const char *value = NULL;
+ if (__kmp_target_offload == tgt_default)
+ value = "DEFAULT";
+ else if (__kmp_target_offload == tgt_mandatory)
+ value = "MANDATORY";
+ else if (__kmp_target_offload == tgt_disabled)
+ value = "DISABLED";
+ if (value) {
+ __kmp_str_buf_print(buffer, " %s=%s\n", name, value);
+ }
+} // __kmp_stg_print_target_offload
+#endif
+
#if OMP_45_ENABLED
// -----------------------------------------------------------------------------
// OpenMP 4.5: OMP_MAX_TASK_PRIORITY
@@ -4443,6 +4483,10 @@ static kmp_setting_t __kmp_stg_table[] =
{"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device,
__kmp_stg_print_default_device, NULL, 0, 0},
#endif
+#if OMP_50_ENABLED
+ {"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload,
+ __kmp_stg_print_target_offload, NULL, 0, 0},
+#endif
#if OMP_45_ENABLED
{"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority,
__kmp_stg_print_max_task_priority, NULL, 0, 0},
More information about the Openmp-commits
mailing list