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 Aug 4, 2022
1 parent 7ae4d9e commit 549b71c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/lib.rs
Expand Up @@ -1308,7 +1308,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 @@ -1965,7 +1972,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 549b71c

Please sign in to comment.