Skip to content

Commit

Permalink
Add nvhpc ( nvc, nvc++ ) to the set of supported compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard authored and sylvestre committed Sep 29, 2023
1 parent 8253364 commit 4aff489
Show file tree
Hide file tree
Showing 6 changed files with 441 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export RUSTC_WRAPPER=/path/to/sccache
cargo build
```

sccache supports gcc, clang, MSVC, rustc, NVCC, and [Wind River's diab compiler](https://www.windriver.com/products/development-tools/#diab_compiler). Both gcc and msvc support Response Files, read more about their implementation [here](docs/ResponseFiles.md).
sccache supports gcc, clang, MSVC, rustc, [NVCC](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html), [NVC++](https://docs.nvidia.com/hpc-sdk//compilers/hpc-compilers-user-guide/index.html), and [Wind River's diab compiler](https://www.windriver.com/products/development-tools/#diab_compiler). Both gcc and msvc support Response Files, read more about their implementation [here](docs/ResponseFiles.md).

If you don't [specify otherwise](#storage-options), sccache will use a local disk cache.

Expand Down
11 changes: 11 additions & 0 deletions src/compiler/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ pub enum CCompilerKind {
Msvc,
/// NVIDIA cuda compiler
Nvcc,
/// NVIDIA hpc c, c++ compiler
Nvhpc,
/// Tasking VX
TaskingVX,
}
Expand Down Expand Up @@ -682,6 +684,15 @@ impl pkg::ToolchainPackager for CToolchainPackager {
add_named_prog(&mut package_builder, "ptxas")?;
}

CCompilerKind::Nvhpc => {
// Various programs called by the nvc nvc++ front end.
add_named_file(&mut package_builder, "cpp1")?;
add_named_file(&mut package_builder, "cpp2")?;
add_named_file(&mut package_builder, "opt")?;
add_named_prog(&mut package_builder, "llc")?;
add_named_prog(&mut package_builder, "acclnk")?;
}

_ => unreachable!(),
}

Expand Down
36 changes: 36 additions & 0 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::compiler::msvc;
use crate::compiler::msvc::Msvc;
use crate::compiler::nvcc::Nvcc;
use crate::compiler::nvcc::NvccHostCompiler;
use crate::compiler::nvhpc::Nvhpc;
use crate::compiler::rust::{Rust, RustupProxy};
use crate::compiler::tasking_vx::TaskingVX;
#[cfg(feature = "dist-client")]
Expand Down Expand Up @@ -1083,6 +1084,8 @@ where
// Both clang and clang-cl define _MSC_VER on Windows, so we first
// check for MSVC, then check whether _MT is defined, which is the
// difference between clang and clang-cl.
// NVHPC needs a custom version line since `__VERSION__` evaluates
// to the EDG version.
//
// We prefix the information we need with `compiler_id` and `compiler_version`
// so that we can support compilers that insert pre-amble code even in `-E` mode
Expand All @@ -1097,6 +1100,9 @@ compiler_id=nvcc
compiler_id=msvc
#elif defined(_MSC_VER) && defined(_MT)
compiler_id=msvc-clang
#elif defined(__NVCOMPILER)
compiler_id=nvhpc
compiler_version=__NVCOMPILER_MAJOR__.__NVCOMPILER_MINOR__.__NVCOMPILER_PATCHLEVEL__
#elif defined(__clang__) && defined(__cplusplus) && defined(__apple_build_version__)
compiler_id=apple-clang++
#elif defined(__clang__) && defined(__cplusplus)
Expand Down Expand Up @@ -1250,6 +1256,19 @@ compiler_version=__VERSION__
.await
.map(|c| Box::new(c) as Box<dyn Compiler<T>>);
}
"nvhpc" => {
debug!("Found NVHPC");
return CCompiler::new(
Nvhpc {
nvcplusplus: kind == "nvc++",
version: version.clone(),
},
executable,
&pool,
)
.await
.map(|c| Box::new(c) as Box<dyn Compiler<T>>);
}
"tasking_vx" => {
debug!("Found Tasking VX");
return CCompiler::new(TaskingVX, executable, &pool)
Expand Down Expand Up @@ -1382,6 +1401,23 @@ mod test {
assert_eq!(CompilerKind::C(CCompilerKind::Nvcc), c.kind());
}

#[test]
fn test_detect_compiler_kind_nvhpc() {
let f = TestFixture::new();
let creator = new_creator();
let runtime = single_threaded_runtime();
let pool = runtime.handle();
next_command(
&creator,
Ok(MockChild::new(exit_status(0), "compiler_id=nvhpc\n", "")),
);
let c = detect_compiler(creator, &f.bins[0], f.tempdir.path(), &[], &[], pool, None)
.wait()
.unwrap()
.0;
assert_eq!(CompilerKind::C(CCompilerKind::Nvhpc), c.kind());
}

#[test]
fn test_detect_compiler_kind_rustc() {
let f = TestFixture::new();
Expand Down
1 change: 1 addition & 0 deletions src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod diab;
mod gcc;
mod msvc;
mod nvcc;
mod nvhpc;
mod rust;
mod tasking_vx;
#[macro_use]
Expand Down
Loading

0 comments on commit 4aff489

Please sign in to comment.