Skip to content

Commit dca9dc0

Browse files
committed
cleanpu
1 parent e5a6cdf commit dca9dc0

File tree

1 file changed

+8
-29
lines changed

1 file changed

+8
-29
lines changed

compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,9 @@ pub(crate) fn gen_define_handling<'ll>(
368368

369369
let offload_entry_ty = offload_globals.offload_entry_ty;
370370

371-
let mut arg_iter = types.iter().zip(metadata);
372-
373371
// It seems like non-pointer values are automatically mapped. So here, we focus on pointer (or
374372
// reference) types.
375-
let ptr_meta = arg_iter.filter_map(|(&x, meta)| match cx.type_kind(x) {
373+
let ptr_meta = types.iter().zip(metadata).filter_map(|(&x, meta)| match cx.type_kind(x) {
376374
rustc_codegen_ssa::common::TypeKind::Pointer => Some(meta),
377375
_ => None,
378376
});
@@ -481,7 +479,6 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
481479
host_llfn: &'ll Value,
482480
host_llty: &'ll Type,
483481
) {
484-
dbg!(&host_llfn);
485482
let cx = builder.cx;
486483
let OffloadKernelGlobals { offload_sizes, offload_entry, memtransfer_types, region_id } =
487484
offload_data;
@@ -504,7 +501,12 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
504501

505502
// FIXME(Sa4dUs): dummy loads are a temp workaround, we should find a proper way to prevent these
506503
// variables from being optimized away
507-
for val in [offload_sizes] {
504+
let to_keep: &[&llvm::Value] = if let Some(offload_entry) = offload_entry {
505+
&[offload_sizes, offload_entry]
506+
} else {
507+
&[offload_sizes]
508+
};
509+
for val in to_keep {
508510
//for val in [offload_sizes, offload_entry] {
509511
unsafe {
510512
let dummy = llvm::LLVMBuildLoad2(
@@ -638,33 +640,13 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
638640
let args = vec![
639641
s_ident_t,
640642
// FIXME(offload) give users a way to select which GPU to use.
641-
//cx.get_const_i64(0), // MAX == -1.
642643
cx.get_const_i64(u64::MAX), // MAX == -1.
643644
num_workgroups,
644645
threads_per_block,
645646
region_id,
646647
a5,
647648
];
648649
if host {
649-
//let new_args = vec![];
650-
//dbg!(&args);// were overwritten above, now hold omp stuff (shadowed)
651-
dbg!(&vals);
652-
dbg!(&types);
653-
//dbg!(&fn_ty);
654-
//let host_llty = cx.llvm_ty(host_llfn);
655-
dbg!(&host_fnc_name);
656-
dbg!(cx.get_defined_value(&host_fnc_name));
657-
//let user_fn = unsafe {
658-
// llvm::LLVMRustGetOrInsertFunction(
659-
// builder.llmod,
660-
// host_fnc_name.as_c_char_ptr(),
661-
// host_fnc_name.len(),
662-
// fn_ty,
663-
// )
664-
//};
665-
//dbg!(&user_fn);
666-
// void *omp_get_mapped_ptr(void *ptr, int device_num);
667-
668650
let fn_name = "omp_get_mapped_ptr";
669651
let ty2: &'ll Type = cx.type_func(&[cx.type_ptr(), cx.type_i32()], cx.type_ptr());
670652
let mapper_fn = unsafe {
@@ -679,17 +661,14 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
679661
let mut device_vals = Vec::with_capacity(vals.len());
680662
let device_num = cx.get_const_i32(0);
681663
for arg in vals {
682-
dbg!(&mapper_fn);
683-
dbg!(&ty2);
684664
let device_arg =
685665
builder.call(ty2, None, None, mapper_fn, &[arg, device_num], None, None);
686666
device_vals.push(device_arg);
687667
}
688668
builder.call(host_llty, None, None, host_llfn, &device_vals, None, None);
689-
//builder.call(fn_ty, None, None, host_llfn, &vals, None, None);
690669
} else {
691-
builder.call(tgt_target_kernel_ty, None, None, tgt_decl, &args, None, None);
692670
// %41 = call i32 @__tgt_target_kernel(ptr @1, i64 -1, i32 2097152, i32 256, ptr @.kernel_1.region_id, ptr %kernel_args)
671+
builder.call(tgt_target_kernel_ty, None, None, tgt_decl, &args, None, None);
693672
}
694673

695674
// Step 4)

0 commit comments

Comments
 (0)