|
| 1 | +find_package(CutlassSycl) |
| 2 | + |
| 3 | +if (NOT CutlassSycl_FOUND) |
| 4 | + set(CUTLASS_ENABLE_HEADERS_ONLY ON CACHE BOOL "Enable only the header library") |
| 5 | + set(CUTLASS_ENABLE_BENCHMARKS OFF CACHE BOOL "Disable CUTLASS Benchmarks") |
| 6 | + |
| 7 | +# Set CUTLASS_REVISION manually -- its revision detection doesn't work in this case. |
| 8 | + set(CUTLASS_REVISION "v{{ version }}" CACHE STRING "CUTLASS revision to use") |
| 9 | + |
| 10 | +# Use the specified CUTLASS source directory for compilation if CUTLASS_SYCL_SRC_DIR is provided |
| 11 | + if (DEFINED ENV{CUTLASS_SYCL_SRC_DIR}) |
| 12 | + set(CUTLASS_SYCL_SRC_DIR $ENV{CUTLASS_SYCL_SRC_DIR}) |
| 13 | + endif() |
| 14 | + |
| 15 | + if(CUTLASS_SYCL_SRC_DIR) |
| 16 | + if(NOT IS_ABSOLUTE CUTLASS_SYCL_SRC_DIR) |
| 17 | + get_filename_component(CUTLASS_SYCL_SRC_DIR "${CUTLASS_SYCL_SRC_DIR}" ABSOLUTE) |
| 18 | + endif() |
| 19 | + message(STATUS "The CUTLASS_SYCL_SRC_DIR is set, using ${CUTLASS_SYCL_SRC_DIR} for compilation") |
| 20 | + FetchContent_Declare(cutlass SOURCE_DIR ${CUTLASS_SYCL_SRC_DIR}) |
| 21 | + else() |
| 22 | + FetchContent_Declare( |
| 23 | + cutlass |
| 24 | + GIT_REPOSITORY https://github.com/intel/cutlass-sycl.git |
| 25 | + GIT_TAG ${CUTLASS_REVISION} |
| 26 | + GIT_PROGRESS TRUE |
| 27 | + |
| 28 | + # Speed up CUTLASS download by retrieving only the specified GIT_TAG instead of the history. |
| 29 | + # Important: If GIT_SHALLOW is enabled then GIT_TAG works only with branch names and tags. |
| 30 | + # So if the GIT_TAG above is updated to a commit hash, GIT_SHALLOW must be set to FALSE |
| 31 | + GIT_SHALLOW TRUE |
| 32 | + ) |
| 33 | + endif() |
| 34 | + |
| 35 | + # Set Intel backend env |
| 36 | + message(STATUS "Setting Intel GPU optimization env vars for Cutlass-SYCL") |
| 37 | + string(REPLACE "-fsycl-targets=spir64_gen,spir64" "-fsycl-targets=intel_gpu_pvc" sycl_link_flags "${sycl_link_flags}") |
| 38 | + string(REPLACE "-device pvc,xe-lpg,ats-m150" "" sycl_link_flags "${sycl_link_flags}") |
| 39 | + string(APPEND sycl_link_flags "-Xspirv-translator;-spirv-ext=+SPV_INTEL_split_barrier;") |
| 40 | + string(REPLACE "-fsycl-targets=spir64_gen,spir64" "-fsycl-targets=intel_gpu_pvc" sycl_flags "${sycl_flags}") |
| 41 | + |
| 42 | + set(CUTLASS_ENABLE_SYCL ON CACHE BOOL "Enable SYCL for CUTLASS") |
| 43 | + add_compile_definitions(CUTLASS_ENABLE_SYCL=1) |
| 44 | + set(DPCPP_SYCL_TARGET "intel_gpu_pvc" CACHE STRING "SYCL target for Intel GPU") |
| 45 | + add_compile_definitions(DPCPP_SYCL_TARGET=intel_gpu_pvc) |
| 46 | + set(SYCL_INTEL_TARGET ON CACHE BOOL "Enable SYCL for INTEL") |
| 47 | + add_compile_definitions(SYCL_INTEL_TARGET=1) |
| 48 | + |
| 49 | + set(ENV{SYCL_PROGRAM_COMPILE_OPTIONS} "-ze-opt-large-register-file") |
| 50 | + set(ENV{IGC_VISAOptions} "-perfmodel") |
| 51 | + set(ENV{IGC_VectorAliasBBThreshold} "10000") |
| 52 | + set(ENV{IGC_ExtraOCLOptions} "-cl-intel-256-GRF-per-thread") |
| 53 | + |
| 54 | + FetchContent_MakeAvailable(cutlass) |
| 55 | + |
| 56 | + include_directories(${CUTLASS_INCLUDE_DIR}) |
| 57 | + include_directories(${CUTLASS_TOOLS_UTIL_INCLUDE_DIR}) |
| 58 | +else() |
| 59 | + message(STATUS "Using system cutlass with version: ${CutlassSycl_VERSION}") |
| 60 | +endif(NOT CutlassSycl_FOUND) |
0 commit comments