Skip to content

Fix assumption that ncc is installed on build system. #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 35 additions & 16 deletions clang/tools/nec-aurora-build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project("NEC Aurora Offloading Build Wrapper Tools" CXX)
endif()

# Set Clang and RVClang target compiler variables
if (CMAKE_BUILD_TYPE MATCHES RELEASE)
set(NECAURORA_TARGET_COMPILER_CLANG
"${CMAKE_INSTALL_PREFIX}/bin/clang"
CACHE
FILEPATH
"Path to clang used as VE target compiler")
set(NECAURORA_TARGET_COMPILER_RVCLANG
"${CMAKE_INSTALL_PREFIX}/bin/rvclang"
CACHE FILEPATH
"Path to rvclang used as VE target compiler")
else() # most likely there won't be an install step
set(NECAURORA_TARGET_COMPILER_CLANG
"${CMAKE_BINARY_DIR}/bin/clang"
CACHE
FILEPATH
"Path to clang used as VE target compiler")
set(NECAURORA_TARGET_COMPILER_RVCLANG
"${CMAKE_BINARY_DIR}/bin/rvclang"
CACHE FILEPATH
"Path to rvclang used as VE target compiler")
endif()

# Find NEC target compiler.
find_program(NECAURORA_TARGET_COMPILER_NCC
NAMES
Expand All @@ -13,29 +36,25 @@ find_program(NECAURORA_TARGET_COMPILER_NCC
PATHS
"/opt/nec/ve/bin/"
ENV PATH)

# It is okay if we do not find ncc, we can fallback to Clang or RVCLang and
# will handlle the missing ncc in code.
if (NECAURORA_TARGET_COMPILER_NCC)
set(TARGET_COMPILER_NCC "${NECAURORA_TARGET_COMPILER_NCC}")
set(TARGET_COMPILER_NCC "${NECAURORA_TARGET_COMPILER_NCC}")
set(NECAURORA_DEFAULT_TARGET_COMPILER
"ncc"
CACHE STRING
"Default target compiler for NEC OpenMP target (-fopenmp-nec-compiler=<this_value>)")
else()
message(WARNING "Could not find ncc compiler. ncc will not be available as VE target compiler")
set(TARGET_COMPILER_NCC "ncc") # We check whether it exists at runtime
set(NECAURORA_DEFAULT_TARGET_COMPILER
"${NECAURORA_TARGET_COMPILER_CLANG}"
CACHE STRING
"Default target compiler for NEC OpenMP target (-fopenmp-nec-compiler=<this_value>)")
message(WARNING "Could not find ncc compiler. ncc might not be available as VE target compiler")
endif()

# Set Clang and RVClang target compiler variables
set(NECAURORA_TARGET_COMPILER_CLANG
"${CMAKE_INSTALL_PREFIX}/bin/clang"
CACHE
FILEPATH
"Path to clang used as VE target compiler")
set(NECAURORA_TARGET_COMPILER_RVCLANG
"${CMAKE_INSTALL_PREFIX}/bin/rvclang"
CACHE FILEPATH
"Path to rvclang used as VE target compiler")

set(NECAURORA_DEFAULT_TARGET_COMPILER
"ncc"
CACHE STRING
"Default target compiler for NEC OpenMP target (-fopenmp-nec-compiler=<this_value>)")
message("OMPT for SX-Aurora: Using the default target compiler option \"${NECAURORA_DEFAULT_TARGET_COMPILER}\"" )

find_library(
Expand Down
15 changes: 11 additions & 4 deletions clang/tools/nec-aurora-build/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,28 @@ int configureTargetCompiler(const std::string& CompilerName) {
<< std::endl;

}
// We can assume the first two to exist
if (CompilerName == "clang") { CompilerCmd = ClangCompilerCmd; return 0; }
if (CompilerName == "rvclang") { CompilerCmd = RVClangCompilerCmd; return 0; }
if (CompilerName == "ncc") { CompilerCmd = NCCCompilerCmd; return 0; }
if (CompilerName == "ncc") {
CompilerCmd = NCCCompilerCmd;
auto ret = std::system((CompilerCmd + " --version").c_str());
if (ret == 0) {
return 0;
}
}
std::cerr << "nec-aurora-build: -fopenmp-nec-compiler=" << CompilerCmd
<< " not recognized"
<< " not recognized. Aborting."
<< std::endl;
return 1;
exit(EXIT_FAILURE); // it does not make any sense to continue here
}


const char *getTargetCompiler() {
// If no option was specified on the command line chose the builtin default
if (CompilerCmd.empty()) {
#ifndef DEFAULT_TARGET_COMPILER_OPTION
#error "DEFAULT_TARGET_COMPILER_OPTION not specified during build!"
#error "DEFAULT_TARGET_COMPILER_OPTION not specified during build!"
#endif
configureTargetCompiler(DEFAULT_TARGET_COMPILER_OPTION);
}
Expand Down