Skip to content

Commit

Permalink
Merge branch 'aomp-dev' into aomp-epsdb-mainline
Browse files Browse the repository at this point in the history
Change-Id: I86e451b13e91b457645074a5542051350336d754
  • Loading branch information
ronlieb committed Feb 22, 2023
2 parents a3137e0 + 4b84802 commit 0ab1484
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
14 changes: 11 additions & 3 deletions tools/flang1/flang1exe/semsmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,6 @@ semsmp(int rednum, SST *top)
*/
case MP_STMT41:
if (sem.metadirective.whencondition) {
if (sem.metadirective.whenexpanded) { break; }
if (!sem.metadirective.defaultcondition && !sem.metadirective.whenconditionvalue) { break; }
sem.metadirective.whenexpanded = true;
}
Expand All @@ -1602,7 +1601,7 @@ semsmp(int rednum, SST *top)
sem.collapse = CL_VAL(CL_COLLAPSE);
} else if (CL_PRESENT(CL_SAFELEN) || CL_PRESENT(CL_LINEAR) ||
CL_PRESENT(CL_ALIGNED) || CL_PRESENT(CL_PRIVATE) ||
CL_PRESENT(CL_LASTPRIVATE) || CL_PRESENT(CL_REDUCTION)){
CL_PRESENT(CL_LASTPRIVATE)){
errwarn((error_code_t)604);
sem.expect_simd_do = FALSE;
par_push_scope(TRUE);
Expand Down Expand Up @@ -9706,7 +9705,16 @@ static bool
begin_combine_constructs(BIGINT64 construct)
{
int doif = sem.doif_depth;
int ast, combinedMode;
int ast;
int combinedMode = get_omp_combined_mode(construct);
if (sem.metadirective.whencondition) {
if (sem.metadirective.whenexpanded ||
(!sem.metadirective.defaultcondition && !sem.metadirective.whenconditionvalue)) {
--sem.doif_depth;
return false;
}
}

LOGICAL do_enter = FALSE;

has_team = FALSE;
Expand Down
40 changes: 33 additions & 7 deletions tools/flang2/flang2exe/tgtutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@
#ifdef OMP_OFFLOAD_AMD
#include <vector>
#include <algorithm>

// Vector to keep track all array accesses with constant offset within device.
extern std::vector<SPTR> constArraySymbolList;
#endif
static int updateregion = 0;
// AOCC End

#ifdef OMP_OFFLOAD_LLVM
static void change_target_func_smbols(int outlined_func_sptr, int stblk_sptr);
// AOCC additional argument
Expand Down Expand Up @@ -423,9 +425,23 @@ _tgt_target_fill_maptype(SPTR sptr, int maptype, int isMidnum, int midnum_maptyp
return final_maptype;
}

static bool isOpenMPKernelCall(int api_id)
{
switch (api_id){
case TGT_API_TARGET:
case TGT_API_TARGET_TEAMS:
case TGT_API_TARGET_TEAMS_PARALLEL:
return true;
default:
return false;
}
return false;
}

void
tgt_target_fill_params(SPTR arg_base_sptr, SPTR arg_size_sptr, SPTR args_sptr,
SPTR args_maptypes_sptr, OMPACCEL_TINFO *targetinfo)
SPTR args_maptypes_sptr, OMPACCEL_TINFO *targetinfo,
int api_id)
{
int i, j, ilix, iliy;
char *name_base="", *name_length="";
Expand Down Expand Up @@ -528,6 +544,14 @@ tgt_target_fill_params(SPTR arg_base_sptr, SPTR arg_size_sptr, SPTR args_sptr,
#endif
// AOCC End

// Flang and Clang can generate OpenMP kernels where number of device
// kernel arguments is not equal to number of passed host arguments.
// That's why, if given host symbol is not mapped in the target kernel
// then we should not mark it as valid param.
if (isOpenMPKernelCall(api_id) &&
targetinfo->symbols[i].device_sym == NOSYM) {
targetinfo->symbols[i].map_type &= ~(OMP_TGT_MAPTYPE_TARGET_PARAM);
}
ilix = ad4ili(IL_ST, ad_icon(targetinfo->symbols[i].map_type),
ad_acon(args_maptypes_sptr, i * TARGET_PTRSIZE), nme_types, MSZ_I8);
chk_block(ilix);
Expand Down Expand Up @@ -682,7 +706,7 @@ ll_make_tgt_target(SPTR outlined_func_sptr, int64_t device_id, SPTR stblk_sptr)
args_maptypes_sptr = make_array_sptr(name, DT_INT8, targetinfo->n_symbols);

tgt_target_fill_params(arg_base_sptr, arg_size_sptr, args_sptr,
args_maptypes_sptr, targetinfo);
args_maptypes_sptr, targetinfo, TGT_API_TARGET);

// prepare argument for tgt target
int locargs[7];
Expand Down Expand Up @@ -737,7 +761,7 @@ ll_make_tgt_target_teams(SPTR outlined_func_sptr, int64_t device_id,
args_maptypes_sptr = make_array_sptr(name, DT_INT8, nargs);

tgt_target_fill_params(arg_base_sptr, arg_size_sptr, args_sptr,
args_maptypes_sptr, targetinfo);
args_maptypes_sptr, targetinfo, TGT_API_TARGET_TEAMS);

// prepare argument for tgt target
int locargs[9];
Expand Down Expand Up @@ -809,7 +833,8 @@ ll_make_tgt_target_teams_parallel(SPTR outlined_func_sptr, int64_t device_id,
args_maptypes_sptr = make_array_sptr(name, DT_INT8, nargs);

tgt_target_fill_params(arg_base_sptr, arg_size_sptr, args_sptr,
args_maptypes_sptr, targetinfo);
args_maptypes_sptr, targetinfo,
TGT_API_TARGET_TEAMS_PARALLEL);

// prepare argument for tgt target
int locargs[11];
Expand Down Expand Up @@ -860,7 +885,8 @@ ll_make_tgt_target_data_begin(int device_id, OMPACCEL_TINFO *targetinfo)
dataregion++;

tgt_target_fill_params(arg_base_sptr, arg_size_sptr, args_sptr,
args_maptypes_sptr, targetinfo);
args_maptypes_sptr, targetinfo,
TGT_API_TARGET_DATA_BEGIN);

locargs[5] = ad_icon(device_id);
locargs[4] = ad_icon(nargs);
Expand Down Expand Up @@ -904,7 +930,7 @@ _tgt_target_fill_targetdata(int device_id, OMPACCEL_TINFO *targetinfo, int tgt_a
dataregion++;

tgt_target_fill_params(arg_base_sptr, arg_size_sptr, args_sptr,
args_maptypes_sptr, targetinfo);
args_maptypes_sptr, targetinfo, tgt_api);

locargs[5] = ad_icon(device_id);
locargs[4] = ad_icon(nargs);
Expand Down Expand Up @@ -1397,7 +1423,7 @@ ll_make_tgt_target_update(int device_id, OMPACCEL_TINFO *targetinfo)
updateregion++;

tgt_target_fill_params(arg_base_sptr, arg_size_sptr, arg_sptr,
arg_map_sptr, targetinfo);
arg_map_sptr, targetinfo, TGT_API_TARGETUPDATE);

local_args[5] = ad_icon(device_id);
local_args[4] = ad_icon(nargs);
Expand Down

0 comments on commit 0ab1484

Please sign in to comment.