Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 32781b6d authored by Thierry's avatar Thierry
Browse files

[fix] provide patch to add priority to task without support frm the compiler,...

[fix] provide patch to add priority to task without support frm the compiler, such as ICC 2017 ou 2018
parent c6b80fef
No related branches found
No related tags found
No related merge requests found
...@@ -113,6 +113,9 @@ ...@@ -113,6 +113,9 @@
extern double __KAI_KMPC_CONVENTION omp_get_wtime (void); extern double __KAI_KMPC_CONVENTION omp_get_wtime (void);
extern double __KAI_KMPC_CONVENTION omp_get_wtick (void); extern double __KAI_KMPC_CONVENTION omp_get_wtick (void);
/* OpenMP 3.0 extension */
extern void __KAI_KMPC_CONVENTION omp_set_task_priority (int priority);
# include <stdlib.h> # include <stdlib.h>
/* kmp API functions */ /* kmp API functions */
extern int __KAI_KMPC_CONVENTION kmp_get_stacksize (void); extern int __KAI_KMPC_CONVENTION kmp_get_stacksize (void);
......
...@@ -105,6 +105,9 @@ ...@@ -105,6 +105,9 @@
extern double __KAI_KMPC_CONVENTION omp_get_wtime (void); extern double __KAI_KMPC_CONVENTION omp_get_wtime (void);
extern double __KAI_KMPC_CONVENTION omp_get_wtick (void); extern double __KAI_KMPC_CONVENTION omp_get_wtick (void);
/* OpenMP 3.0 extension */
extern void __KAI_KMPC_CONVENTION omp_set_task_priority (int priority);
/* OpenMP 4.0 extension */ /* OpenMP 4.0 extension */
#if OMP_EXTENSION_AFFINITY #if OMP_EXTENSION_AFFINITY
typedef enum omp_affinity_kind_t { typedef enum omp_affinity_kind_t {
......
...@@ -123,6 +123,9 @@ ...@@ -123,6 +123,9 @@
extern double __KAI_KMPC_CONVENTION omp_get_wtick (void); extern double __KAI_KMPC_CONVENTION omp_get_wtick (void);
/* OpenMP 3.0 extension */
extern void __KAI_KMPC_CONVENTION omp_set_task_priority (int priority);
/* OpenMP 4.0 extension */ /* OpenMP 4.0 extension */
#if OMP_EXTENSION_AFFINITY #if OMP_EXTENSION_AFFINITY
typedef enum omp_affinity_kind_t { typedef enum omp_affinity_kind_t {
......
...@@ -123,6 +123,9 @@ ...@@ -123,6 +123,9 @@
extern double __KAI_KMPC_CONVENTION omp_get_wtime (void); extern double __KAI_KMPC_CONVENTION omp_get_wtime (void);
extern double __KAI_KMPC_CONVENTION omp_get_wtick (void); extern double __KAI_KMPC_CONVENTION omp_get_wtick (void);
/* OpenMP 3.0 extension */
extern void __KAI_KMPC_CONVENTION omp_set_task_priority (int priority);
/* OpenMP 4.0 extension */ /* OpenMP 4.0 extension */
#if OMP_EXTENSION_AFFINITY #if OMP_EXTENSION_AFFINITY
typedef enum omp_affinity_kind_t { typedef enum omp_affinity_kind_t {
......
...@@ -2063,6 +2063,11 @@ typedef struct kmp_local { ...@@ -2063,6 +2063,11 @@ typedef struct kmp_local {
#define set__sched(xthread, xval) \ #define set__sched(xthread, xval) \
(((xthread)->th.th_current_task->td_icvs.sched) = (xval)) (((xthread)->th.th_current_task->td_icvs.sched) = (xval))
#define set__priority( xthread, xval ) \
( ( (xthread)->th.th_task_priority ) = (xval) )
#define get__priority( xthread ) \
( (xthread)->th.th_task_priority )
#if OMP_40_ENABLED #if OMP_40_ENABLED
#define set__proc_bind(xthread, xval) \ #define set__proc_bind(xthread, xval) \
...@@ -2667,6 +2672,7 @@ typedef struct KMP_ALIGN_CACHE kmp_base_info { ...@@ -2667,6 +2672,7 @@ typedef struct KMP_ALIGN_CACHE kmp_base_info {
kmp_extra_depinfo_th_t th_edeps[2]; // [alias/noalias] kmp_extra_depinfo_th_t th_edeps[2]; // [alias/noalias]
kmp_extra_depinfo_th_t* th_edeps_tail[2]; // TG: tail pointers kmp_extra_depinfo_th_t* th_edeps_tail[2]; // TG: tail pointers
#endif #endif
kmp_int32 th_task_priority; //
#if OMPT_SUPPORT #if OMPT_SUPPORT
const char* th_task_name; // const char* th_task_name; //
intptr_t th_task_key[2]; // intptr_t th_task_key[2]; //
...@@ -3887,6 +3893,7 @@ void __kmpc_omp_task_complete(ident_t *loc_ref, kmp_int32 gtid, ...@@ -3887,6 +3893,7 @@ void __kmpc_omp_task_complete(ident_t *loc_ref, kmp_int32 gtid,
KMP_EXPORT void __kmpc_omp_set_task_affinity(kmp_uint32 kind, kmp_uint64 affinity, kmp_uint32 strict); KMP_EXPORT void __kmpc_omp_set_task_affinity(kmp_uint32 kind, kmp_uint64 affinity, kmp_uint32 strict);
KMP_EXPORT void __kmpc_omp_set_task_name(char *name); KMP_EXPORT void __kmpc_omp_set_task_name(char *name);
KMP_EXPORT void __kmpc_omp_set_task_priority(int priority);
KMP_EXPORT void __kmpc_omp_set_task_attr(char key, long int value); KMP_EXPORT void __kmpc_omp_set_task_attr(char key, long int value);
KMP_EXPORT void* __kmpc_omp_begin_sched_graph(int flag); KMP_EXPORT void* __kmpc_omp_begin_sched_graph(int flag);
KMP_EXPORT void __kmpc_omp_end_sched_graph(void* handle, int flag ); KMP_EXPORT void __kmpc_omp_end_sched_graph(void* handle, int flag );
......
...@@ -636,6 +636,16 @@ FTN_SET_TASK_NAME(char *name) ...@@ -636,6 +636,16 @@ FTN_SET_TASK_NAME(char *name)
#endif #endif
} }
void FTN_STDCALL
FTN_SET_TASK_PRIORITY(int priority)
{
#ifdef KMP_STUB
// nothing
#else
__kmpc_omp_set_task_priority(priority);
#endif
}
void FTN_STDCALL void FTN_STDCALL
FTN_SET_TASK_ATTR(char key, long int value) FTN_SET_TASK_ATTR(char key, long int value)
{ {
......
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
#define FTN_INFO_ALLOC_SIZE omp_info_alloc_memory #define FTN_INFO_ALLOC_SIZE omp_info_alloc_memory
#define FTN_INFO_FREE_SIZE omp_info_free_memory #define FTN_INFO_FREE_SIZE omp_info_free_memory
#define FTN_SET_MEMORY_LIMIT omp_set_memory_limit #define FTN_SET_MEMORY_LIMIT omp_set_memory_limit
#define FTN_SET_TASK_PRIORITY omp_set_task_priority
#if OMP_40_ENABLED #if OMP_40_ENABLED
#if LIBOMP_USE_VARDEP #if LIBOMP_USE_VARDEP
#define FN_TASK_DECLDEPS omp_task_declare_dependencies #define FN_TASK_DECLDEPS omp_task_declare_dependencies
...@@ -220,6 +221,7 @@ ...@@ -220,6 +221,7 @@
#define FTN_INFO_ALLOC_SIZE omp_info_alloc_memory_ #define FTN_INFO_ALLOC_SIZE omp_info_alloc_memory_
#define FTN_INFO_FREE_SIZE omp_info_free_memory_ #define FTN_INFO_FREE_SIZE omp_info_free_memory_
#define FTN_SET_MEMORY_LIMIT omp_set_memory_limit_ #define FTN_SET_MEMORY_LIMIT omp_set_memory_limit_
#define FTN_SET_TASK_PRIORITY omp_set_task_priority_
#if OMP_40_ENABLED #if OMP_40_ENABLED
#if LIBOMP_USE_VARDEP #if LIBOMP_USE_VARDEP
#define FN_TASK_DECLDEPS omp_task_declare_dependencies_ #define FN_TASK_DECLDEPS omp_task_declare_dependencies_
...@@ -356,6 +358,7 @@ ...@@ -356,6 +358,7 @@
#define FTN_INFO_ALLOC_SIZE OMP_INFO_ALLOC_MEMORY #define FTN_INFO_ALLOC_SIZE OMP_INFO_ALLOC_MEMORY
#define FTN_INFO_FREE_SIZE OMP_INFO_FREE_MEMORY #define FTN_INFO_FREE_SIZE OMP_INFO_FREE_MEMORY
#define FTN_SET_MEMORY_LIMIT OMP_SET_MEMORY_LIMIT #define FTN_SET_MEMORY_LIMIT OMP_SET_MEMORY_LIMIT
#define FTN_SET_TASK_PRIORITY OMP_SET_TASK_PRIORITY
#if OMP_40_ENABLED #if OMP_40_ENABLED
#if LIBOMP_USE_VARDEP #if LIBOMP_USE_VARDEP
#define FN_TASK_DECLDEPS OMP_TASK_DECLARE_DEPENDENCIES #define FN_TASK_DECLDEPS OMP_TASK_DECLARE_DEPENDENCIES
...@@ -492,6 +495,7 @@ ...@@ -492,6 +495,7 @@
#define FTN_INFO_ALLOC_SIZE OMP_INFO_ALLOC_MEMORY_ #define FTN_INFO_ALLOC_SIZE OMP_INFO_ALLOC_MEMORY_
#define FTN_INFO_FREE_SIZE OMP_INFO_FREE_MEMORY_ #define FTN_INFO_FREE_SIZE OMP_INFO_FREE_MEMORY_
#define FTN_SET_MEMORY_LIMIT OMP_SET_MEMORY_LIMIT_ #define FTN_SET_MEMORY_LIMIT OMP_SET_MEMORY_LIMIT_
#define FTN_SET_TASK_PRIORITY OMP_SET_TASK_PRIORITY_
#if OMP_40_ENABLED #if OMP_40_ENABLED
#if LIBOMP_USE_VARDEP #if LIBOMP_USE_VARDEP
#define FN_TASK_DECLDEPS OMP_TASK_DECLARE_DEPENDENCIES_ #define FN_TASK_DECLDEPS OMP_TASK_DECLARE_DEPENDENCIES_
......
...@@ -354,14 +354,18 @@ __kmp_push_task(kmp_int32 gtid, kmp_task_t * task ) ...@@ -354,14 +354,18 @@ __kmp_push_task(kmp_int32 gtid, kmp_task_t * task )
#endif #endif
#if OMP_45_ENABLED #if OMP_45_ENABLED
kmp_int32 priority;
if (taskdata->td_flags.priority_specified) if (taskdata->td_flags.priority_specified)
{ {
kmp_int32 priority = task->data2.priority; //printf("Priority\n");
if (priority < 0) priority = 0; priority = task->data2.priority;
else if (priority > __kmp_max_task_priority)
priority = __kmp_max_task_priority;
taskdata->priority = priority;
} }
else priority = taskdata->priority;
if (priority < 0) priority = 0;
else if (priority > __kmp_max_task_priority)
priority = __kmp_max_task_priority;
taskdata->priority = priority;
#endif #endif
#if LIBOMP_USE_AFFINITY #if LIBOMP_USE_AFFINITY
...@@ -1502,6 +1506,10 @@ kmp_task_t* __kmp_task_alloc( ident_t *loc_ref, kmp_int32 gtid, kmp_tasking_flag ...@@ -1502,6 +1506,10 @@ kmp_task_t* __kmp_task_alloc( ident_t *loc_ref, kmp_int32 gtid, kmp_tasking_flag
#endif #endif
copy_icvs(&taskdata->td_icvs, &taskdata->td_parent->td_icvs); copy_icvs(&taskdata->td_icvs, &taskdata->td_parent->td_icvs);
// for ICC 2017,2018 -> pass through OMP extension
taskdata->priority = thread->th.th_task_priority;
thread->th.th_task_priority = 0;
#if OMPT_SUPPORT #if OMPT_SUPPORT
/* reset task name after creation */ /* reset task name after creation */
taskdata->td_icvs.name = thread->th.th_task_name; taskdata->td_icvs.name = thread->th.th_task_name;
...@@ -2260,6 +2268,17 @@ __kmpc_end_push_init() ...@@ -2260,6 +2268,17 @@ __kmpc_end_push_init()
{ {
} }
//-------------------------------------------------------------------------------------
// __kmpc_omp_set_task_priority: set the priority for the next task to create
void
__kmpc_omp_set_task_priority(int priority)
{
kmp_info_t * thread = __kmp_threads[ __kmp_entry_gtid() ];
set__priority(thread, priority);
}
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// __kmpc_omp_set_task_name: set the name for the next task to create // __kmpc_omp_set_task_name: set the name for the next task to create
...@@ -2875,8 +2894,26 @@ __kmp_steal_task( kmp_info_t *victim, kmp_int32 cpu, kmp_int32 node, ...@@ -2875,8 +2894,26 @@ __kmp_steal_task( kmp_info_t *victim, kmp_int32 cpu, kmp_int32 node,
// GEH: why would this happen? // GEH: why would this happen?
return 0; return 0;
} }
#if OMP_45_ENABLED
/* look at task priority set before my local queue */
for (kmp_int32 i = __kmp_max_task_priority-1; i>=0; --i)
{
if (task_team->tt.tt_task_queues_priority &&
!kaapi_wsqueue_empty( &(task_team->tt.tt_task_queues_priority[i]->qd.td_wsdeque)))
{
taskdata = kaapi_wsqueue_locked_pop_task( &(task_team->tt.tt_task_queues_priority[i]->qd.td_wsdeque) );
if (taskdata !=0)
{
task = KMP_TASKDATA_TO_TASK( taskdata );
return task;
}
}
}
#endif #endif
#endif // LIBOMP_USE_THEQUEUE||LIBOMP_USE_LINKED_DEQUEUE
threads_data = task_team->tt.tt_threads_data; threads_data = task_team->tt.tt_threads_data;
KMP_DEBUG_ASSERT(threads_data != NULL); // Caller should check this condition KMP_DEBUG_ASSERT(threads_data != NULL); // Caller should check this condition
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment