Skip to content

Commit 3d5f172

Browse files
committed
fix task_schedule callbacks with yield and adapt testcase
1 parent d7f15c6 commit 3d5f172

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

runtime/src/kmp_tasking.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,17 +1676,9 @@ __kmpc_omp_taskyield( ident_t *loc_ref, kmp_int32 gtid, int end_part )
16761676
kmp_task_team_t * task_team = thread->th.th_task_team;
16771677
if (task_team != NULL) {
16781678
if (KMP_TASKING_ENABLED(task_team)) {
1679+
//TODO: store in thread that the task yields
16791680
__kmp_execute_tasks_32( thread, gtid, NULL, FALSE, &thread_finished
16801681
USE_ITT_BUILD_ARG(itt_sync_obj), __kmp_task_stealing_constraint );
1681-
#if OMPT_SUPPORT
1682-
if (ompt_enabled &&
1683-
ompt_callbacks.ompt_callback(ompt_callback_task_schedule)) {
1684-
ompt_callbacks.ompt_callback(ompt_callback_task_schedule)(
1685-
&(taskdata->ompt_task_info.task_data),
1686-
ompt_task_yield,
1687-
&(taskdata->ompt_task_info.task_data)); //TODO: How can we access the task_data of the scheduled task? (for now the same task_data is used)
1688-
}
1689-
#endif
16901682
}
16911683
}
16921684
}

runtime/test/ompt/tasks/taskyield.c

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,27 @@
66

77
int main()
88
{
9+
int condition=0, x=0;
910
#pragma omp parallel num_threads(2)
1011
{
1112
#pragma omp master
1213
{
13-
#pragma omp task
14+
#pragma omp task shared(condition)
1415
{
15-
sleep(1);
16+
#pragma omp task shared(condition)
17+
{
18+
OMPT_SIGNAL(condition);
19+
OMPT_WAIT(condition,2);
20+
}
21+
OMPT_WAIT(condition,1);
22+
#pragma omp task shared(x)
23+
{
24+
x++;
25+
}
26+
printf("%" PRIu64 ": before yield\n", ompt_get_thread_data()->value);
1627
#pragma omp taskyield
17-
sleep(1);
18-
}
19-
#pragma omp task
20-
{
21-
sleep(1);
28+
printf("%" PRIu64 ": after yield\n", ompt_get_thread_data()->value);
29+
OMPT_SIGNAL(condition);
2230
}
2331
}
2432
}
@@ -27,22 +35,23 @@ int main()
2735
// Check if libomp supports the callbacks for this test.
2836
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'
2937
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_schedule'
38+
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
39+
3040

31-
3241
// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
33-
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_task_create: parent_task_id={{[0-9]+}}, parent_task_frame.exit=[[NULL]], parent_task_frame.reenter=[[NULL]], new_task_id=[[PARENT_TASK:[0-9]+]], parallel_function=0x{{[0-f]+}}, task_type=ompt_task_initial=1, has_dependences=no
34-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id={{[0-9]+}}, parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[TASK_ONE:[0-9]+]], parallel_function={{0x[0-f]+}}, task_type=ompt_task_explicit=3, has_dependences=no
35-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id={{[0-9]+}}, parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[TASK_TWO:[0-9]+]], parallel_function={{0x[0-f]+}}, task_type=ompt_task_explicit=3, has_dependences=no
42+
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_implicit_task_begin: parallel_id={{[0-9]+}}, task_id=[[IMPLICIT_TASK_ID:[0-9]+]], team_size={{[0-9]+}}, thread_num={{[0-9]+}}
3643

44+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id={{[0-9]+}}, parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[OUTER_TASK:[0-9]+]], parallel_function={{0x[0-f]+}}, task_type=ompt_task_explicit=3, has_dependences=no
45+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[IMPLICIT_TASK_ID]], second_task_id=[[OUTER_TASK]], prior_task_status=ompt_task_others=4
46+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id={{[0-9]+}}, parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[WORKER_TASK:[0-9]+]], parallel_function={{0x[0-f]+}}, task_type=ompt_task_explicit=3, has_dependences=no
47+
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id={{[0-9]+}}, parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[INNER_TASK:[0-9]+]], parallel_function={{0x[0-f]+}}, task_type=ompt_task_explicit=3, has_dependences=no
3748

38-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id={{[0-9]+}}, second_task_id=[[TASK_TWO]], prior_task_status=ompt_task_others=4
39-
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[TASK_TWO]], second_task_id={{[0-9]+}}, prior_task_status=ompt_task_complete=1
49+
// CHECK: {{^}}[[THREAD_ID]]: ompt_event_task_schedule: first_task_id=[[OUTER_TASK]], second_task_id=[[INNER_TASK]], prior_task_status=ompt_task_yield=2
50+
// CHECK: {{^}}[[THREAD_ID]]: ompt_event_task_schedule: first_task_id=[[INNER_TASK]], second_task_id=[[OUTER_TASK]], prior_task_status=ompt_task_complete=1
4051

4152

42-
// CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_task_schedule: first_task_id={{[0-9]+}}, second_task_id=[[TASK_ONE]], prior_task_status=ompt_task_others=4
43-
// CHECK: {{^}}[[THREAD_ID]]: ompt_event_task_schedule: first_task_id=[[TASK_ONE]], second_task_id=[[TASK_ONE]], prior_task_status=ompt_task_yield=2
44-
// missing schedule callbacks?
45-
// CHECK: {{^}}[[THREAD_ID]]: ompt_event_task_schedule: first_task_id=[[TASK_ONE]], second_task_id={{[0-9]+}}, prior_task_status=ompt_task_complete=1
53+
// CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_task_schedule: first_task_id={{[0-9]+}}, second_task_id=[[WORKER_TASK]], prior_task_status=ompt_task_others=4
54+
// CHECK: {{^}}[[THREAD_ID]]: ompt_event_task_schedule: first_task_id=[[WORKER_TASK]], second_task_id={{[0-9]+}}, prior_task_status=ompt_task_complete=1
4655

4756

4857

0 commit comments

Comments
 (0)