From: Paul Fultz II Date: Mon, 21 Sep 2020 18:38:55 +0000 (-0500) Subject: Add support for hip language (#666) X-Git-Tag: v4.0~84 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a8d2b6cf3dc84d92c59220806d7502b9e5ab4c16;p=thirdparty%2Fccache.git Add support for hip language (#666) --- diff --git a/src/ccache.cpp b/src/ccache.cpp index 088c78426..441ab2fb7 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -1017,9 +1017,14 @@ get_result_name_from_cpp(Context& ctx, Args& args, Hash& hash) size_t args_added = 2; args.push_back("-E"); + if (ctx.args_info.actual_language == "hip") { + args.push_back("-o"); + args.push_back("-"); + args_added += 2; + } if (ctx.config.keep_comments_cpp()) { args.push_back("-C"); - args_added = 3; + args_added++; } args.push_back(ctx.args_info.input_file); add_prefix(ctx, args, ctx.config.prefix_command_cpp()); diff --git a/src/language.cpp b/src/language.cpp index 1b4955dc0..70325eaed 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -68,6 +68,7 @@ const struct {".tcc", "c++-header"}, {".TCC", "c++-header"}, {".cu", "cu"}, + {".hip", "hip"}, {nullptr, nullptr}, }; @@ -84,6 +85,7 @@ const struct {"c++-cpp-output", "c++-cpp-output"}, {"c++-header", "c++-cpp-output"}, {"cu", "cpp-output"}, + {"hip", "cpp-output"}, {"objective-c", "objective-c-cpp-output"}, {"objective-c-header", "objective-c-cpp-output"}, {"objc-cpp-output", "objective-c-cpp-output"}, diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8b6c015ee..3f5527050 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -44,6 +44,7 @@ addtest(debug_prefix_map) addtest(profiling) addtest(profiling_gcc) addtest(profiling_clang) +addtest(profiling_hip_clang) addtest(split_dwarf) addtest(masquerading) addtest(hardlink) diff --git a/test/suites/profiling_hip_clang.bash b/test/suites/profiling_hip_clang.bash new file mode 100644 index 000000000..0ca00d85a --- /dev/null +++ b/test/suites/profiling_hip_clang.bash @@ -0,0 +1,55 @@ +SUITE_profiling_hip_clang_PROBE() { + if ! $COMPILER_TYPE_CLANG; then + echo "compiler is not Clang" + elif ! echo | $COMPILER -x hip --cuda-gpu-arch=gfx900 -nogpulib -c - > /dev/null; then + echo "Hip not supported" + fi +} + +SUITE_profiling_hip_clang_SETUP() { + echo 'int main(void) { return 0; }' >test1.hip + echo 'int main(void) { int x = 0+0; return 0; }' >test2.hip + unset CCACHE_NODIRECT +} + +SUITE_profiling_hip_clang() { + # ------------------------------------------------------------------------- + TEST "hip-clang" + + hip_opts="-x hip --cuda-gpu-arch=gfx900 -nogpulib" + + $CCACHE_COMPILE $hip_opts -c test1.hip + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache miss' 1 + + $CCACHE_COMPILE $hip_opts -c test1.hip + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache miss' 1 + + $CCACHE_COMPILE $hip_opts --cuda-gpu-arch=gfx906 -c test1.hip + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache miss' 2 + + $CCACHE_COMPILE $hip_opts -c test2.hip + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache miss' 3 + + $CCACHE_COMPILE $hip_opts -c test2.hip + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache miss' 3 + + $CCACHE_COMPILE $hip_opts -Dx=x -c test2.hip + expect_stat 'cache hit (preprocessed)' 1 + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache miss' 3 + + $CCACHE_COMPILE $hip_opts -Dx=y -c test2.hip + expect_stat 'cache hit (preprocessed)' 1 + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache miss' 4 +}