Skip to content

Commit 907f2a0

Browse files
authored
[HIP][Driver] Automatically include hipstdpar forwarding header (llvm#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.
1 parent 58cfd56 commit 907f2a0

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -545,26 +545,35 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs,
545545
}
546546

547547
const auto HandleHipStdPar = [=, &DriverArgs, &CC1Args]() {
548-
if (!hasHIPStdParLibrary()) {
549-
D.Diag(diag::err_drv_no_hipstdpar_lib);
550-
return;
551-
}
552-
if (!HasRocThrustLibrary &&
553-
!D.getVFS().exists(getIncludePath() + "/thrust")) {
548+
StringRef Inc = getIncludePath();
549+
auto &FS = D.getVFS();
550+
551+
if (!hasHIPStdParLibrary())
552+
if (!HIPStdParPathArg.empty() ||
553+
!FS.exists(Inc + "/thrust/system/hip/hipstdpar/hipstdpar_lib.hpp")) {
554+
D.Diag(diag::err_drv_no_hipstdpar_lib);
555+
return;
556+
}
557+
if (!HasRocThrustLibrary && !FS.exists(Inc + "/thrust")) {
554558
D.Diag(diag::err_drv_no_hipstdpar_thrust_lib);
555559
return;
556560
}
557-
if (!HasRocPrimLibrary &&
558-
!D.getVFS().exists(getIncludePath() + "/rocprim")) {
561+
if (!HasRocPrimLibrary && !FS.exists(Inc + "/rocprim")) {
559562
D.Diag(diag::err_drv_no_hipstdpar_prim_lib);
560563
return;
561564
}
562-
563565
const char *ThrustPath;
564566
if (HasRocThrustLibrary)
565567
ThrustPath = DriverArgs.MakeArgString(HIPRocThrustPathArg);
566568
else
567-
ThrustPath = DriverArgs.MakeArgString(getIncludePath() + "/thrust");
569+
ThrustPath = DriverArgs.MakeArgString(Inc + "/thrust");
570+
571+
const char *HIPStdParPath;
572+
if (hasHIPStdParLibrary())
573+
HIPStdParPath = DriverArgs.MakeArgString(HIPStdParPathArg);
574+
else
575+
HIPStdParPath = DriverArgs.MakeArgString(StringRef(ThrustPath) +
576+
"/system/hip/hipstdpar");
568577

569578
const char *PrimPath;
570579
if (HasRocPrimLibrary)
@@ -573,8 +582,8 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs,
573582
PrimPath = DriverArgs.MakeArgString(getIncludePath() + "/rocprim");
574583

575584
CC1Args.append({"-idirafter", ThrustPath, "-idirafter", PrimPath,
576-
"-idirafter", DriverArgs.MakeArgString(HIPStdParPathArg),
577-
"-include", "hipstdpar_lib.hpp"});
585+
"-idirafter", HIPStdParPath, "-include",
586+
"hipstdpar_lib.hpp"});
578587
};
579588

580589
if (DriverArgs.hasArg(options::OPT_nogpuinc)) {

clang/test/Driver/hipstdpar.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// XFAIL: target={{.*}}-scei{{.*}}
66
// XFAIL: target={{.*}}-sie{{.*}}
77

8-
// RUN: not %clang -### --hipstdpar -nogpulib -nogpuinc --compile %s 2>&1 | \
8+
// RUN: not %clang -### --hipstdpar --hipstdpar-path=/does/not/exist -nogpulib \
9+
// RUN: -nogpuinc --compile %s 2>&1 | \
910
// RUN: FileCheck --check-prefix=HIPSTDPAR-MISSING-LIB %s
1011
// RUN: %clang -### --hipstdpar --hipstdpar-path=%S/Inputs/hipstdpar \
1112
// RUN: --hipstdpar-thrust-path=%S/Inputs/hipstdpar/thrust \

0 commit comments

Comments
 (0)