Skip to content

Commit 792c31c

Browse files
dot-asmthomcc
authored andcommitted
Refine CUDA support.
Instead of counting all source files we count only .cu files, ones with device code that actually require the special treatment.
1 parent e0df9ba commit 792c31c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ impl Build {
13691369
if !msvc || !is_asm || !is_arm {
13701370
cmd.arg("-c");
13711371
}
1372-
if self.cuda && self.files.len() > 1 {
1372+
if self.cuda && self.cuda_file_count() > 1 {
13731373
cmd.arg("--device-c");
13741374
}
13751375
if is_asm {
@@ -2037,7 +2037,7 @@ impl Build {
20372037
self.assemble_progressive(dst, chunk)?;
20382038
}
20392039

2040-
if self.cuda {
2040+
if self.cuda && self.cuda_file_count() > 0 {
20412041
// Link the device-side code and add it to the target library,
20422042
// so that non-CUDA linker can link the final binary.
20432043

@@ -3012,6 +3012,13 @@ impl Build {
30123012
cache.insert(sdk.into(), ret.clone());
30133013
Ok(ret)
30143014
}
3015+
3016+
fn cuda_file_count(&self) -> usize {
3017+
self.files
3018+
.iter()
3019+
.filter(|file| file.extension() == Some(OsStr::new("cu")))
3020+
.count()
3021+
}
30153022
}
30163023

30173024
impl Default for Build {

0 commit comments

Comments
 (0)