Skip to content

Commit c6b5e64

Browse files
mdtoguchijsji
authored andcommitted
[Driver][SYCL] Improve diagnostic behaviors for intel_gpu targets
When using multiple targets, like -fsycl-targets=intel_gpu_pvc,intel_gpu_bdw, we were emitting a diagnostic that the latter value was being ignored as the values were similar. This is not a correct diagnostic, as the values have identical triples, but not an identical arch target. Update how these diagnostics are produced, depending on using the old or the new offloading model.
1 parent 090127d commit c6b5e64

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,14 +1396,28 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
13961396
} else
13971397
TT = getSYCLDeviceTriple(Triple);
13981398

1399-
std::string NormalizedName = TT.normalize();
1399+
// For the new offloading model, we only want a single triple entry
1400+
// for each target, even if we have multiple intel_gpu* entries. We
1401+
// will track triples for new model and unique strings for the old
1402+
// model.
1403+
std::string NormalizedName;
1404+
bool UseNewOffload =
1405+
(C.getArgs().hasFlag(options::OPT_offload_new_driver,
1406+
options::OPT_no_offload_new_driver, false));
1407+
NormalizedName = UseNewOffload
1408+
? TT.normalize()
1409+
: getSYCLDeviceTriple(Triple).normalize();
14001410

14011411
auto [TripleIt, Inserted] =
14021412
FoundNormalizedTriples.try_emplace(NormalizedName, Triple);
14031413

14041414
if (!Inserted) {
1405-
Diag(clang::diag::warn_drv_sycl_offload_target_duplicate)
1406-
<< Triple << TripleIt->second;
1415+
// Only emit the diagnostic of duplicate targets with the new
1416+
// offloading model only when the found triple matches. For the
1417+
// old model, we always emit the diagnostic.
1418+
if (!UseNewOffload || (UseNewOffload && Triple == TripleIt->second))
1419+
Diag(clang::diag::warn_drv_sycl_offload_target_duplicate)
1420+
<< Triple << TripleIt->second;
14071421
continue;
14081422
}
14091423

clang/test/Driver/sycl-offload-old-model.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@
7676
// RUN: | FileCheck -check-prefix=CHK-DUPLICATES %s
7777
// CHK-DUPLICATES: warning: SYCL offloading target 'spir64-unknown-unknown' is similar to target 'spir64-unknown-unknown' already specified; will be ignored
7878

79+
// RUN: %clang -### -ccc-print-phases -fsycl --no-offload-new-driver -fsycl-targets=intel_gpu_pvc,intel_gpu_pvc %s 2>&1 \
80+
// RUN: | FileCheck -check-prefix=CHK-DUPLICATES-GPU %s
81+
// CHK-DUPLICATES-GPU: warning: SYCL offloading target 'intel_gpu_pvc' is similar to target 'intel_gpu_pvc' already specified; will be ignored
82+
83+
/// No duplicate warning should be emitted for 'like' triples but different
84+
/// arch targets.
85+
// RUN: %clang -### -ccc-print-phases -fsycl --no-offload-new-driver -fsycl-targets=intel_gpu_pvc,intel_gpu_bdw %s 2>&1 \
86+
// RUN: | FileCheck -check-prefix=CHK-DIFF-GPU %s
87+
// CHK-DIFF-GPU-NOT: warning: SYCL offloading target 'intel_gpu_bdw' is similar to target 'intel_gpu_pvc' already specified; will be ignored
88+
7989
/// ###########################################################################
8090

8191
/// Check -Xsycl-target-frontend triggers error when multiple triples are used.

clang/test/Driver/sycl-offload.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@
8383
// RUN: | FileCheck -check-prefix=CHK-DUPLICATES %s
8484
// CHK-DUPLICATES: warning: SYCL offloading target 'spir64-unknown-unknown' is similar to target 'spir64-unknown-unknown' already specified; will be ignored
8585

86+
// RUN: %clang -### -ccc-print-phases -fsycl --offload-new-driver -fsycl-targets=intel_gpu_pvc,intel_gpu_pvc %s 2>&1 \
87+
// RUN: | FileCheck -check-prefix=CHK-DUPLICATES-GPU %s
88+
// CHK-DUPLICATES-GPU: warning: SYCL offloading target 'intel_gpu_pvc' is similar to target 'intel_gpu_pvc' already specified; will be ignored
89+
90+
/// No duplicate warning should be emitted for 'like' triples but different
91+
/// arch targets.
92+
// RUN: %clang -### -ccc-print-phases -fsycl --offload-new-driver -fsycl-targets=intel_gpu_pvc,intel_gpu_bdw %s 2>&1 \
93+
// RUN: | FileCheck -check-prefix=CHK-DIFF-GPU %s
94+
// CHK-DIFF-GPU-NOT: warning: SYCL offloading target 'intel_gpu_bdw' is similar to target 'intel_gpu_pvc' already specified; will be ignored
95+
8696
/// ###########################################################################
8797

8898
/// Check -Xsycl-target-frontend triggers error when multiple triples are used.

0 commit comments

Comments
 (0)