diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2016-02-25 18:04:09 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2016-02-25 18:04:09 +0000 |
commit | 2851072d69af205fd8d2ef438db7e4848afb1592 (patch) | |
tree | dcb52f43380903216be6c2b4002aa4a0c95b893d /openmp/runtime/src | |
parent | 2a834115bf5caf0b3a2176dcec5ac4ca295e5332 (diff) | |
download | bcm5719-llvm-2851072d69af205fd8d2ef438db7e4848afb1592.tar.gz bcm5719-llvm-2851072d69af205fd8d2ef438db7e4848afb1592.zip |
Add initial support for OpenMP 4.5 task priority feature
The maximum task priority value is read from envirable: OMP_MAX_TASK_PRIORITY.
But as of now, nothing is done with it. We just handle the environment variable
and add the new api: omp_get_max_task_priority() which returns that value or
zero if it is not set.
Differential Revision: http://reviews.llvm.org/D17411
llvm-svn: 261908
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r-- | openmp/runtime/src/dllexports | 1 | ||||
-rw-r--r-- | openmp/runtime/src/include/41/omp.h.var | 1 | ||||
-rw-r--r-- | openmp/runtime/src/include/41/omp_lib.f.var | 9 | ||||
-rw-r--r-- | openmp/runtime/src/include/41/omp_lib.f90.var | 5 | ||||
-rw-r--r-- | openmp/runtime/src/include/41/omp_lib.h.var | 7 | ||||
-rw-r--r-- | openmp/runtime/src/kmp.h | 28 | ||||
-rw-r--r-- | openmp/runtime/src/kmp_ftn_entry.h | 16 | ||||
-rw-r--r-- | openmp/runtime/src/kmp_ftn_os.h | 16 | ||||
-rw-r--r-- | openmp/runtime/src/kmp_global.c | 3 | ||||
-rw-r--r-- | openmp/runtime/src/kmp_settings.c | 20 | ||||
-rw-r--r-- | openmp/runtime/src/kmp_tasking.c | 4 |
11 files changed, 103 insertions, 7 deletions
diff --git a/openmp/runtime/src/dllexports b/openmp/runtime/src/dllexports index ca7d7363b79..f14da7079e1 100644 --- a/openmp/runtime/src/dllexports +++ b/openmp/runtime/src/dllexports @@ -497,6 +497,7 @@ kmp_set_warnings_off 780 %ifdef OMP_41 omp_init_lock_with_hint 870 omp_init_nest_lock_with_hint 871 + omp_get_max_task_priority 872 %endif # OMP_41 %ifndef stub diff --git a/openmp/runtime/src/include/41/omp.h.var b/openmp/runtime/src/include/41/omp.h.var index 6d9fa43810f..4597d0eaa81 100644 --- a/openmp/runtime/src/include/41/omp.h.var +++ b/openmp/runtime/src/include/41/omp.h.var @@ -62,6 +62,7 @@ extern int __KAI_KMPC_CONVENTION omp_get_thread_limit (void); extern int __KAI_KMPC_CONVENTION omp_get_max_active_levels (void); extern void __KAI_KMPC_CONVENTION omp_get_schedule (omp_sched_t *, int *); + extern int __KAI_KMPC_CONVENTION omp_get_max_task_priority (void); /* lock API functions */ typedef struct omp_lock_t { diff --git a/openmp/runtime/src/include/41/omp_lib.f.var b/openmp/runtime/src/include/41/omp_lib.f.var index c801908cd41..d3406e00601 100644 --- a/openmp/runtime/src/include/41/omp_lib.f.var +++ b/openmp/runtime/src/include/41/omp_lib.f.var @@ -305,6 +305,11 @@ integer (kind=omp_nest_lock_kind) lockvar end function omp_test_nest_lock + function omp_get_max_task_priority() + use omp_lib_kinds + integer (kind=omp_integer_kind) omp_get_max_task_priority + end function omp_get_max_task_priority + ! *** ! *** kmp_* entry points ! *** @@ -503,6 +508,7 @@ !dec$ attributes alias:'OMP_GET_TEAM_NUM' :: omp_get_team_num !dec$ attributes alias:'OMP_GET_CANCELLATION' :: omp_get_cancellation !dec$ attributes alias:'OMP_IS_INITIAL_DEVICE' :: omp_is_initial_device +!dec$ attributes alias:'OMP_GET_MAX_TASK_PRIORITY' :: omp_get_max_task_priority !dec$ attributes alias:'omp_init_lock' :: omp_init_lock !dec$ attributes alias:'omp_init_lock_with_hint' :: omp_init_lock_with_hint @@ -581,6 +587,7 @@ !dec$ attributes alias:'_OMP_GET_TEAM_NUM' :: omp_get_team_num !dec$ attributes alias:'_OMP_GET_CANCELLATION' :: omp_get_cancellation !dec$ attributes alias:'_OMP_IS_INITIAL_DEVICE' :: omp_is_initial_device +!dec$ attributes alias:'_OMP_GET_MAX_TASK_PRIORTY' :: omp_get_max_task_priority !dec$ attributes alias:'_omp_init_lock' :: omp_init_lock !dec$ attributes alias:'_omp_init_lock_with_hint' :: omp_init_lock_with_hint @@ -662,6 +669,7 @@ !dec$ attributes alias:'omp_get_team_num_'::omp_get_team_num !dec$ attributes alias:'omp_get_cancellation_'::omp_get_cancellation !dec$ attributes alias:'omp_is_initial_device_'::omp_is_initial_device +!dec$ attributes alias:'omp_get_max_task_priority_'::omp_get_max_task_priority !dec$ attributes alias:'omp_init_lock_'::omp_init_lock !dec$ attributes alias:'omp_init_lock_with_hint_'::omp_init_lock_with_hint @@ -739,6 +747,7 @@ !dec$ attributes alias:'_omp_get_team_num_'::omp_get_team_num !dec$ attributes alias:'_omp_get_cancellation_'::omp_get_cancellation !dec$ attributes alias:'_omp_is_initial_device_'::omp_is_initial_device +!dec$ attributes alias:'_omp_get_max_task_priorty_'::omp_get_max_task_priority !dec$ attributes alias:'_omp_init_lock_'::omp_init_lock !dec$ attributes alias:'_omp_init_lock_with_hint_'::omp_init_lock_with_hint diff --git a/openmp/runtime/src/include/41/omp_lib.f90.var b/openmp/runtime/src/include/41/omp_lib.f90.var index 2d23667b108..18770e4c979 100644 --- a/openmp/runtime/src/include/41/omp_lib.f90.var +++ b/openmp/runtime/src/include/41/omp_lib.f90.var @@ -310,6 +310,11 @@ integer (kind=omp_nest_lock_kind) lockvar end function omp_test_nest_lock + function omp_get_max_task_priority() bind(c) + use omp_lib_kinds + integer (kind=omp_integer_kind) omp_get_max_task_priority + end function omp_get_max_task_priority + ! *** ! *** kmp_* entry points ! *** diff --git a/openmp/runtime/src/include/41/omp_lib.h.var b/openmp/runtime/src/include/41/omp_lib.h.var index 867bcd97b09..fbdd8484f26 100644 --- a/openmp/runtime/src/include/41/omp_lib.h.var +++ b/openmp/runtime/src/include/41/omp_lib.h.var @@ -292,6 +292,11 @@ integer (kind=omp_nest_lock_kind) lockvar end function omp_test_nest_lock + function omp_get_max_task_priority() bind(c) + import + integer (kind=omp_integer_kind) omp_get_max_task_priority + end function omp_get_max_task_priority + ! *** ! *** kmp_* entry points ! *** @@ -482,6 +487,7 @@ !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_set_nest_lock !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_unset_nest_lock !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_test_nest_lock +!DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_max_task_priority !DIR$ ATTRIBUTES OFFLOAD:MIC :: kmp_set_stacksize !DIR$ ATTRIBUTES OFFLOAD:MIC :: kmp_set_stacksize_s !DIR$ ATTRIBUTES OFFLOAD:MIC :: kmp_set_blocktime @@ -551,6 +557,7 @@ !$omp declare target(omp_set_nest_lock ) !$omp declare target(omp_unset_nest_lock ) !$omp declare target(omp_test_nest_lock ) +!$omp declare target(omp_get_max_task_priority ) !$omp declare target(kmp_set_stacksize ) !$omp declare target(kmp_set_stacksize_s ) !$omp declare target(kmp_set_blocktime ) diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h index 3e1c63f3954..71bb323159f 100644 --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -1060,6 +1060,8 @@ extern int __kmp_place_num_threads_per_core; #define KMP_MAX_ACTIVE_LEVELS_LIMIT INT_MAX +#define KMP_MAX_TASK_PRIORITY_LIMIT INT_MAX + /* Minimum number of threads before switch to TLS gtid (experimentally determined) */ /* josh TODO: what about OS X* tuning? */ #if KMP_ARCH_X86 || KMP_ARCH_X86_64 @@ -1998,6 +2000,9 @@ typedef enum kmp_tasking_mode { extern kmp_tasking_mode_t __kmp_tasking_mode; /* determines how/when to execute tasks */ extern kmp_int32 __kmp_task_stealing_constraint; +#if OMP_41_ENABLED + extern kmp_int32 __kmp_max_task_priority; // Set via OMP_MAX_TASK_PRIORITY if specified, defaults to 0 otherwise +#endif /* NOTE: kmp_taskdata_t and kmp_task_t structures allocated in single block with taskdata first */ #define KMP_TASK_TO_TASKDATA(task) (((kmp_taskdata_t *) task) - 1) @@ -2016,6 +2021,18 @@ extern kmp_int32 __kmp_task_stealing_constraint; */ typedef kmp_int32 (* kmp_routine_entry_t)( kmp_int32, void * ); +#if OMP_40_ENABLED || OMP_41_ENABLED +typedef union kmp_cmplrdata { +#if OMP_41_ENABLED + kmp_int32 priority; /**< priority specified by user for the task */ +#endif // OMP_41_ENABLED +#if OMP_40_ENABLED + kmp_routine_entry_t destructors; /* pointer to function to invoke deconstructors of firstprivate C++ objects */ +#endif // OMP_40_ENABLED + /* future data */ +} kmp_cmplrdata_t; +#endif + /* sizeof_kmp_task_t passed as arg to kmpc_omp_task call */ /*! */ @@ -2023,9 +2040,11 @@ typedef struct kmp_task { /* GEH: Shouldn't this be aligned so void * shareds; /**< pointer to block of pointers to shared vars */ kmp_routine_entry_t routine; /**< pointer to routine to call for executing task */ kmp_int32 part_id; /**< part id for the task */ -#if OMP_40_ENABLED - kmp_routine_entry_t destructors; /* pointer to function to invoke deconstructors of firstprivate C++ objects */ -#endif // OMP_40_ENABLED +#if OMP_40_ENABLED || OMP_41_ENABLED + kmp_cmplrdata_t data1; /* Two known optional additions: destructors and priority */ + kmp_cmplrdata_t data2; /* Process destructors first, priority second */ + /* future data */ +#endif /* private vars */ } kmp_task_t; @@ -2124,7 +2143,8 @@ typedef struct kmp_tasking_flags { /* Total struct must be exactly 32 b unsigned destructors_thunk : 1; /* set if the compiler creates a thunk to invoke destructors from the runtime */ #if OMP_41_ENABLED unsigned proxy : 1; /* task is a proxy task (it will be executed outside the context of the RTL) */ - unsigned reserved : 11; /* reserved for compiler use */ + unsigned priority_specified :1; /* set if the compiler provides priority setting for the task */ + unsigned reserved : 10; /* reserved for compiler use */ #else unsigned reserved : 12; /* reserved for compiler use */ #endif diff --git a/openmp/runtime/src/kmp_ftn_entry.h b/openmp/runtime/src/kmp_ftn_entry.h index fcbaacbffa7..2711c5d12fa 100644 --- a/openmp/runtime/src/kmp_ftn_entry.h +++ b/openmp/runtime/src/kmp_ftn_entry.h @@ -1089,6 +1089,22 @@ FTN_GET_CANCELLATION_STATUS(int cancel_kind) { #endif // OMP_40_ENABLED +#if OMP_41_ENABLED +/* returns the maximum allowed task priority */ +int FTN_STDCALL +FTN_GET_MAX_TASK_PRIORITY( void ) +{ +#ifdef KMP_STUB + return 0; +#else + if ( ! __kmp_init_serial ) { + __kmp_serial_initialize(); + } + return __kmp_max_task_priority; +#endif +} +#endif + // GCC compatibility (versioned symbols) #ifdef KMP_USE_VERSION_SYMBOLS diff --git a/openmp/runtime/src/kmp_ftn_os.h b/openmp/runtime/src/kmp_ftn_os.h index 4b41260a9dd..d9157504cbc 100644 --- a/openmp/runtime/src/kmp_ftn_os.h +++ b/openmp/runtime/src/kmp_ftn_os.h @@ -113,6 +113,10 @@ #define FTN_GET_CANCELLATION_STATUS kmp_get_cancellation_status #endif +#if OMP_41_ENABLED + #define FTN_GET_MAX_TASK_PRIORITY omp_get_max_task_priority +#endif + #endif /* KMP_FTN_PLAIN */ /* ------------------------------------------------------------------------ */ @@ -210,6 +214,10 @@ #define FTN_GET_CANCELLATION_STATUS kmp_get_cancellation_status_ #endif +#if OMP_41_ENABLED + #define FTN_GET_MAX_TASK_PRIORITY omp_get_max_task_priority_ +#endif + #endif /* KMP_FTN_APPEND */ /* ------------------------------------------------------------------------ */ @@ -307,6 +315,10 @@ #define FTN_GET_CANCELLATION_STATUS KMP_GET_CANCELLATION_STATUS #endif +#if OMP_41_ENABLED + #define FTN_GET_MAX_TASK_PRIORITY OMP_GET_MAX_TASK_PRIORITY +#endif + #endif /* KMP_FTN_UPPER */ /* ------------------------------------------------------------------------ */ @@ -404,6 +416,10 @@ #define FTN_GET_CANCELLATION_STATUS KMP_GET_CANCELLATION_STATUS_ #endif +#if OMP_41_ENABLED + #define FTN_GET_MAX_TASK_PRIORITY OMP_GET_MAX_TASK_PRIORITY_ +#endif + #endif /* KMP_FTN_UAPPEND */ /* ------------------------------------------------------------------ */ diff --git a/openmp/runtime/src/kmp_global.c b/openmp/runtime/src/kmp_global.c index bdac75b0058..b905fc69a78 100644 --- a/openmp/runtime/src/kmp_global.c +++ b/openmp/runtime/src/kmp_global.c @@ -259,6 +259,9 @@ int __kmp_place_core_offset = 0; int __kmp_place_num_threads_per_core = 0; kmp_tasking_mode_t __kmp_tasking_mode = tskm_task_teams; +#if OMP_41_ENABLED +kmp_int32 __kmp_max_task_priority = 0; +#endif /* This check ensures that the compiler is passing the correct data type * for the flags formal parameter of the function kmpc_omp_task_alloc(). diff --git a/openmp/runtime/src/kmp_settings.c b/openmp/runtime/src/kmp_settings.c index 11e340cdc72..ac53c471cf2 100644 --- a/openmp/runtime/src/kmp_settings.c +++ b/openmp/runtime/src/kmp_settings.c @@ -1163,7 +1163,7 @@ __kmp_stg_print_task_stealing( kmp_str_buf_t * buffer, char const * name, void * static void __kmp_stg_parse_max_active_levels( char const * name, char const * value, void * data ) { - __kmp_stg_parse_int( name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, & __kmp_dflt_max_active_levels ); + __kmp_stg_parse_int( name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT, & __kmp_dflt_max_active_levels ); } // __kmp_stg_parse_max_active_levels static void @@ -1171,6 +1171,21 @@ __kmp_stg_print_max_active_levels( kmp_str_buf_t * buffer, char const * name, vo __kmp_stg_print_int( buffer, name, __kmp_dflt_max_active_levels ); } // __kmp_stg_print_max_active_levels +#if OMP_41_ENABLED +// ------------------------------------------------------------------------------------------------- +// OpenMP 4.5: OMP_MAX_TASK_PRIORITY +// ------------------------------------------------------------------------------------------------- +static void +__kmp_stg_parse_max_task_priority(char const *name, char const *value, void *data) { + __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT, &__kmp_max_task_priority); +} // __kmp_stg_parse_max_task_priority + +static void +__kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer, char const *name, void *data) { + __kmp_stg_print_int(buffer, name, __kmp_max_task_priority); +} // __kmp_stg_print_max_task_priority +#endif // OMP_41_ENABLED + #if KMP_NESTED_HOT_TEAMS // ------------------------------------------------------------------------------------------------- // KMP_HOT_TEAMS_MAX_LEVEL, KMP_HOT_TEAMS_MODE @@ -4519,6 +4534,9 @@ static kmp_setting_t __kmp_stg_table[] = { { "KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL, 0, 0 }, { "KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing, __kmp_stg_print_task_stealing, NULL, 0, 0 }, { "OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels, __kmp_stg_print_max_active_levels, NULL, 0, 0 }, +#if OMP_41_ENABLED + { "OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority, __kmp_stg_print_max_task_priority, NULL, 0, 0 }, +#endif { "OMP_THREAD_LIMIT", __kmp_stg_parse_all_threads, __kmp_stg_print_all_threads, NULL, 0, 0 }, { "OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, NULL, 0, 0 }, #if KMP_NESTED_HOT_TEAMS diff --git a/openmp/runtime/src/kmp_tasking.c b/openmp/runtime/src/kmp_tasking.c index 10933f36b80..3ed9a9da5cb 100644 --- a/openmp/runtime/src/kmp_tasking.c +++ b/openmp/runtime/src/kmp_tasking.c @@ -679,9 +679,9 @@ __kmp_task_finish( kmp_int32 gtid, kmp_task_t *task, kmp_taskdata_t *resumed_tas hence overlapping the destructor invokations with some other work in the released tasks. The OpenMP spec is not specific on when the destructors are invoked, so we should be free to choose. - */ + */ if (taskdata->td_flags.destructors_thunk) { - kmp_routine_entry_t destr_thunk = task->destructors; + kmp_routine_entry_t destr_thunk = task->data1.destructors; KMP_ASSERT(destr_thunk); destr_thunk(gtid, task); } |