-
Notifications
You must be signed in to change notification settings - Fork 791
[UR][Offload] Add option to build offload adapter #19864
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
Conversation
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.
configure.py
LGTM
UPDATE_COMMAND "" | ||
) | ||
# Build OpenMP runtime (required dependency for offload's libomptarget) from the cloned source | ||
ExternalProject_Add(openmp_ext |
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 are we not just using LLVM_ENABLE_RUNTIMES="offload;openmp"
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.
We’re not using LLVM_ENABLE_RUNTIMES="offload;openmp"
here because that mode requires configuring from the top-level llvm directory. In that flow, clang/llvm would be built as part of the runtimes build, which means clang/llvm ends up being built twice.
Instead, I build OpenMP and offload in standalone mode, reusing the existing clang/llvm build from intel/llvm.
Also, in the latest commit I improved this further: rather than cloning llvm-project again, I now create a git worktree from the already cloned intel/llvm repository, pulling in only the directories needed for the runtime build.
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 looked into this a while ago and figured out how to build openmp without a dependency on clang. It required a few patches, which I should really figure out who to harass about.
rather than cloning llvm-project again, I now create a git worktree from the already cloned intel/llvm repository
What if the runtimes are using a newer version of llvm-project that hasn't been pulled down into intel/llvm yet?
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.
Sorry if the statement was confusing, worktree is created from fresh enough hash specified in LLVM_PROJECT_TAG, i.e. assumption is that llvm-project remote and its main branch is visible in the cloned intel/llvm repo, i.e. just trying to avoid re-cloning what's already available.
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.
The issue I'm thinking of is with, for example the commit ee5022d63549032235247269903f6ccf7e70bd02
(which doesn't affect liboffload, but pretend it does). That commit exists on llvm/llvm-project, but not on intel/llvm at the time of writing (at the time of writing).
Although, there's a commit from 13 minutes ago on the main
branch, so it might get mirrored frequently enough that that's not an issue. How often does intel/llvm pull down new llvm/llvm-project changes?
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.
pulldowns approximately once per week/2weeks.
How dependent are openmp and offload from other components in llvm? I wonder why an option of standalone building mode even exists if those runtimes have to be built in-tree with entire llvm project of exact same version. If you believe openmp and offload are tightly coupled with the rest of llvm and has to be of exactly same version, then I can switch to what you propose - using LLVM_ENABLE_RUNTIMES="offload;openmp" i,e, re-building clang/llvm entirely from llvm-project.
Or we can try the current approach first for some time and switch to LLVM_ENABLE_RUNTIMES="offload;openmp" if there will be cases when build breaks because of such dependency.
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. Thanks for the sparse checkout.
set(UR_OFFLOAD_INSTALL_DIR ${CMAKE_BINARY_DIR}/offload-install) | ||
set(UR_OFFLOAD_INCLUDE_DIR ${UR_OFFLOAD_INSTALL_DIR}/include) | ||
|
||
execute_process(COMMAND git -C "${CMAKE_SOURCE_DIR}" worktree prune) |
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.
We have a helper for this:
https://github.com/intel/llvm/blob/sycl/unified-runtime/cmake/helpers.cmake#L246
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.
Thanks, I tried this, but the helper’s shallow checkout approach seems to work only with tags, and it becomes slow when used with commit hashes. So I am leaving this part as is for now if that's ok.
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.
looks correct
$ ./sycl-ls
[level_zero:gpu][level_zero:0] Intel(R) oneAPI Unified Runtime over Level-Zero, Intel(R) Graphics 12.70.4 [1.6.33944+13]
[offload:gpu][offload:0] CUDA, NVIDIA GeForce GTX 1060 6GB [12090]
[opencl:gpu][opencl:0] Intel(R) OpenCL Graphics, Intel(R) Graphics OpenCL 3.0 NEO [25.22.33944]
Failures are unrelated.
is supposed to be fixed by #19933
|
Add
--offload
option toconfigure.py
which allows to build UR offload adapter.Because offload API is under active development in llvm-project, we have to fetch specific version of LLVM and build offload runtime (and dependent openmp) using those sources.
Necessary to mention that offload/openmp runtimes are built in standalone mode using main compiler build, i.e. we don't build llvm twice.