Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Remove nvptx target architecture conditions. #145

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/cuda_std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ pub mod prelude {
};
}

#[cfg(any(target_arch = "nvptx", target_arch = "nvptx64"))]
#[cfg(target_arch = "nvptx64")]
#[alloc_error_handler]
fn alloc_handler(layout: core::alloc::Layout) -> ! {
core::panic!("Memory allocation of {} bytes failed", layout.size());
}

// FIXME(RDambrosio016): For some very odd reason, this function causes an InvalidAddress error when called,
// despite it having no reason for doing that. It needs more debugging to see what is causing it exactly. For now we just trap.
#[cfg(any(target_arch = "nvptx", target_arch = "nvptx64"))]
#[cfg(target_arch = "nvptx64")]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
// use crate::prelude::*;
Expand Down
6 changes: 3 additions & 3 deletions crates/cuda_std_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn kernel(input: proc_macro::TokenStream, item: proc_macro::TokenStream) ->
let mut item = parse_macro_input!(item as ItemFn);
let no_mangle = parse_quote!(#[no_mangle]);
item.attrs.push(no_mangle);
let internal = parse_quote!(#[cfg_attr(any(target_arch="nvptx", target_arch="nvptx64"), nvvm_internal(kernel(#input)))]);
let internal = parse_quote!(#[cfg_attr(target_arch="nvptx64", nvvm_internal(kernel(#input)))]);
item.attrs.push(internal);

// used to guarantee some things about how params are passed in the codegen.
Expand Down Expand Up @@ -170,13 +170,13 @@ pub fn gpu_only(_attr: proc_macro::TokenStream, item: proc_macro::TokenStream) -
};

let output = quote::quote! {
#[cfg(not(any(target_arch="nvptx", target_arch="nvptx64")))]
#[cfg(not(target_arch="nvptx64"))]
#[allow(unused_variables)]
#(#cloned_attrs)* #vis #sig_cpu {
unimplemented!(concat!("`", stringify!(#fn_name), "` can only be used on the GPU with rustc_codegen_nvvm"))
}

#[cfg(any(target_arch="nvptx", target_arch="nvptx64"))]
#[cfg(target_arch="nvptx64")]
#(#attrs)* #vis #sig {
#block
}
Expand Down
Loading