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
%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
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 {
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
! ***
!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
!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
!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
!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
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
! ***
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
! ***
!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
!$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 )
#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
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)
*/
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 */
/*!
*/
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;
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
#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
#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 */
/* ------------------------------------------------------------------------ */
#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 */
/* ------------------------------------------------------------------------ */
#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 */
/* ------------------------------------------------------------------------ */
#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 */
/* ------------------------------------------------------------------ */
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().
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
__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
{ "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
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);
}
# substitutions
config.substitutions.append(("%libomp-compile-and-run", \
- "%clang %cflags %s -o %t -lm && %t"))
+ "%libomp-compile && %libomp-run"))
+config.substitutions.append(("%libomp-compile", \
+ "%clang %cflags %s -o %t -lm"))
+config.substitutions.append(("%libomp-run", "%t"))
config.substitutions.append(("%clang", config.test_compiler))
config.substitutions.append(("%openmp_flag", config.test_openmp_flag))
config.substitutions.append(("%cflags", config.test_cflags))