Skip to content

Commit 8ab8cba

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

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
@@ -3347,22 +3347,29 @@ def _sycl_lib_options() -> list[str]:
33473347

33483348

33493349
def _dpcpp_compiler_options() -> list[str]:
3350-
# TODO Select device target architecture based on environment.
3350+
# TODO: Automatically detect device architecture.
3351+
arch = f"intel_gpu_{config.sycl.arch}" if config.sycl.arch is not None else "spir64"
33513352
options = [
33523353
"-fsycl",
33533354
"-std=c++17",
33543355
"-fPIC",
33553356
"-Xspirv-translator", "-spirv-ext=+SPV_INTEL_split_barrier",
33563357
"-fsycl-range-rounding=disable",
3357-
# TODO: Replace this with device-specific architecture.
3358-
"-fsycl-targets=spir64",
3358+
f"-fsycl-targets={arch}",
3359+
config.sycl.compile_opt_level,
33593360
"-DCUTLASS_ENABLE_SYCL",
33603361
"-DSYCL_INTEL_TARGET",
3361-
# TODO: Add optimization level.
33623362
]
33633363
# TODO: Add special case for FB?
3364-
# TODO: Add debug info handling.
3365-
# TODO: Add fast-math handling.
3364+
if config.sycl.enable_debug_info:
3365+
options.extend(["-g", "-DCUTLASS_DEBUG_TRACE_LEVEL=1"])
3366+
if config.sycl.use_fast_math:
3367+
options.extend(
3368+
[
3369+
"-ffast-math",
3370+
"-DCUTLASS_USE_TANH_FOR_SIGMOID=1",
3371+
]
3372+
)
33663373

33673374
return options
33683375

torch/_inductor/config.py

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

14041404

1405+
class sycl:
1406+
# Intel GPU arch to use for SYCL template kernel compilation.
1407+
# e.g. "pvc", "bmg", etc.
1408+
# When arch is None, generates SPIR-V that is finalized at runtime.
1409+
arch: Optional[str] = None
1410+
1411+
# Optimization level for the host compiler.
1412+
compile_opt_level: Literal["-O0", "-O1", "-O2", "-O3", "-OS"] = "-O1"
1413+
1414+
# Whether to enable debug info, e.g. line number, cutlass debug info.
1415+
enable_debug_info = False
1416+
1417+
# Whether to use fast math.
1418+
use_fast_math = False
1419+
1420+
14051421
# Backend to use for CPU codegen either "cpp" or "triton" (experimental) or "halide" (experimental)
14061422
cpu_backend: Literal["cpp", "triton", "halide"] = "cpp"
14071423

0 commit comments

Comments
 (0)