Skip to content

Commit 62afb59

Browse files
authored
[ESIMD] Add driver option to control SYCL/ESIMD code splitting. (#6174)
This is needed to support invoke_simd processing in sycl-post-link. Signed-off-by: Konstantin S Bobrovsky [email protected]
1 parent 677e2e2 commit 62afb59

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,6 +2770,10 @@ def fsycl_device_code_split_EQ : Joined<["-"], "fsycl-device-code-split=">,
27702770
def fsycl_device_code_split : Flag<["-"], "fsycl-device-code-split">, Alias<fsycl_device_code_split_EQ>,
27712771
AliasArgs<["auto"]>, Flags<[CC1Option, CoreOption]>,
27722772
HelpText<"Perform SYCL device code split in the 'auto' mode, i.e. use heuristic to distribute device code across modules">;
2773+
def fsycl_device_code_split_esimd : Flag<["-"], "fsycl-device-code-split-esimd">,
2774+
Flags<[CoreOption]>, HelpText<"split ESIMD device code from SYCL into a separate device binary image (default). Has effect only for SPIR-based targets. (experimental)">;
2775+
def fno_sycl_device_code_split_esimd : Flag<["-"], "fno-sycl-device-code-split-esimd">,
2776+
Flags<[CoreOption]>, HelpText<"do not split ESIMD and SYCL device code into separate device binary images. Has effect only for SPIR-based targets. (experimental)">;
27732777
defm sycl_instrument_device_code
27742778
: BoolFOption<"sycl-instrument-device-code",
27752779
CodeGenOpts<"SPIRITTAnnotations">, DefaultFalse,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9382,11 +9382,16 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
93829382
addArgs(CmdArgs, TCArgs, {"-ir-output-only"});
93839383
} else {
93849384
assert(SYCLPostLink->getTrueType() == types::TY_Tempfiletable);
9385+
bool SplitEsimdByDefault = getToolChain().getTriple().isSPIR();
9386+
bool SplitEsimd = TCArgs.hasFlag(
9387+
options::OPT_fsycl_device_code_split_esimd,
9388+
options::OPT_fno_sycl_device_code_split_esimd, SplitEsimdByDefault);
93859389
// Symbol file and specialization constant info generation is mandatory -
93869390
// add options unconditionally
93879391
addArgs(CmdArgs, TCArgs, {"-symbols"});
93889392
addArgs(CmdArgs, TCArgs, {"-emit-exported-symbols"});
9389-
addArgs(CmdArgs, TCArgs, {"-split-esimd"});
9393+
if (SplitEsimd)
9394+
addArgs(CmdArgs, TCArgs, {"-split-esimd"});
93909395
addArgs(CmdArgs, TCArgs, {"-lower-esimd"});
93919396
}
93929397
addArgs(CmdArgs, TCArgs,

clang/test/Driver/sycl-offload-with-split.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,17 @@
338338
// RUN: %clang -### -fsycl -fsycl-targets=spir64_fpga-unknown-unknown %s 2>&1 | FileCheck %s -check-prefixes=CHK-ESIMD-LOWER
339339
// RUN: %clang_cl -### -fsycl -fintelfpga %s 2>&1 | FileCheck %s -check-prefixes=CHK-ESIMD-LOWER
340340
// CHK-ESIMD-LOWER: sycl-post-link{{.*}} "-lower-esimd"
341+
342+
// Check -f[no]sycl-device-code-split-esimd option's effect on sycl-post-link invocation
343+
// RUN: %clang -### -fsycl -fsycl-device-code-split-esimd %s 2>&1 \
344+
// RUN: | FileCheck %s -check-prefixes=CHK-ESIMD-SPLIT-ON
345+
// RUN: %clang -### -fsycl -fno-sycl-device-code-split-esimd %s 2>&1 \
346+
// RUN: | FileCheck %s -check-prefixes=CHK-ESIMD-SPLIT-OFF
347+
// RUN: %clang -### -fsycl %s 2>&1 \
348+
// RUN: | FileCheck %s -check-prefixes=CHK-ESIMD-SPLIT-DEFAULT
349+
// RUN: %clang -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda %s 2>&1 \
350+
// RUN: | FileCheck %s -check-prefixes=CHK-ESIMD-SPLIT-NON-SPIRV
351+
// CHK-ESIMD-SPLIT-ON: sycl-post-link{{.*}} "-split-esimd"{{.*}} "-o"{{.*}}
352+
// CHK-ESIMD-SPLIT-OFF-NOT: sycl-post-link{{.*}} "-split-esimd"{{.*}}
353+
// CHK-ESIMD-SPLIT-DEFAULT: sycl-post-link{{.*}} "-split-esimd"{{.*}} "-o"{{.*}}
354+
// CHK-ESIMD-SPLIT-NON-SPIRV-NOT: sycl-post-link{{.*}} "-split-esimd"{{.*}}

sycl/doc/UsersManual.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ and not recommended to use in production environment.
176176
* auto - the compiler will use a heuristic to select the best way of
177177
splitting device code. This is default mode.
178178

179+
**`-f[no-]sycl-device-code-split-esimd`** [EXPERIMENTAL]
180+
181+
Controls SYCL/ESIMD device code splitting. When enabled (this is the
182+
default), SYCL and ESIMD entry points along with their call graphs are
183+
put into separate device binary images. Otherwise, SYCL and ESIMD parts
184+
of the device code are kept in the same device binary image and get
185+
compiled by the Intel GPU compiler back end as a single module. This
186+
option has effect only for SPIR-based targets and apps containing ESIMD
187+
kernels.
188+
179189
**`-fsycl-max-parallel-link-jobs=<N>`**
180190

181191
Experimental feature. When specified, it informs the compiler

0 commit comments

Comments
 (0)