Skip to content

Commit c61daab

Browse files
Skip symbols which are not initialized
Signed-off-by: Dominik Adamski <[email protected]>
1 parent ac07dcf commit c61daab

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

tools/flang2/flang2exe/kmpcutil.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,11 +1749,31 @@ ll_make_kmpc_target_init(OMP_TARGET_MODE mode)
17491749
return mk_kmpc_api_call(KMPC_API_TARGET_INIT, 4, arg_types, args);
17501750
}
17511751

1752+
int get_n_symbols(OMPACCEL_TINFO *tinfo)
1753+
{
1754+
int orig_n_symbols = tinfo->n_symbols;
1755+
int n_symbols = orig_n_symbols;
1756+
for (int i = 0; i < orig_n_symbols; ++i) {
1757+
//skip uninitialized symbols
1758+
if (DTYPEG(tinfo->symbols[i].device_sym) == 0) {
1759+
n_symbols--;
1760+
}
1761+
}
1762+
return n_symbols;
1763+
}
1764+
1765+
bool check_if_skip_symbol(SPTR sym)
1766+
{
1767+
if (DTYPEG(sym) == 0)
1768+
return true;
1769+
return false;
1770+
}
1771+
17521772
int
17531773
ll_make_kmpc_parallel_51(int global_tid_sptr, std::vector<int> &symbols, SPTR helper_func)
17541774
{
17551775
static int id;
1756-
int n_symbols = ompaccel_tinfo_get(gbl.currsub)->n_symbols;//2;//symbols.size();
1776+
int n_symbols = get_n_symbols(ompaccel_tinfo_get(gbl.currsub));
17571777
DTYPE arg_types[9];
17581778
DTYPE void_ptr_t = DT_ADDR;//create_dtype_funcprototype();
17591779
DTYPE void_ptr_ptr_t = get_type(2, TY_PTR, void_ptr_t);
@@ -1770,8 +1790,9 @@ ll_make_kmpc_parallel_51(int global_tid_sptr, std::vector<int> &symbols, SPTR he
17701790
ad_icon(0),
17711791
FALSE);
17721792
int j = 0;
1773-
1774-
for (unsigned i = 0; i < n_symbols; ++i) {
1793+
for (int i = 0; i < n_symbols; ++i) {
1794+
if (check_if_skip_symbol(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym))
1795+
continue;
17751796
if (DT_ISSCALAR(DTYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym)) ||
17761797
STYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].host_sym) == ST_STRUCT) {
17771798
ilix = mk_ompaccel_store(symbols[j++],

tools/flang2/flang2exe/kmpcutil.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,18 @@ int ll_make_kmpc_nvptx_parallel_reduce_nowait_simple_spmd(int, int, int, SPTR, S
534534
*/
535535
int ll_make_kmpc_nvptx_end_reduce_nowait();
536536

537+
/**
538+
\brief Get number of correctly initialized number of symbols.
539+
*/
540+
int get_n_symbols(OMPACCEL_TINFO *tinfo);
541+
542+
/**
543+
\brief Check if given symbol should be skipped
544+
If DTYPE of symbol is 0 then the symbol should not be passed
545+
as an argument to kmpc_parallel_51 function
546+
*/
547+
bool check_if_skip_symbol(SPTR sym);
548+
537549
/* End OpenMP Accelerator RT - non standard */
538550
#endif
539551
#endif /* KMPC_RUNTIME_H_ */

tools/flang2/flang2exe/outliner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2691,7 +2691,8 @@ ll_make_helper_function_for_kmpc_parallel_51(SPTR scope_sptr, OMPACCEL_TINFO *or
26912691
int max_nargs = orig_tinfo->n_symbols +
26922692
orig_tinfo->n_quiet_symbols +
26932693
orig_tinfo->n_reduction_symbols;
2694-
int func_args_cnt = orig_tinfo->n_symbols + 2; // global_tid, bound_tid + target_info args
2694+
int func_args_cnt = get_n_symbols(orig_tinfo);
2695+
func_args_cnt += 2; // global_tid, bound_tid + target_info args
26952696
std::vector<DTYPE> func_args(func_args_cnt);
26962697
auto *symbols = orig_tinfo->symbols;
26972698
func_args[0] = get_type(2, TY_PTR, DT_INT8);//DT_CPTR; // global_tid

0 commit comments

Comments
 (0)