[clang] [HIP][Driver] Automatically include `hipstdpar` forwarding header (PR #78915)
https://github.com/AlexVlx closed https://github.com/llvm/llvm-project/pull/78915 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HIP][Driver] Automatically include `hipstdpar` forwarding header (PR #78915)
https://github.com/yxsamliu approved this pull request. https://github.com/llvm/llvm-project/pull/78915 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HIP][Driver] Automatically include `hipstdpar` forwarding header (PR #78915)
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/78915 >From 37453ff13fd7a61f2072069cf94615497c748089 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Sun, 21 Jan 2024 21:52:52 + Subject: [PATCH 1/2] Add automated inclusion for the forwarding header packaged with `rocThrust`. --- clang/lib/Driver/ToolChains/AMDGPU.cpp | 25 + clang/test/Driver/hipstdpar.c | 3 ++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 56f06fc5fccb7eb..8a88dba562c8c02 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -545,26 +545,35 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, } const auto HandleHipStdPar = [=, &DriverArgs, &CC1Args]() { -if (!hasHIPStdParLibrary()) { +StringRef Inc = getIncludePath(); +auto &FS = D.getVFS(); + +if (!hasHIPStdParLibrary()) + if (!HIPStdParPathArg.empty() || + !FS.exists(Inc + "/thrust/system/hip/hipstdpar/hipstdpar_lib.hpp")) { D.Diag(diag::err_drv_no_hipstdpar_lib); return; } -if (!HasRocThrustLibrary && -!D.getVFS().exists(getIncludePath() + "/thrust")) { +if (!HasRocThrustLibrary && !FS.exists(Inc + "/thrust")) { D.Diag(diag::err_drv_no_hipstdpar_thrust_lib); return; } -if (!HasRocPrimLibrary && -!D.getVFS().exists(getIncludePath() + "/rocprim")) { +if (!HasRocPrimLibrary && !FS.exists(Inc + "/rocprim")) { D.Diag(diag::err_drv_no_hipstdpar_prim_lib); return; } - const char *ThrustPath; if (HasRocThrustLibrary) ThrustPath = DriverArgs.MakeArgString(HIPRocThrustPathArg); else - ThrustPath = DriverArgs.MakeArgString(getIncludePath() + "/thrust"); + ThrustPath = DriverArgs.MakeArgString(Inc + "/thrust"); + +const char *HIPStdParPath; +if (hasHIPStdParLibrary()) + HIPStdParPath = DriverArgs.MakeArgString(HIPStdParPathArg); +else + HIPStdParPath = DriverArgs.MakeArgString(StringRef(ThrustPath) + + "/system/hip/hipstdpar"); const char *PrimPath; if (HasRocPrimLibrary) @@ -573,7 +582,7 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, PrimPath = DriverArgs.MakeArgString(getIncludePath() + "/rocprim"); CC1Args.append({"-idirafter", ThrustPath, "-idirafter", PrimPath, -"-idirafter", DriverArgs.MakeArgString(HIPStdParPathArg), +"-idirafter", HIPStdParPath, "-include", "hipstdpar_lib.hpp"}); }; diff --git a/clang/test/Driver/hipstdpar.c b/clang/test/Driver/hipstdpar.c index 69c5b177d170cd8..2f48bf6b5cf1ebd 100644 --- a/clang/test/Driver/hipstdpar.c +++ b/clang/test/Driver/hipstdpar.c @@ -5,7 +5,8 @@ // XFAIL: target={{.*}}-scei{{.*}} // XFAIL: target={{.*}}-sie{{.*}} -// RUN: not %clang -### --hipstdpar -nogpulib -nogpuinc --compile %s 2>&1 | \ +// RUN: not %clang -### --hipstdpar --hipstdpar-path=/does/not/exist -nogpulib \ +// RUN: -nogpuinc --compile %s 2>&1 | \ // RUN: FileCheck --check-prefix=HIPSTDPAR-MISSING-LIB %s // RUN: %clang -### --hipstdpar --hipstdpar-path=%S/Inputs/hipstdpar \ // RUN: --hipstdpar-thrust-path=%S/Inputs/hipstdpar/thrust \ >From b4ad26f6213aec78adcac302ee915420eebc4c16 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Sun, 21 Jan 2024 22:04:12 + Subject: [PATCH 2/2] Fix formatting. --- clang/lib/Driver/ToolChains/AMDGPU.cpp | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 8a88dba562c8c02..b3c9d5908654f6a 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -551,9 +551,9 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, if (!hasHIPStdParLibrary()) if (!HIPStdParPathArg.empty() || !FS.exists(Inc + "/thrust/system/hip/hipstdpar/hipstdpar_lib.hpp")) { - D.Diag(diag::err_drv_no_hipstdpar_lib); - return; -} +D.Diag(diag::err_drv_no_hipstdpar_lib); +return; + } if (!HasRocThrustLibrary && !FS.exists(Inc + "/thrust")) { D.Diag(diag::err_drv_no_hipstdpar_thrust_lib); return; @@ -582,8 +582,8 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, PrimPath = DriverArgs.MakeArgString(getIncludePath() + "/rocprim"); CC1Args.append({"-idirafter", ThrustPath, "-idirafter", PrimPath, -"-idirafter", HIPStdParPath, -"-include", "hipstdpar_lib.hpp"}); +"-idirafter", HIPStdParPath, "-include", +"hipstdpar_lib.hpp"}); }; if (DriverArgs.hasArg(options::OPT_nogpuinc)) { __
[clang] [HIP][Driver] Automatically include `hipstdpar` forwarding header (PR #78915)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 5518a9d7673bfe55b4110bea049140316d032fbf 37453ff13fd7a61f2072069cf94615497c748089 -- clang/lib/Driver/ToolChains/AMDGPU.cpp clang/test/Driver/hipstdpar.c `` View the diff from clang-format here. ``diff diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 8a88dba562..b3c9d59086 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -551,9 +551,9 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, if (!hasHIPStdParLibrary()) if (!HIPStdParPathArg.empty() || !FS.exists(Inc + "/thrust/system/hip/hipstdpar/hipstdpar_lib.hpp")) { - D.Diag(diag::err_drv_no_hipstdpar_lib); - return; -} +D.Diag(diag::err_drv_no_hipstdpar_lib); +return; + } if (!HasRocThrustLibrary && !FS.exists(Inc + "/thrust")) { D.Diag(diag::err_drv_no_hipstdpar_thrust_lib); return; @@ -582,8 +582,8 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, PrimPath = DriverArgs.MakeArgString(getIncludePath() + "/rocprim"); CC1Args.append({"-idirafter", ThrustPath, "-idirafter", PrimPath, -"-idirafter", HIPStdParPath, -"-include", "hipstdpar_lib.hpp"}); +"-idirafter", HIPStdParPath, "-include", +"hipstdpar_lib.hpp"}); }; if (DriverArgs.hasArg(options::OPT_nogpuinc)) { `` https://github.com/llvm/llvm-project/pull/78915 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HIP][Driver] Automatically include `hipstdpar` forwarding header (PR #78915)
llvmbot wrote: @llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: Alex Voicu (AlexVlx) Changes The forwarding header used by `hipstdpar` on AMDGPU targets is now pacakged with `rocThrust`. This change augments the ROCm Driver component so that it can automatically pick up the packaged header iff the user hasn't overridden it via the dedicated flag. --- Full diff: https://github.com/llvm/llvm-project/pull/78915.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/AMDGPU.cpp (+17-8) - (modified) clang/test/Driver/hipstdpar.c (+2-1) ``diff diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 56f06fc5fccb7e..8a88dba562c8c0 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -545,26 +545,35 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, } const auto HandleHipStdPar = [=, &DriverArgs, &CC1Args]() { -if (!hasHIPStdParLibrary()) { +StringRef Inc = getIncludePath(); +auto &FS = D.getVFS(); + +if (!hasHIPStdParLibrary()) + if (!HIPStdParPathArg.empty() || + !FS.exists(Inc + "/thrust/system/hip/hipstdpar/hipstdpar_lib.hpp")) { D.Diag(diag::err_drv_no_hipstdpar_lib); return; } -if (!HasRocThrustLibrary && -!D.getVFS().exists(getIncludePath() + "/thrust")) { +if (!HasRocThrustLibrary && !FS.exists(Inc + "/thrust")) { D.Diag(diag::err_drv_no_hipstdpar_thrust_lib); return; } -if (!HasRocPrimLibrary && -!D.getVFS().exists(getIncludePath() + "/rocprim")) { +if (!HasRocPrimLibrary && !FS.exists(Inc + "/rocprim")) { D.Diag(diag::err_drv_no_hipstdpar_prim_lib); return; } - const char *ThrustPath; if (HasRocThrustLibrary) ThrustPath = DriverArgs.MakeArgString(HIPRocThrustPathArg); else - ThrustPath = DriverArgs.MakeArgString(getIncludePath() + "/thrust"); + ThrustPath = DriverArgs.MakeArgString(Inc + "/thrust"); + +const char *HIPStdParPath; +if (hasHIPStdParLibrary()) + HIPStdParPath = DriverArgs.MakeArgString(HIPStdParPathArg); +else + HIPStdParPath = DriverArgs.MakeArgString(StringRef(ThrustPath) + + "/system/hip/hipstdpar"); const char *PrimPath; if (HasRocPrimLibrary) @@ -573,7 +582,7 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, PrimPath = DriverArgs.MakeArgString(getIncludePath() + "/rocprim"); CC1Args.append({"-idirafter", ThrustPath, "-idirafter", PrimPath, -"-idirafter", DriverArgs.MakeArgString(HIPStdParPathArg), +"-idirafter", HIPStdParPath, "-include", "hipstdpar_lib.hpp"}); }; diff --git a/clang/test/Driver/hipstdpar.c b/clang/test/Driver/hipstdpar.c index 69c5b177d170cd..2f48bf6b5cf1eb 100644 --- a/clang/test/Driver/hipstdpar.c +++ b/clang/test/Driver/hipstdpar.c @@ -5,7 +5,8 @@ // XFAIL: target={{.*}}-scei{{.*}} // XFAIL: target={{.*}}-sie{{.*}} -// RUN: not %clang -### --hipstdpar -nogpulib -nogpuinc --compile %s 2>&1 | \ +// RUN: not %clang -### --hipstdpar --hipstdpar-path=/does/not/exist -nogpulib \ +// RUN: -nogpuinc --compile %s 2>&1 | \ // RUN: FileCheck --check-prefix=HIPSTDPAR-MISSING-LIB %s // RUN: %clang -### --hipstdpar --hipstdpar-path=%S/Inputs/hipstdpar \ // RUN: --hipstdpar-thrust-path=%S/Inputs/hipstdpar/thrust \ `` https://github.com/llvm/llvm-project/pull/78915 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HIP][Driver] Automatically include `hipstdpar` forwarding header (PR #78915)
https://github.com/AlexVlx created https://github.com/llvm/llvm-project/pull/78915 The forwarding header used by `hipstdpar` on AMDGPU targets is now pacakged with `rocThrust`. This change augments the ROCm Driver component so that it can automatically pick up the packaged header iff the user hasn't overridden it via the dedicated flag. >From 37453ff13fd7a61f2072069cf94615497c748089 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Sun, 21 Jan 2024 21:52:52 + Subject: [PATCH] Add automated inclusion for the forwarding header packaged with `rocThrust`. --- clang/lib/Driver/ToolChains/AMDGPU.cpp | 25 + clang/test/Driver/hipstdpar.c | 3 ++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 56f06fc5fccb7e..8a88dba562c8c0 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -545,26 +545,35 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, } const auto HandleHipStdPar = [=, &DriverArgs, &CC1Args]() { -if (!hasHIPStdParLibrary()) { +StringRef Inc = getIncludePath(); +auto &FS = D.getVFS(); + +if (!hasHIPStdParLibrary()) + if (!HIPStdParPathArg.empty() || + !FS.exists(Inc + "/thrust/system/hip/hipstdpar/hipstdpar_lib.hpp")) { D.Diag(diag::err_drv_no_hipstdpar_lib); return; } -if (!HasRocThrustLibrary && -!D.getVFS().exists(getIncludePath() + "/thrust")) { +if (!HasRocThrustLibrary && !FS.exists(Inc + "/thrust")) { D.Diag(diag::err_drv_no_hipstdpar_thrust_lib); return; } -if (!HasRocPrimLibrary && -!D.getVFS().exists(getIncludePath() + "/rocprim")) { +if (!HasRocPrimLibrary && !FS.exists(Inc + "/rocprim")) { D.Diag(diag::err_drv_no_hipstdpar_prim_lib); return; } - const char *ThrustPath; if (HasRocThrustLibrary) ThrustPath = DriverArgs.MakeArgString(HIPRocThrustPathArg); else - ThrustPath = DriverArgs.MakeArgString(getIncludePath() + "/thrust"); + ThrustPath = DriverArgs.MakeArgString(Inc + "/thrust"); + +const char *HIPStdParPath; +if (hasHIPStdParLibrary()) + HIPStdParPath = DriverArgs.MakeArgString(HIPStdParPathArg); +else + HIPStdParPath = DriverArgs.MakeArgString(StringRef(ThrustPath) + + "/system/hip/hipstdpar"); const char *PrimPath; if (HasRocPrimLibrary) @@ -573,7 +582,7 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, PrimPath = DriverArgs.MakeArgString(getIncludePath() + "/rocprim"); CC1Args.append({"-idirafter", ThrustPath, "-idirafter", PrimPath, -"-idirafter", DriverArgs.MakeArgString(HIPStdParPathArg), +"-idirafter", HIPStdParPath, "-include", "hipstdpar_lib.hpp"}); }; diff --git a/clang/test/Driver/hipstdpar.c b/clang/test/Driver/hipstdpar.c index 69c5b177d170cd..2f48bf6b5cf1eb 100644 --- a/clang/test/Driver/hipstdpar.c +++ b/clang/test/Driver/hipstdpar.c @@ -5,7 +5,8 @@ // XFAIL: target={{.*}}-scei{{.*}} // XFAIL: target={{.*}}-sie{{.*}} -// RUN: not %clang -### --hipstdpar -nogpulib -nogpuinc --compile %s 2>&1 | \ +// RUN: not %clang -### --hipstdpar --hipstdpar-path=/does/not/exist -nogpulib \ +// RUN: -nogpuinc --compile %s 2>&1 | \ // RUN: FileCheck --check-prefix=HIPSTDPAR-MISSING-LIB %s // RUN: %clang -### --hipstdpar --hipstdpar-path=%S/Inputs/hipstdpar \ // RUN: --hipstdpar-thrust-path=%S/Inputs/hipstdpar/thrust \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits