Skip to content

Fine tune SYCL RTC's resource.cpp generation #20275

@aelovikov-intel

Description

@aelovikov-intel

add_custom_command(
OUTPUT ${SYCL_JIT_RESOURCE_CPP}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py --toolchain-dir ${CMAKE_BINARY_DIR} --output ${SYCL_JIT_RESOURCE_CPP} --prefix ${SYCL_JIT_VIRTUAL_TOOLCHAIN_ROOT}
DEPENDS
${SYCL_JIT_RESOURCE_DEPS}

that only depends on

set(SYCL_JIT_RESOURCE_DEPS
sycl-headers # include/sycl
clang # lib/clang/N/include
${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py)
if ("libclc" IN_LIST LLVM_ENABLE_PROJECTS)
# Somehow just "libclc" doesn't build "remangled-*" (and maybe whatever else).
list(APPEND SYCL_JIT_RESOURCE_DEPS libclc libspirv-builtins) # lib/clc/*.bc
endif()
if ("libdevice" IN_LIST LLVM_ENABLE_PROJECTS)
list(APPEND SYCL_JIT_RESOURCE_DEPS libsycldevice) # lib/*.bc
endif()

However, generate.py just blindly captures everything in build/lib/clang/**:

def process_dir(dir):
for root, _, files in os.walk(dir):
for file in files:
file_path = os.path.join(root, file)
process_file(file_path)
process_dir(os.path.join(args.toolchain_dir, "include/"))
process_dir(os.path.join(args.toolchain_dir, "lib/clang/"))
process_dir(os.path.join(args.toolchain_dir, "lib/clc/"))

which causes two types of issues:

  • We distribute more than we necessarily need/want
  • Flaky build errors. The way output files are created is often such that in-progress writes happen to a temporary file that is later renamed once all the writes finish. If that file is created by a project/runtime we don't depend on, then resource.cpp might capture that temp file that won't be available by the time resource.cpp is being built, failing at the corresponding #embed directive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions