@@ -64,21 +64,24 @@ Continuation* Runtime::emit_host_code(CodeGen& code_gen, llvm::IRBuilder<>& buil
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);
7577    auto  target_device = builder.CreateOr (target_platform, builder.CreateShl (target_device_id, builder.getInt32 (4 )));
7678
7779    auto  it_space = body->arg (LaunchArgs::Space);
7880    auto  it_config = body->arg (LaunchArgs::Config);
79-     auto  kernel = body->arg (LaunchArgs::Body)->as <Global>()->init ()->as <Continuation>();
8081
81-     auto & world = continuation->world ();
82+     auto  lmem = code_gen.emit (body->arg (LaunchArgs::LocalMem));
83+ 
84+     auto  kernel = body->arg (LaunchArgs::Body)->as <Global>()->init ()->as <Continuation>();
8285    auto  kernel_name = builder.CreateGlobalStringPtr (kernel->name () == " hls_top"   ? kernel->name () : kernel->unique_name ());
8386    auto  file_name = builder.CreateGlobalStringPtr (world.name () + ext);
8487    const  size_t  num_kernel_args = body->num_args () - LaunchArgs::Num;
@@ -181,6 +184,7 @@ Continuation* Runtime::emit_host_code(CodeGen& code_gen, llvm::IRBuilder<>& buil
181184    launch_kernel (code_gen, builder, target_device,
182185                  file_name, kernel_name,
183186                  grid_size, block_size,
187+                   lmem,
184188                  args, sizes, aligns, allocs, types,
185189                  builder.getInt32 (num_kernel_args));
186190
@@ -191,10 +195,11 @@ llvm::Value* Runtime::launch_kernel(
191195    CodeGen& code_gen, llvm::IRBuilder<>& builder, llvm::Value* device,
192196    llvm::Value* file, llvm::Value* kernel,
193197    llvm::Value* grid, llvm::Value* block,
198+     llvm::Value* lmem,
194199    llvm::Value* args, llvm::Value* sizes, llvm::Value* aligns, llvm::Value* allocs, llvm::Value* types,
195200    llvm::Value* num_args)
196201{
197-     llvm::Value* launch_args[] = { device, file, kernel, grid, block, args, sizes, aligns, allocs, types, num_args };
202+     llvm::Value* launch_args[] = { device, file, kernel, grid, block, lmem,  args, sizes, aligns, allocs, types, num_args };
198203    return  builder.CreateCall (get (code_gen, " anydsl_launch_kernel"  ), launch_args);
199204}
200205
0 commit comments