]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add support for hip language (#666)
authorPaul Fultz II <pfultz2@yahoo.com>
Mon, 21 Sep 2020 18:38:55 +0000 (13:38 -0500)
committerGitHub <noreply@github.com>
Mon, 21 Sep 2020 18:38:55 +0000 (20:38 +0200)
src/ccache.cpp
src/language.cpp
test/CMakeLists.txt
test/suites/profiling_hip_clang.bash [new file with mode: 0644]

index 088c78426cfcb9ff0e0b87e03685a0130cef7192..441ab2fb7bf10a048842b92ffdc8b7f6eb624f4d 100644 (file)
@@ -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());
index 1b4955dc021e0a6f7fcc48a55f1a2c01397e5000..70325eaed5135e1c0e89684a74d91dd7d4660855 100644 (file)
@@ -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"},
index 8b6c015ee429c67a14e4627e6ea9210945d84090..3f5527050a83994ee2ca14114a9040543e73a675 100644 (file)
@@ -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 (file)
index 0000000..0ca00d8
--- /dev/null
@@ -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
+}