Skip to content

Conversation

@aelovikov-intel
Copy link
Contributor

Fixes #20275

That way we achieve all of:

  • Better "filtering" of what we need, as we don't operate at files/directories level anymore. Applies to both what we want to include and what we don't need (i.e., if provided by components we're not interested in)
  • Avoid race conditions with other targets creating temp files in the directories we take files from

Fixes intel#20275

That way we achieve all of:
* Better "filtering" of what we need, as we don't operate at
  files/directories level anymore. Applies to both what we want to
  include and what we don't need (i.e., if provided by components we're
  not interested in)
* Avoid race conditions with other targets creating temp files in the
  directories we take files from
@aelovikov-intel aelovikov-intel requested review from a team and cperkinsintel as code owners October 24, 2025 19:07
@aelovikov-intel aelovikov-intel added the run-perf-tests Run performance tests in pre-commit (normally part of post-commit only) label Oct 24, 2025
@aelovikov-intel
Copy link
Contributor Author

@sarnex, @jsj, added you as CMake experts.

Copy link
Contributor

@sarnex sarnex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

questions/nits

)
endforeach()

add_custom_target(rtc-prepare-resources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like add_custom_target is always considered out of date, so this will be run any time someone builds even if it's incremental. Is that a big deal? Is this expensive to run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that a big deal?

Not sure

Is this expensive to run?

No (at least IMO), and the incremental builds will output this:

-- Up-to-date: <root>/build/tools/sycl-jit/jit-compiler/rtc-resources-install/lib/libsycl-fallback-imf-fp64.o

instead of

-- Installing: <root>/build/tools/sycl-jit/jit-compiler/rtc-resources-install/lib/libsycl-fallback-imf-fp64.o

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also thinking about rm -rf rtc-resources-install after resource.cpp is generated so that we won't have stale files in there. In that case we'd even want to run it all the time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, it will just call the target which itself will determine it is up to date, so basically nothing happens and it's better than before IMO

Copy link
Contributor

@sarnex sarnex Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also thinking about rm -rf rtc-resources-install after resource.cpp is generated so that we won't have stale files in there. In that case we'd even want to run it all the time.

Wouldn't the version of the file in that folder be regenerated if anyone makes a change to the file? Like someone modifies sycl.h and rebuilds and at that point it will rerun the resource.cpp generation in full because dependency sycl-headers or whatever changed right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating sycl.hpp works with this version (AFAIK), I was thinking about deleting it. But, to be fair, we have that problem everywhere else, so probably no reason to address here.

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}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py --toolchain-dir ${CMAKE_CURRENT_BINARY_DIR}/rtc-resources-install --output ${SYCL_JIT_RESOURCE_CPP} --prefix ${SYCL_JIT_VIRTUAL_TOOLCHAIN_ROOT}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could we make rtc-resources-install into a variable so its not copy pasted here and in the loop defining it?

set(ALL_RTC_PREPARE_RESOURCES_COMMANDS)
foreach(component IN LISTS SYCL_JIT_RESOURCE_INSTALL_COMPONENTS)
list(APPEND ALL_RTC_PREPARE_RESOURCES_COMMANDS
COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${CMAKE_CURRENT_BINARY_DIR}/rtc-resources-install --component "${component}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the idea here is we re-install all these components into a new rtc-resources-install subfolder and then run that script to embed them into something, and we need to do the separate install because using the actual installed files runs into race conditions because files are moved around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, except that before this PR we weren't even installing - just taking from the build directly.

Also, race is only one issue, better control of what's in there is beneficial on its own.

Copy link
Contributor

@sarnex sarnex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with nit fixed

Copy link
Contributor

@jsji jsji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of using cmake component install. Thanks!

sycl-headers # include/sycl
clang # lib/clang/N/include
${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py)
set(SYCL_JIT_RESOURCE_DEPS sycl-headers clang)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we don't need to depends on OpenCL-Headers?
Also do we need to depends on clang just for clang-resource-headers?

If we can depend on all the components to be installed, then we can just maintain one list instead two lists here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we don't need to depends on OpenCL-Headers?

There is no such target, but I probably need to dig deeper still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-perf-tests Run performance tests in pre-commit (normally part of post-commit only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fine tune SYCL RTC's resource.cpp generation

3 participants