Skip to content

Commit b1d600c

Browse files
author
Simon Moll
committed
Merge remote-tracking branch 'manorom/sotoc_offload_select_compiler' into feature/sotoc_offload
2 parents 11d48f2 + 2fd4a6d commit b1d600c

File tree

4 files changed

+46
-27
lines changed

4 files changed

+46
-27
lines changed

clang/tools/nec-aurora-build/CMakeLists.txt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
44
endif()
55

66
# Find NEC target compiler.
7-
find_program(NECAURORA_TARGET_COMPILER
7+
find_program(NECAURORA_TARGET_COMPILER_NCC
88
NAMES
99
ncc
1010
ncc-2.3.1
@@ -13,16 +13,26 @@ find_program(NECAURORA_TARGET_COMPILER
1313
PATHS
1414
"/opt/nec/ve/bin/"
1515
ENV PATH)
16-
17-
# if ncc was not found and gcc is not set stop
18-
if(NOT NECAURORA_TARGET_COMPILER AND NOT NECAURORA_TARGET_COMPILER_GCC)
19-
message(FATAL_ERROR "NEC target compiler not found and GCC not set, exiting.")
20-
# if ncc was not found vut gcc is set, use gcc
21-
elseif(NOT NECAURORA_TARGET_COMPILER)
22-
message(STATUS "NEC target compiler not found but GCC is set, using GCC.")
23-
set(NECAURORA_TARGET_COMPILER "${NECAURORA_TARGET_COMPILER_GCC}")
16+
# It is okay if we do not find ncc, we can fallback to Clang or RVCLang and
17+
# will handlle the missing ncc in code.
18+
if (NECAURORA_TARGET_COMPILER_NCC)
19+
set(TARGET_COMPILER_NCC "${NECAURORA_TARGET_COMPILER_NCC}")
20+
else()
21+
message(WARNING "Could not find ncc compiler. ncc will not be avaible as VE target compiler")
2422
endif()
2523

24+
# Set Clang and RVClang target compiler variables
25+
set(NECAURORA_TARGET_COMPILER_CLANG
26+
"${CMAKE_INSTALL_PREFIX}/bin/clang"
27+
CACHE
28+
FILEPATH
29+
"Path to clang used as VE target compiler")
30+
set(NECAURORA_TARGET_COMPILER_RVCLANG
31+
"${CMAKE_INSTALL_PREFIX}/bin/rvclang"
32+
CACHE FILEPATH
33+
"Path to rvclang used as VE target compiler")
34+
35+
2636
find_library(
2737
NECAURORA_LIBVEORUN_STATIC
2838
NAMES
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
#define DEFAULT_TARGET_COMPILER "@NECAURORA_TARGET_COMPILER@"
1+
#define TARGET_COMPILER_CLANG "@NECAURORA_TARGET_COMPILER_CLANG@"
2+
#define TARGET_COMPILER_RVCLANG "@NECAURORA_TARGET_COMPILER_RVCLANG@"
3+
#cmakedefine TARGET_COMPILER_NCC "@TARGET_COMPILER_NCC@"
4+
25
#cmakedefine LIBVEORUN_STATIC_PATH "@LIBVEORUN_STATIC_PATH@"

clang/tools/nec-aurora-build/utils.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,37 @@
88

99
#include "necaurora-ofld-wrapper.h"
1010

11-
const std::string ClangCompilerCmd = "clang --target=ve-linux";
12-
const std::string RVClangCompilerCmd = "rvclang --target=ve-linux";
13-
const std::string NCCCompilerCmd = "/opt/nec/ve/bin/ncc";
11+
const std::string ClangCompilerCmd = TARGET_COMPILER_CLANG " --target=ve-linux";
12+
const std::string RVClangCompilerCmd = TARGET_COMPILER_RVCLANG " --target=ve-linux";
13+
const std::string NCCCompilerCmd = TARGET_COMPILER_NCC;
1414

15-
std::string CompilerCmd;
15+
std::string CompilerCmd = ClangCompilerCmd;
1616

1717
int configureTargetCompiler(const std::string& CompilerName) {
18+
if (CompilerName.find("path:") == 0) {
19+
CompilerCmd = CompilerName.substr(5);
20+
//Small sanity check whether there is actually a path
21+
if (CompilerCmd.length() > 0) {
22+
return 0;
23+
}
24+
std::cerr << "nec-aurora-build: -fopenmp-nec-compiler=path: empty"
25+
<< std::endl;
26+
27+
}
1828
if (CompilerName == "clang") { CompilerCmd = ClangCompilerCmd; return 0; }
1929
if (CompilerName == "rvclang") { CompilerCmd = RVClangCompilerCmd; return 0; }
2030
if (CompilerName == "ncc") { CompilerCmd = NCCCompilerCmd; return 0; }
31+
std::cerr << "nec-aurora-build: -fopenmp-nec-compiler=" << CompilerCmd
32+
<< " not recognized"
33+
<< std::endl;
2134
return 1;
2235
}
2336

37+
38+
const char *getTargetCompiler() {
39+
return CompilerCmd.c_str();
40+
}
41+
2442
const char *getTmpDir() {
2543
const char *TmpDir = std::getenv("TMPDIR");
2644

@@ -39,18 +57,6 @@ const char *getTmpDir() {
3957
return TmpDir;
4058
}
4159

42-
const char *getTargetCompiler() {
43-
if (CompilerCmd.empty()) {
44-
const char *TargetCompiler = std::getenv("NECAURORA_OFLD_TARGET_COMPILER");
45-
if (!TargetCompiler) {
46-
TargetCompiler = DEFAULT_TARGET_COMPILER;
47-
}
48-
return TargetCompiler;
49-
}
50-
51-
return CompilerCmd.c_str();
52-
}
53-
5460
std::string writeTmpFile(const std::string &Content, const std::string &Prefix,
5561
const std::string &Extension, bool RealTmpfile) {
5662
std::string TmpPath;

clang/tools/sotoc/test/lit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ config.substitutions.append(('%sotoc-compile', \
7878
'%compiler %cflags %t.transformed.c -c -o %t.o'))
7979
config.substitutions.append(('%compile-for-target', \
8080
'%compiler -Xopenmp-target "--sotoc-path=%sotoc" \
81-
-fopenmp -fopenmp-targets=aurora-nec-veort-unknown %s -o %t.o'))
81+
-fopenmp -fopenmp-nec-compiler=ncc -fopenmp-targets=aurora-nec-veort-unknown %s -o %t.o'))
8282
config.substitutions.append(('%sotoc-library-compile',
8383
'%compiler -Xopenmp-target "--sotoc-path=%sotoc" -fopenmp \
8484
-fopenmp-targets=aurora-nec-veort-unknown -DIS_LIBRARY -shared \

0 commit comments

Comments
 (0)