Skip to content

Commit eec1f03

Browse files
author
anikelal
committed
[Driver][HIP] Do not pass -dependency-file flag for HIP Device offloading
When we launch hipcc with multiple offload architectures along with -MF dep_file flag, the clang compilation invocations for host and device offloads write to the same dep_file, and can lead to collision during file IO operations. This can typically happen during large workloads. This commit provides a fix to generate dep_file only in host compilation.
1 parent 6f32d5e commit eec1f03

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,21 +1013,23 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
10131013
ArgM = ArgMD;
10141014

10151015
if (ArgM) {
1016-
// Determine the output location.
1017-
const char *DepFile;
1018-
if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
1019-
DepFile = MF->getValue();
1020-
C.addFailureResultFile(DepFile, &JA);
1021-
} else if (Output.getType() == types::TY_Dependencies) {
1022-
DepFile = Output.getFilename();
1023-
} else if (!ArgMD) {
1024-
DepFile = "-";
1025-
} else {
1026-
DepFile = getDependencyFileName(Args, Inputs);
1027-
C.addFailureResultFile(DepFile, &JA);
1016+
if (!JA.isDeviceOffloading(Action::OFK_HIP)) {
1017+
// Determine the output location.
1018+
const char *DepFile;
1019+
if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
1020+
DepFile = MF->getValue();
1021+
C.addFailureResultFile(DepFile, &JA);
1022+
} else if (Output.getType() == types::TY_Dependencies) {
1023+
DepFile = Output.getFilename();
1024+
} else if (!ArgMD) {
1025+
DepFile = "-";
1026+
} else {
1027+
DepFile = getDependencyFileName(Args, Inputs);
1028+
C.addFailureResultFile(DepFile, &JA);
1029+
}
1030+
CmdArgs.push_back("-dependency-file");
1031+
CmdArgs.push_back(DepFile);
10281032
}
1029-
CmdArgs.push_back("-dependency-file");
1030-
CmdArgs.push_back(DepFile);
10311033

10321034
bool HasTarget = false;
10331035
for (const Arg *A : Args.filtered(options::OPT_MT, options::OPT_MQ)) {

0 commit comments

Comments
 (0)