Skip to content

Commit 6737371

Browse files
Do not modify the LLType of the argument
If we generate initialization function for SPMD kernels we need to store addresses of the arguments before we call kmpc_parallel_51 function. We use ptrtoint instruction for scalar variables. Before this patch the LLVM IR code was generated wrongly for complex variables: void kernel_func(<float, float> *Arg_c) //some code ptrtoint i64* %Arg_c //error Arg_c was declared as pair of floats //some code call kmpc_parallel_51() //some code This patch causes that LLVM IR contains correct ptrtoint instruction: void kernel_func(<float, float> *Arg_c) //some code ptrtoint <float, float>* %Arg_c //ok, Arg_c was declared as pair of floats //some code call kmpc_parallel_51() //some code Signed-off-by: Dominik Adamski <[email protected]>
1 parent 5de4a26 commit 6737371

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

tools/flang2/flang2exe/cgmain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12267,7 +12267,7 @@ process_sptr_offset(SPTR sptr, ISZ_T off)
1226712267
}
1226812268
if ((flg.smp || (XBIT(34, 0x200) || gbl.usekmpc)) &&
1226912269
(gbl.outlined || ISTASKDUPG(GBL_CURRFUNC))) {
12270-
if (sptr == ll_get_shared_arg(gbl.currsub)) {
12270+
if (sptr == ll_get_shared_arg(gbl.currsub) && !gbl.is_init_spmd_kernel) {
1227112271
LLTYPE(sptr) = make_ptr_lltype(make_lltype_from_dtype(DT_INT8));
1227212272
}
1227312273
}

tools/flang2/flang2exe/expand.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ expand(void)
237237
static std::map<int, int> process_expanded_map = std::map<int,int>();
238238
auto it = process_expanded_map.find(gbl.currsub);
239239
int process_expanded = 0;
240+
// we reset flag because we do not know if we generate initialization
241+
// function for SPMD kernel (the function with kmpc_parallel_51 call)
242+
// or the proper kernel code (the function which is passed as an argument
243+
// to kmpc_parallel_51 call or generic kernel
244+
gbl.is_init_spmd_kernel = false;
240245
if (it != process_expanded_map.end())
241246
{
242247
process_expanded = it->second;
@@ -806,7 +811,8 @@ eval_ilm_check_if_skip(int ilmx, int *skip_expand, int *process_expanded)
806811
ilix = ll_make_kmpc_global_thread_num();
807812
iltb.callfg = 1;
808813
chk_block(ilix);
809-
sptr1 = ll_make_helper_function_for_kmpc_parallel_51((SPTR)0, ompaccel_tinfo_get(gbl.currsub));
814+
gbl.is_init_spmd_kernel = true;
815+
sptr1 = ll_make_helper_function_for_kmpc_parallel_51((SPTR)0, ompaccel_tinfo_get(gbl.currsub));
810816
ilix = ll_make_kmpc_parallel_51(ilix, allocated_symbols, sptr1);
811817
iltb.callfg = 1;
812818
chk_block(ilix);

tools/shared/utils/global.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ typedef struct {
162162
bool ompaccel_intarget; /* set when expander is in the openmp target construct */
163163
bool ompaccel_isdevice; /* set when generating code for openmp target device */
164164
SPTR teamPrivateArgs; /* keeps sptr that holds team private array */
165+
bool is_init_spmd_kernel; /* if TRUE, we generate initialization proceudre of SPMD kernel */
165166
#endif
166167
} GBL;
167168

0 commit comments

Comments
 (0)