Skip to content

Commit

Permalink
Refine CUDA support.
Browse files Browse the repository at this point in the history
Instead of counting all source files we count only .cu files, ones with
device code that actually require the special treatment.
  • Loading branch information
dot-asm committed Nov 3, 2022
1 parent bac2216 commit a5ace66
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/lib.rs
Expand Up @@ -1342,7 +1342,14 @@ impl Build {
if !msvc || !is_asm || !is_arm {
cmd.arg("-c");
}
if self.cuda && self.files.len() > 1 {
if self.cuda
&& self
.files
.iter()
.filter(|file| file.extension() == Some(OsStr::new("cu")))
.count()
> 1
{
cmd.arg("--device-c");
}
if compiler.family == (ToolFamily::Msvc { clang_cl: true }) {
Expand Down Expand Up @@ -1999,7 +2006,14 @@ impl Build {
self.assemble_progressive(dst, chunk)?;
}

if self.cuda {
if self.cuda
&& self
.files
.iter()
.filter(|file| file.extension() == Some(OsStr::new("cu")))
.count()
> 0
{
// Link the device-side code and add it to the target library,
// so that non-CUDA linker can link the final binary.

Expand Down

0 comments on commit a5ace66

Please sign in to comment.