Skip to content

Commit

Permalink
Use the same OpenMP API as Clang for target parallel for pragma
Browse files Browse the repository at this point in the history
Clang uses kmpc_parallel_51 function for handlig target parallel for
pragma.

Flang should use the same functions as Clang for pragma
target parallel

Signed-off-by: Dominik Adamski <[email protected]>
  • Loading branch information
DominikAdamski committed May 10, 2022
1 parent 97bd64e commit 3fb2323
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion tools/flang2/flang2exe/cgmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14406,7 +14406,8 @@ INLINE void static add_property_struct(char *func_name,
print_token("@");
print_token(func_name);

if (is_SPMD_mode(mode)) {
if (mode >= mode_target_teams_distribute_parallel_for
&& mode <= mode_target_parallel_for_simd) {
print_token("__exec_mode = weak constant i8 2\n");
}
else {
Expand Down
28 changes: 22 additions & 6 deletions tools/flang2/flang2exe/kmpcutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1736,11 +1736,19 @@ ll_make_kmpc_target_init(OMP_TARGET_MODE mode)
int args[4];

args[3] = gen_null_arg(); /* ident */
if (is_SPMD_mode(mode)) {
if (mode >= mode_target_teams_distribute_parallel_for &&
mode <= mode_target_parallel_for_simd) {
args[2] = ad_icon(2); /* SPMD Mode */
args[1] = ad_icon(0); /* UseGenericStateMachine */
args[0] = ad_icon(0); /* RequiresFullRuntime */
// args[0] = ad_icon(1); /* RequiresFullRuntime */
if (mode == mode_target_parallel) {
/* RequiresFullRuntime - kmpc_parallel_51 requires full runtime */
args[0] = ad_icon(1);
}
else {
/* RequiresFullRuntime - Old Fortran OpenMP API does not require
* full runtime */
args[0] = ad_icon(0);
}
} else {
args[2] = ad_icon(1); /* Generic mode */
args[1] = ad_icon(1); /* UseGenericStateMachine */
Expand Down Expand Up @@ -1851,10 +1859,18 @@ ll_make_kmpc_target_deinit(OMP_TARGET_MODE mode)
int args[3];

args[2] = gen_null_arg(); /* ident */
if (is_SPMD_mode(mode)) {
if (mode >= mode_target_teams_distribute_parallel_for &&
mode <= mode_target_parallel_for_simd) {
args[1] = ad_icon(2); /* SPMD Mode */
args[0] = ad_icon(0); /* RequiresFullRuntime */
// args[0] = ad_icon(1); /* RequiresFullRuntime */
if (mode == mode_target_parallel) {
/* RequiresFullRuntime - kmpc_parallel_51 requires full runtime */
args[0] = ad_icon(1);
}
else {
/* RequiresFullRuntime - Old Fortran OpenMP API does not require
* full runtime */
args[0] = ad_icon(0);
}
} else {
args[1] = ad_icon(1); /* Generic mode */
args[0] = ad_icon(1); /* RequiresFullRuntime */
Expand Down
3 changes: 1 addition & 2 deletions tools/flang2/flang2exe/ompaccel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3726,8 +3726,7 @@ ompaccel_set_target_declare() {
}

bool is_SPMD_mode(OMP_TARGET_MODE mode) {
if (mode >= mode_target_teams_distribute_parallel_for
&& mode <= mode_target_parallel_for_simd) {
if (mode == mode_target_parallel) {
return true;
}
return false;
Expand Down

0 comments on commit 3fb2323

Please sign in to comment.