Skip to content

Commit

Permalink
[OpenMP] Add OMPT support for omp_all_memory task dependence
Browse files Browse the repository at this point in the history
omp_all_memory currently has no representation in OMPT.

Adding new dependency flags as suggested by omp-lang issue #3007.

Differential Revision: https://reviews.llvm.org/D111788
  • Loading branch information
jprotze committed Jul 7, 2023
1 parent 39f2fce commit 6ef16f2
Show file tree
Hide file tree
Showing 5 changed files with 754 additions and 11 deletions.
16 changes: 9 additions & 7 deletions openmp/runtime/src/include/omp-tools.h.var
Expand Up @@ -413,13 +413,15 @@ typedef enum ompt_target_map_flag_t {
} ompt_target_map_flag_t;

typedef enum ompt_dependence_type_t {
ompt_dependence_type_in = 1,
ompt_dependence_type_out = 2,
ompt_dependence_type_inout = 3,
ompt_dependence_type_mutexinoutset = 4,
ompt_dependence_type_source = 5,
ompt_dependence_type_sink = 6,
ompt_dependence_type_inoutset = 7
ompt_dependence_type_in = 1,
ompt_dependence_type_out = 2,
ompt_dependence_type_inout = 3,
ompt_dependence_type_mutexinoutset = 4,
ompt_dependence_type_source = 5,
ompt_dependence_type_sink = 6,
ompt_dependence_type_inoutset = 7,
ompt_dependence_type_out_all_memory = 34,
ompt_dependence_type_inout_all_memory = 35
} ompt_dependence_type_t;

typedef enum ompt_severity_t {
Expand Down
14 changes: 12 additions & 2 deletions openmp/runtime/src/kmp_taskdeps.cpp
Expand Up @@ -745,7 +745,9 @@ kmp_int32 __kmpc_omp_task_with_deps(ident_t *loc_ref, kmp_int32 gtid,

for (i = 0; i < ndeps; i++) {
ompt_deps[i].variable.ptr = (void *)dep_list[i].base_addr;
if (dep_list[i].flags.in && dep_list[i].flags.out)
if (dep_list[i].base_addr == KMP_SIZE_T_MAX)
ompt_deps[i].dependence_type = ompt_dependence_type_out_all_memory;
else if (dep_list[i].flags.in && dep_list[i].flags.out)
ompt_deps[i].dependence_type = ompt_dependence_type_inout;
else if (dep_list[i].flags.out)
ompt_deps[i].dependence_type = ompt_dependence_type_out;
Expand All @@ -755,10 +757,15 @@ kmp_int32 __kmpc_omp_task_with_deps(ident_t *loc_ref, kmp_int32 gtid,
ompt_deps[i].dependence_type = ompt_dependence_type_mutexinoutset;
else if (dep_list[i].flags.set)
ompt_deps[i].dependence_type = ompt_dependence_type_inoutset;
else if (dep_list[i].flags.all)
ompt_deps[i].dependence_type = ompt_dependence_type_out_all_memory;
}
for (i = 0; i < ndeps_noalias; i++) {
ompt_deps[ndeps + i].variable.ptr = (void *)noalias_dep_list[i].base_addr;
if (noalias_dep_list[i].flags.in && noalias_dep_list[i].flags.out)
if (noalias_dep_list[i].base_addr == KMP_SIZE_T_MAX)
ompt_deps[ndeps + i].dependence_type =
ompt_dependence_type_out_all_memory;
else if (noalias_dep_list[i].flags.in && noalias_dep_list[i].flags.out)
ompt_deps[ndeps + i].dependence_type = ompt_dependence_type_inout;
else if (noalias_dep_list[i].flags.out)
ompt_deps[ndeps + i].dependence_type = ompt_dependence_type_out;
Expand All @@ -769,6 +776,9 @@ kmp_int32 __kmpc_omp_task_with_deps(ident_t *loc_ref, kmp_int32 gtid,
ompt_dependence_type_mutexinoutset;
else if (noalias_dep_list[i].flags.set)
ompt_deps[ndeps + i].dependence_type = ompt_dependence_type_inoutset;
else if (noalias_dep_list[i].flags.all)
ompt_deps[ndeps + i].dependence_type =
ompt_dependence_type_out_all_memory;
}
ompt_callbacks.ompt_callback(ompt_callback_dependences)(
&(new_taskdata->ompt_task_info.task_data), ompt_deps, ompt_ndeps);
Expand Down
9 changes: 7 additions & 2 deletions openmp/runtime/test/ompt/callback.h
Expand Up @@ -47,15 +47,20 @@ static const char* ompt_cancel_flag_t_values[] = {
"ompt_cancel_discarded_task"
};

static const char *ompt_dependence_type_t_values[] = {
static const char *ompt_dependence_type_t_values[36] = {
"ompt_dependence_type_UNDEFINED",
"ompt_dependence_type_in", // 1
"ompt_dependence_type_out", // 2
"ompt_dependence_type_inout", // 3
"ompt_dependence_type_mutexinoutset", // 4
"ompt_dependence_type_source", // 5
"ompt_dependence_type_sink", // 6
"ompt_dependence_type_inoutset" // 7
"ompt_dependence_type_inoutset", // 7
"", "", "", "", "", "", // 8-13
"", "", "", "", "", "", "", "", "", "", // 14-23
"", "", "", "", "", "", "", "", "", "", // 24-33
"ompt_dependence_type_out_all_memory", // 34
"ompt_dependence_type_inout_all_memory" // 35
};

static void format_task_type(int type, char *buffer) {
Expand Down

0 comments on commit 6ef16f2

Please sign in to comment.