Skip to content

Commit c74b542

Browse files
committed
Try removing __rust_cuda_ffi_safe_assert module
1 parent 5e1534c commit c74b542

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

rust-cuda-kernel/src/kernel/wrapper/generate/cuda_wrapper.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,28 @@ pub(in super::super) fn quote_cuda_wrapper(
6161
},
6262
);
6363

64+
let private_func_params = func_params
65+
.iter()
66+
.map(|param| {
67+
let mut private = syn::Ident::clone(param);
68+
private.set_span(proc_macro::Span::def_site().into());
69+
private
70+
})
71+
.collect::<Vec<_>>();
72+
6473
quote! {
6574
#[cfg(target_os = "cuda")]
6675
#[#crate_path::device::specialise_kernel_function(#func_ident)]
6776
#[no_mangle]
6877
#[allow(unused_unsafe)]
6978
#(#func_attrs)*
7079
pub unsafe extern "ptx-kernel" fn #func_ident_hash(#(#ffi_inputs),*) {
80+
extern "C" { #(
81+
#[allow(dead_code)]
82+
#[deny(improper_ctypes)]
83+
static #private_func_params: #ffi_types;
84+
)* }
85+
7186
unsafe {
7287
// Initialise the dynamically-sized thread-block shared memory
7388
// and the thread-local offset pointer that points to it
@@ -89,17 +104,6 @@ pub(in super::super) fn quote_cuda_wrapper(
89104
::core::arch::asm!(#KERNEL_TYPE_USE_END_CANARY);
90105
}
91106

92-
#[deny(improper_ctypes)]
93-
mod __rust_cuda_ffi_safe_assert {
94-
#[allow(unused_imports)]
95-
use super::*;
96-
97-
extern "C" { #(
98-
#[allow(dead_code)]
99-
static #func_params: #ffi_types;
100-
)* }
101-
}
102-
103107
#ffi_param_ptx_jit_wrap
104108
}
105109
}

rust-cuda-kernel/src/kernel/wrapper/generate/host_linker_macro/get_ptx.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,24 @@ pub(super) fn quote_get_ptx(
8080
.collect::<Vec<_>>()
8181
};
8282

83+
let private_func_params = func_params
84+
.iter()
85+
.map(|param| {
86+
let mut private = syn::Ident::clone(param);
87+
private.set_span(proc_macro::Span::def_site().into());
88+
private
89+
})
90+
.collect::<Vec<_>>();
91+
8392
quote! {
8493
fn get_ptx() -> &'static ::core::ffi::CStr {
85-
#[allow(unused_imports)]
86-
use __rust_cuda_ffi_safe_assert::#args;
94+
#args_trait
95+
96+
extern "C" { #(
97+
#[allow(dead_code)]
98+
#[deny(improper_ctypes)]
99+
static #private_func_params: #cpu_func_lifetime_erased_types;
100+
)* }
87101

88102
#crate_path::kernel::link_kernel!{
89103
#func_ident #func_ident_hash #crate_name #crate_manifest_dir #generic_start_token
@@ -95,19 +109,6 @@ pub(super) fn quote_get_ptx(
95109

96110
#(#type_layout_asserts)*
97111

98-
#[deny(improper_ctypes)]
99-
mod __rust_cuda_ffi_safe_assert {
100-
#[allow(unused_imports)]
101-
use super::*;
102-
103-
#args_trait
104-
105-
extern "C" { #(
106-
#[allow(dead_code)]
107-
static #func_params: #cpu_func_lifetime_erased_types;
108-
)* }
109-
}
110-
111112
PTX_CSTR
112113
}
113114
}

src/host/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ impl<'a, T: PortableBitSemantics + TypeGraphLayout> HostAndDeviceMutRef<'a, T> {
152152
}
153153
}
154154

155-
#[allow(dead_code)] // FIXME
156155
#[must_use]
157156
pub(crate) fn for_device<'b>(&'b mut self) -> DeviceMutRef<'a, T>
158157
where
@@ -164,7 +163,6 @@ impl<'a, T: PortableBitSemantics + TypeGraphLayout> HostAndDeviceMutRef<'a, T> {
164163
}
165164
}
166165

167-
#[allow(dead_code)] // FIXME
168166
#[must_use]
169167
pub(crate) fn for_host<'b: 'a>(&'b self) -> &'a T {
170168
self.host_ref

0 commit comments

Comments
 (0)