@@ -64,11 +64,13 @@ void Runtime::emit_host_code(CodeGen& code_gen, llvm::IRBuilder<>& builder, Plat
6464 assert (continuation->has_body ());
6565 auto body = continuation->body ();
6666 // to-target is the desired kernel call
67- // target(mem, device, (dim.x, dim.y, dim.z), (block.x, block.y, block.z), body, return, free_vars)
67+ // target(mem, device, (dim.x, dim.y, dim.z), (block.x, block.y, block.z), lmem, body, return, free_vars)
6868 auto target = body->callee ()->as_nom <Continuation>();
6969 assert_unused (target->is_intrinsic ());
7070 assert (body->num_args () >= LaunchArgs::Num && " required arguments are missing" );
7171
72+ auto & world = continuation->world ();
73+
7274 // arguments
7375 auto target_device_id = code_gen.emit (body->arg (LaunchArgs::Device));
7476 auto target_platform = builder.getInt32 (platform);
@@ -78,7 +80,6 @@ void Runtime::emit_host_code(CodeGen& code_gen, llvm::IRBuilder<>& builder, Plat
7880 auto it_config = body->arg (LaunchArgs::Config);
7981 auto kernel = body->arg (LaunchArgs::Body)->as <Global>()->init ()->as <Continuation>();
8082
81- auto & world = continuation->world ();
8283 // auto kernel_name = builder.CreateGlobalStringPtr(kernel->name() == "hls_top" ? kernel->name() : kernel->name());
8384 auto kernel_name = builder.CreateGlobalStringPtr (kernel->name ());
8485 auto file_name = builder.CreateGlobalStringPtr (world.name () + ext);
@@ -179,9 +180,12 @@ void Runtime::emit_host_code(CodeGen& code_gen, llvm::IRBuilder<>& builder, Plat
179180 allocs = builder.CreateInBoundsGEP (llvm::cast<llvm::AllocaInst>(allocs)->getAllocatedType (), allocs, gep_first_elem);
180181 types = builder.CreateInBoundsGEP (llvm::cast<llvm::AllocaInst>(types)->getAllocatedType (), types, gep_first_elem);
181182
183+ auto lmem = code_gen.emit (body->arg (LaunchArgs::LocalMem));
184+
182185 launch_kernel (code_gen, builder, target_device,
183186 file_name, kernel_name,
184187 grid_size, block_size,
188+ lmem,
185189 args, sizes, aligns, allocs, types,
186190 builder.getInt32 (num_kernel_args));
187191}
@@ -190,10 +194,11 @@ llvm::Value* Runtime::launch_kernel(
190194 CodeGen& code_gen, llvm::IRBuilder<>& builder, llvm::Value* device,
191195 llvm::Value* file, llvm::Value* kernel,
192196 llvm::Value* grid, llvm::Value* block,
197+ llvm::Value* lmem,
193198 llvm::Value* args, llvm::Value* sizes, llvm::Value* aligns, llvm::Value* allocs, llvm::Value* types,
194199 llvm::Value* num_args)
195200{
196- llvm::Value* launch_args[] = { device, file, kernel, grid, block, args, sizes, aligns, allocs, types, num_args };
201+ llvm::Value* launch_args[] = { device, file, kernel, grid, block, lmem, args, sizes, aligns, allocs, types, num_args };
197202 return builder.CreateCall (get (code_gen, " anydsl_launch_kernel" ), launch_args);
198203}
199204
0 commit comments