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 22, 2022
1 parent 2cb2792 commit dbda5d5
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/lib.rs
Expand Up @@ -1367,7 +1367,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 is_asm {
Expand Down Expand Up @@ -2035,7 +2042,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 dbda5d5

Please sign in to comment.