Skip to content

Commit 1c3518c

Browse files
committed
Implicit tasks of worker threads might be reused before implicit-task-end event
1 parent 5869f6c commit 1c3518c

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

runtime/src/kmp_barrier.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,8 +1737,9 @@ __kmp_fork_barrier(int gtid, int tid)
17371737
{
17381738
if (this_thr->th.ompt_thread_info.state == ompt_state_wait_barrier_implicit) {
17391739
int ds_tid = this_thr->th.th_info.ds.ds_tid;
1740-
ompt_task_data_t* tId = &(this_thr->th.th_current_task->ompt_task_info.task_data);
1740+
ompt_task_data_t* tId = (team)? &(this_thr->th.th_current_task->ompt_task_info.task_data) : &(this_thr->th.ompt_thread_info.task_data);
17411741
ompt_parallel_data_t* pId = (team)? &(team->t.ompt_team_info.parallel_data) : &(this_thr->th.ompt_thread_info.parallel_data);
1742+
// ompt_parallel_data_t* pId = (team)? &(team->t.ompt_team_info.parallel_data) : NULL;
17421743
this_thr->th.ompt_thread_info.state = ompt_state_overhead;
17431744
#if OMPT_OPTIONAL
17441745
void * codeptr = NULL;

runtime/src/kmp_runtime.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5615,6 +5615,7 @@ __kmp_launch_thread( kmp_info_t *this_thr )
56155615

56165616
this_thr->th.ompt_thread_info.state = ompt_state_overhead;
56175617
this_thr->th.ompt_thread_info.parallel_data = (*pteam)->t.ompt_team_info.parallel_data;
5618+
this_thr->th.ompt_thread_info.task_data = *OMPT_CUR_TASK_DATA(this_thr);
56185619
}
56195620
#endif
56205621
/* join barrier after parallel region */

runtime/src/kmp_wait_release.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ THIS function is called from
234234
}
235235
} else {
236236
pId = &(this_thr->th.ompt_thread_info.parallel_data);
237-
tId = &(this_thr->th.th_current_task->ompt_task_info.task_data);
237+
// pId = NULL;
238+
tId = &(this_thr->th.ompt_thread_info.task_data);
238239
}
239240
#if OMPT_OPTIONAL
240241
if (ompt_entry_state == ompt_state_idle) {

runtime/src/ompt-internal.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ typedef struct ompt_lw_taskteam_s {
6161

6262

6363
typedef struct {
64-
ompt_thread_data_t thread_data;
64+
ompt_thread_data_t thread_data;
6565
ompt_parallel_data_t parallel_data; /* stored here from implicit barrier-begin until implicit-task-end */
66-
ompt_state_t state;
67-
ompt_wait_id_t wait_id;
68-
void *idle_frame;
66+
ompt_task_data_t task_data; /* stored here from implicit barrier-begin until implicit-task-end */
67+
ompt_state_t state;
68+
ompt_wait_id_t wait_id;
69+
void *idle_frame;
6970
} ompt_thread_info_t;
7071

7172

runtime/test/ompt/cancel/cancel_taskgroup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s
1+
// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | tee log.txt | FileCheck %s
22
// REQUIRES: ompt
33

44
#include "callback.h"
@@ -20,6 +20,7 @@ int main()
2020
printf("start execute task 1\n");
2121
OMPT_SIGNAL(condition);
2222
OMPT_WAIT(condition,2);
23+
usleep(300); // master needs time to discard tasks
2324
#pragma omp cancellation point taskgroup
2425
printf("end execute task 1\n");
2526
}

0 commit comments

Comments
 (0)