-
Couldn't load subscription status.
- Fork 794
[SYCL RTC] Use cmake --install for resource.cpp generation
#20466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c7597b7
73e9f6e
2b47019
ce42833
648c87a
7dc63ba
7598d3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,25 +9,50 @@ else() | |
| set(SYCL_JIT_VIRTUAL_TOOLCHAIN_ROOT "/sycl-jit-toolchain/") | ||
| endif() | ||
|
|
||
| set(SYCL_JIT_RESOURCE_DEPS | ||
| sycl-headers # include/sycl | ||
| clang # lib/clang/N/include | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py) | ||
| set(SYCL_JIT_RESOURCE_INSTALL_COMPONENTS sycl-headers OpenCL-Headers clang-resource-headers) | ||
|
|
||
| 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 | ||
| list(APPEND SYCL_JIT_RESOURCE_INSTALL_COMPONENTS libspirv-builtins) | ||
| endif() | ||
|
|
||
| if ("libdevice" IN_LIST LLVM_ENABLE_PROJECTS) | ||
| list(APPEND SYCL_JIT_RESOURCE_DEPS libsycldevice) # lib/*.bc | ||
| list(APPEND SYCL_JIT_RESOURCE_INSTALL_COMPONENTS libsycldevice) | ||
| endif() | ||
|
|
||
| set(SYCL_JIT_RESOURCE_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/rtc-resources-install) | ||
|
|
||
| set(SYCL_JIT_PREPARE_RESOURCE_COMMANDS) | ||
| foreach(component IN LISTS SYCL_JIT_RESOURCE_INSTALL_COMPONENTS) | ||
| list(APPEND SYCL_JIT_PREPARE_RESOURCE_COMMANDS | ||
| COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${SYCL_JIT_RESOURCE_INSTALL_DIR} --component "${component}" | ||
| ) | ||
| endforeach() | ||
|
|
||
| set(SYCL_JIT_RESOURCE_DEPS ${SYCL_JIT_RESOURCE_INSTALL_COMPONENTS}) | ||
| # OpenCL-Headers doesn't have a corresponding build target: | ||
| list(FILTER SYCL_JIT_RESOURCE_DEPS EXCLUDE REGEX "^OpenCL-Headers$") | ||
|
|
||
| # This is very hacky and I don't quite know what I'm doing, but it's necessary | ||
| # to have `resource.cpp` re-generated/re-built when some SYCL header changes. | ||
| # | ||
| # Inspired by the way `sycl-headers` target is created. | ||
| file(GLOB_RECURSE SYCL_JIT_RESOURCE_FILES CONFIGURE_DEPENDS "${SYCL_JIT_RESOURCE_INSTALL_DIR}/*" ) | ||
|
|
||
| add_custom_target(rtc-prepare-resources | ||
| DEPENDS ${SYCL_JIT_RESOURCE_DEPS} | ||
| ${SYCL_JIT_PREPARE_RESOURCE_COMMANDS} | ||
| BYPRODUCTS | ||
| ${SYCL_JIT_RESOURCE_FILES} | ||
| ) | ||
|
|
||
| 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 ${SYCL_JIT_RESOURCE_INSTALL_DIR} --output ${SYCL_JIT_RESOURCE_CPP} --prefix ${SYCL_JIT_VIRTUAL_TOOLCHAIN_ROOT} | ||
| DEPENDS | ||
| rtc-prepare-resources | ||
| ${SYCL_JIT_RESOURCE_DEPS} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to keep them to highlight that they aren't enough, i.e., just removing the BYPRODUCT files and keeping the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. |
||
| ${SYCL_JIT_RESOURCE_FILES} | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py | ||
| ) | ||
|
|
||
| # We use C23/C++26's `#embed` to implement this resource creation, and "current" | ||
|
|
@@ -67,6 +92,8 @@ add_custom_command( | |
| ${clang_exe} --target=${LLVM_HOST_TRIPLE} ${SYCL_JIT_RESOURCE_CPP} -I ${CMAKE_CURRENT_SOURCE_DIR}/include -c -o ${SYCL_JIT_RESOURCE_OBJ} ${SYCL_JIT_RESOURCE_CXX_FLAGS} | ||
| DEPENDS | ||
| ${SYCL_JIT_RESOURCE_CPP} | ||
| ${SYCL_JIT_RESOURCE_DEPS} | ||
| ${SYCL_JIT_RESOURCE_FILES} | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/include/Resource.h | ||
| ) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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_targetis 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?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure
No (at least IMO), and the incremental builds will output this:
instead of
There was a problem hiding this comment.
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-installafterresource.cppis generated so that we won't have stale files in there. In that case we'd even want to run it all the time.There was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the version of the file in that folder be regenerated if anyone makes a change to the file? Like someone modifies
sycl.hand rebuilds and at that point it will rerun theresource.cppgeneration in full because dependencysycl-headersor whatever changed right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating
sycl.hppworks 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.