-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Libomptarget] Output the DeviceRTL alongside the other libraries #73705
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
set_target_properties(omptarget.devicertl PROPERTIES LINKER_LANGUAGE CXX) | ||
set_target_properties(omptarget.devicertl PROPERTIES | ||
LINKER_LANGUAGE CXX | ||
ARCHIVE_OUTPUT_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR} |
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.
Will this break standalone 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 was thinking about that and wasn't sure. As far as I can tell, add_llvm_library
uses this string internally, which is how libomptarget
ends up where it does. So I'm thinking so long as we're using that, it will be defined somewhere. But I haven't tested it or anything.
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 guess that's because install(TARGETS omptarget.devicertl ARCHIVE DESTINATION ${OPENMP_INSTALL_LIBDIR})
overrides it, which is what we need; otherwise it will be installed into where LLVM is installed, which is not right if build standalone.
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 could change it to only do this if it's standalone, should probably be fine.
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.
Can we build the DeviceRTL standalone? Do we want to support that?
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 guess theoretically? I've never heard of anyone doing it though. It should ideally just require an up-to-date clang
compiler and an LLVM installation.
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 constantly using standalone 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.
Can you test this then? Not really sure what the expected output would be. I guess the issue happens with tests, but do we even support tests out of tree?
@@ -304,4 +304,10 @@ add_library(omptarget.devicertl STATIC) | |||
set_target_properties(omptarget.devicertl PROPERTIES LINKER_LANGUAGE CXX) | |||
target_link_libraries(omptarget.devicertl PRIVATE omptarget.devicertl.all_objs) | |||
|
|||
# Install this alongside the LLVM libraries is possible. | |||
if(NOT OPENMP_STANDALONE_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 think this may break standalone build, especially with the changes in lit.cfg
.
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 still not sure if this is even an issue, considering we use add_llvm_library
which already uses this value internally and does the same operation to set its output directory.
openmp/libomptarget/test/lit.cfg
Outdated
config.library_dir + "/libomptarget.devicertl.a" | ||
return source + " " + config.library_dir + "/libomptarget.devicertl.a" | ||
config.llvm_library_dir + "/libomptarget.devicertl.a" | ||
return source + " " + config.llvm_library_dir + "/libomptarget.devicertl.a" |
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.
But this change can affect both right? In standalone build, I think it is still config.library_dir
instead of config.llvm_library_dir
.
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.
In the general case, AFAICT both the standalone and LLVM build just default to ./lib
as their output, so it'll succeed superficially. If we want to be sure I could manually set the output to something that's either the LLVM dir or the OpenMP one and then make a new lit variable.
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.
With that being said, I'm not sure what this patch tries to fix or improve. Does it try to set the output path at build time or install 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.
It's build time. The issue is that I wanted libc
to fish this out of the install directory, but where it's written to is variable and in a random directory. I wanted it to be next to libomptarget.so
so I have a single static search path I can use for internal resolution of the library.
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 tried your patch and I think it will indeed break standalone build.
config.library_dir = "/gpfs/jlse-fs0/users/ac.shilei.tian/build/openmp/release/libomptarget"
config.llvm_library_dir = "/gpfs/jlse-fs0/users/ac.shilei.tian/build/llvm/release/./lib"
The DeviceRTL library is in /gpfs/jlse-fs0/users/ac.shilei.tian/build/openmp/release/libomptarget
.
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.
And even w/o this patch, libomptarget.devicertl.a
sits next to libomptarget.so
.
➜ libomptarget ll
total 4.1M
drwxr-xr-x 8 ac.shilei.tian jlse 4.0K Nov 28 18:20 ./
drwxr-xr-x 8 ac.shilei.tian jlse 4.0K Nov 28 18:19 ../
drwxr-xr-x 2 ac.shilei.tian jlse 4.0K Nov 28 18:19 CMakeFiles/
-rw-r--r-- 1 ac.shilei.tian jlse 2.4K Nov 28 18:19 cmake_install.cmake
drwxr-xr-x 3 ac.shilei.tian jlse 256K Nov 28 18:20 DeviceRTL/
-rw-r--r-- 1 ac.shilei.tian jlse 1.8M Nov 28 18:20 libomptarget.devicertl.a
lrwxrwxrwx 1 ac.shilei.tian jlse 32 Nov 28 18:20 libomptarget.rtl.amdgpu.so -> libomptarget.rtl.amdgpu.so.18git*
-rwxr-xr-x 1 ac.shilei.tian jlse 443K Nov 28 18:20 libomptarget.rtl.amdgpu.so.18git*
lrwxrwxrwx 1 ac.shilei.tian jlse 30 Nov 28 18:20 libomptarget.rtl.cuda.so -> libomptarget.rtl.cuda.so.18git*
-rwxr-xr-x 1 ac.shilei.tian jlse 360K Nov 28 18:20 libomptarget.rtl.cuda.so.18git*
lrwxrwxrwx 1 ac.shilei.tian jlse 32 Nov 28 18:20 libomptarget.rtl.x86_64.so -> libomptarget.rtl.x86_64.so.18git*
-rwxr-xr-x 1 ac.shilei.tian jlse 303K Nov 28 18:20 libomptarget.rtl.x86_64.so.18git*
lrwxrwxrwx 1 ac.shilei.tian jlse 21 Nov 28 18:20 libomptarget.so -> libomptarget.so.18git*
-rwxr-xr-x 1 ac.shilei.tian jlse 209K Nov 28 18:20 libomptarget.so.18git*
drwxr-xr-x 11 ac.shilei.tian jlse 4.0K Nov 28 18:19 plugins-nextgen/
drwxr-xr-x 3 ac.shilei.tian jlse 4.0K Nov 28 18:19 src/
drwxr-xr-x 8 ac.shilei.tian jlse 4.0K Nov 28 18:19 test/
drwxr-xr-x 5 ac.shilei.tian jlse 4.0K Nov 28 18:19 tools/
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.
Definitely doesn't in my build tree, both projects and runtimes. I think standalone defaults to ./lib
as well?
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 is not in ./lib
because it is build time. Eventually after installation it will be in ./lib
, but it is in config.library_dir
.
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, the build is what I care about. It currently gets installed to the same place, yes. I'm fishing these libraries out of the user's build so it needs to be in a consistent place.
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.
Have you tried ninja -t missingdeps?
I'm fine with this, Shilei will verify standalone build is not broken. |
a8f0245
to
014c68d
Compare
Summary: Currently, the `libomp.so` and `libomptarget.so` are emitted in the `./lib` build directory generally. This logic is internal to the `add_llvm_library` function we use to build `libomptarget`. The DeviceRTl static library however is in the middle of the OpenMP runtime build, which can vary depending on if this is a runtimes or projects build. This patch changes this to install the DeviceRTL static library alongside the other OpenMP libraries so they are easier to find.
014c68d
to
318526f
Compare
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.
LG
Summary:
Currently, the
libomp.so
andlibomptarget.so
are emitted in the./lib
build directory generally. This logic is internal to theadd_llvm_library
function we use to buildlibomptarget
. TheDeviceRTl static library however is in the middle of the OpenMP runtime
build, which can vary depending on if this is a runtimes or projects
build. This patch changes this to install the DeviceRTL static library
alongside the other OpenMP libraries so they are easier to find.