Skip to content

Commit 30ae902

Browse files
committed
Add SYCL config options
Signed-off-by: Lukas Sommer <lukas.sommer@codeplay.com>
1 parent b6dbf1f commit 30ae902

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

torch/_inductor/codecache.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3200,22 +3200,29 @@ def _sycl_lib_options() -> list[str]:
32003200

32013201

32023202
def _dpcpp_compiler_options() -> list[str]:
3203-
# TODO Select device target architecture based on environment.
3203+
# TODO: Automatically detect device architecture.
3204+
arch = f"intel_gpu_{config.sycl.arch}" if config.sycl.arch is not None else "spir64"
32043205
options = [
32053206
"-fsycl",
32063207
"-std=c++17",
32073208
"-fPIC",
32083209
"-Xspirv-translator", "-spirv-ext=+SPV_INTEL_split_barrier",
32093210
"-fsycl-range-rounding=disable",
3210-
# TODO: Replace this with device-specific architecture.
3211-
"-fsycl-targets=spir64",
3211+
f"-fsycl-targets={arch}",
3212+
config.sycl.compile_opt_level,
32123213
"-DCUTLASS_ENABLE_SYCL",
32133214
"-DSYCL_INTEL_TARGET",
3214-
# TODO: Add optimization level.
32153215
]
32163216
# TODO: Add special case for FB?
3217-
# TODO: Add debug info handling.
3218-
# TODO: Add fast-math handling.
3217+
if config.sycl.enable_debug_info:
3218+
options.extend(["-g", "-DCUTLASS_DEBUG_TRACE_LEVEL=1"])
3219+
if config.sycl.use_fast_math:
3220+
options.extend(
3221+
[
3222+
"-ffast-math",
3223+
"-DCUTLASS_USE_TANH_FOR_SIGMOID=1",
3224+
]
3225+
)
32193226

32203227
return options
32213228

torch/_inductor/config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,22 @@ class rocm:
13941394
split_k_threshold: int = 16
13951395

13961396

1397+
class sycl:
1398+
# Intel GPU arch to use for SYCL template kernel compilation.
1399+
# e.g. "pvc", "bmg", etc.
1400+
# When arch is None, generates SPIR-V that is finalized at runtime.
1401+
arch: Optional[str] = None
1402+
1403+
# Optimization level for the host compiler.
1404+
compile_opt_level: Literal["-O0", "-O1", "-O2", "-O3", "-OS"] = "-O1"
1405+
1406+
# Whether to enable debug info, e.g. line number, cutlass debug info.
1407+
enable_debug_info = False
1408+
1409+
# Whether to use fast math.
1410+
use_fast_math = False
1411+
1412+
13971413
# Backend to use for CPU codegen either "cpp" or "triton" (experimental) or "halide" (experimental)
13981414
cpu_backend: Literal["cpp", "triton", "halide"] = "cpp"
13991415

0 commit comments

Comments
 (0)