-
Notifications
You must be signed in to change notification settings - Fork 791
[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
base: sycl
Are you sure you want to change the base?
Conversation
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
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.
questions/nits
| ) | ||
| endforeach() | ||
|
|
||
| add_custom_target(rtc-prepare-resources |
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_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?
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.
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
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-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.
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
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-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?
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.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.
sycl-jit/jit-compiler/CMakeLists.txt
Outdated
| 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} |
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.
nit: could we make rtc-resources-install into a variable so its not copy pasted here and in the loop defining it?
sycl-jit/jit-compiler/CMakeLists.txt
Outdated
| 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}" |
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.
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?
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.
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.
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.
lgtm with nit fixed
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 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) |
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.
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?
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.
Why we don't need to depends on OpenCL-Headers?
There is no such target, but I probably need to dig deeper still.
Fixes #20275
That way we achieve all of: