Skip to content

Commit

Permalink
Add support for passing integers by value
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Adamski <[email protected]>
  • Loading branch information
DominikAdamski committed Apr 7, 2022
1 parent eb88435 commit 077b527
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
5 changes: 4 additions & 1 deletion tools/flang2/flang2exe/expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ expand(void)
static std::map<int, int> process_expanded_map = std::map<int,int>();
auto it = process_expanded_map.find(gbl.currsub);
int process_expanded = 0;

// we reset flag because we do not know if we generate initialization
// function for SPMD kernel (the function with kmpc_parallel_51 call)
// or the proper kernel code (the function which is passed as an argument
Expand Down Expand Up @@ -507,6 +508,9 @@ static std::vector<int> get_allocated_symbols(OMPACCEL_TINFO *orig_symbols)
int store_instr;
int load_instr;
for (unsigned i = 0; i < num_of_symbols; ++i) {
if (PASSBYVALG(orig_symbols->symbols[i].device_sym) &&
!PASSBYREFG(orig_symbols->symbols[i].device_sym))
continue;
if (!DT_ISSCALAR(DTYPEG(orig_symbols->symbols[i].device_sym))
&& STYPEG(orig_symbols->symbols[i].host_sym) != ST_STRUCT) {
continue;
Expand All @@ -531,7 +535,6 @@ static std::vector<int> get_allocated_symbols(OMPACCEL_TINFO *orig_symbols)
chk_block(load_instr);

init_symbols.push_back(load_instr);

}
return init_symbols;

Expand Down
10 changes: 9 additions & 1 deletion tools/flang2/flang2exe/kmpcutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,15 @@ ll_make_kmpc_parallel_51(int global_tid_sptr, std::vector<int> &symbols, SPTR he
for (int i = 0; i < n_symbols; ++i) {
if (check_if_skip_symbol(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym))
continue;
if (DT_ISSCALAR(DTYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym)) ||
else if (PASSBYVALG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym) &&
!PASSBYREFG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym)) {
ilix = mk_ompaccel_ldsptr(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym);
ilix = mk_ompaccel_store(ilix,
DT_INT8,
nme_args,
ad_acon(captured_vars, i * TARGET_PTRSIZE));
}
else if (DT_ISSCALAR(DTYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym)) ||
STYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].host_sym) == ST_STRUCT) {
ilix = mk_ompaccel_store(symbols[j++],
DT_INT8,
Expand Down
9 changes: 5 additions & 4 deletions tools/flang2/flang2exe/outliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,14 @@ ll_make_ftn_outlined_params(int func_sptr, int paramct, DTYPE *argtype, OMPACCEL
NEED((current_tinfo->n_symbols + 1), current_tinfo->symbols, OMPACCEL_SYM,
current_tinfo->sz_symbols, current_tinfo->sz_symbols * 2);
if (cnt >= 2) {
PASSBYVALP(sym, false);
PASSBYREFP(sym, true);
if (!(PASSBYVALG(sym) && !PASSBYREFG(sym) && DTYPEG(sym) == DT_INT8)) {
PASSBYVALP(sym, false);
PASSBYREFP(sym, true);
}
current_tinfo->symbols[current_tinfo->n_symbols].host_sym =
ompaccel_tinfo_get(gbl.currsub)->symbols[cnt-2].device_sym;
current_tinfo->symbols[current_tinfo->n_symbols].device_sym =
ompaccel_tinfo_get(gbl.currsub)->symbols[cnt-2].device_sym;
ompaccel_tinfo_get(gbl.currsub)->symbols[cnt-2].device_sym;
}
current_tinfo->symbols[current_tinfo->n_symbols].map_type = 0;
current_tinfo->symbols[current_tinfo->n_symbols].in_map = 0;
Expand Down Expand Up @@ -2709,7 +2711,6 @@ ll_make_helper_function_for_kmpc_parallel_51(SPTR scope_sptr, OMPACCEL_TINFO *or
else {
func_args[k] = DTYPEG(symbols->device_sym);
}
PASSBYVALP(symbols->device_sym, false);
symbols++;
}

Expand Down

0 comments on commit 077b527

Please sign in to comment.