-
Notifications
You must be signed in to change notification settings - Fork 744
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
[SYCL] Remove dependency on libdevice binary for sycl-device-lib test #3639
Conversation
Signed-off-by: gejin <[email protected]>
clang/lib/Driver/Driver.cpp
Outdated
if (llvm::sys::fs::exists(LibName) || | ||
C.getArgs().hasArg(options::OPT__HASH_HASH_HASH)) { |
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 don't think customizing Driver's behavior for the test is a good solution to the problem.
The common approach in clang LIT infrastructure is to create an "input files", so you we test all scenarios (see https://github.com/intel/llvm/tree/sycl/clang/test/Driver/Inputs).
Please, create corresponding files and test Driver's behavior when no/part/all libraries are found.
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.
Hi, @bader and @mdtoguchi
Current implementation for adding SYCL device libraries in driver doesn't support such "input files". The reason is we have assumption for SYCL device library binaries, in https://github.com/intel/llvm/blob/sycl/clang/lib/Driver/Driver.cpp#L4141
we get the real path of compiler(suppose it is ${compiler_bin_path}) and assume SYCL device binaries are located in ${compiler_bin_path}/../lib/. In other targets including CUDA, compiler driver supports configuring the libdevice binary path based on sys_root env var.
If we want to use the "input file" mechanism in lit test for SYCL device library, can we consider to provide a way to configure SYCL device library path? For example,
- adding an option for sycl device library path to override the default path
- Use an env var for the sycl device library path
Thanks very much.
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.
This sounds like a bug. Why can't we distribute these libraries in SYSTEM paths, which are configured through standard command line options (or SYCL specific)?
Here is a couple of examples how it's done for:
- CUDA: clang/test/Driver/cuda-detect-path.cu, clang/test/Driver/cuda-detect.cu
- ROCM: clang/test/Driver/hip-device-libs.hip clang/test/Driver/rocm-detect.cl clang/test/Driver/rocm-device-libs.cl
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.
Hi, @bader
SYCL device library binaries are shipped together with all sycl runtime libraries such as libsycl.so, libze_loader.so....
Do we have any mechanism to configure path of those libraries through any command line option?
It seems that other targets have such mechanism. For CUDA, "-cuda-path=XX" is used: https://github.com/intel/llvm/blob/sycl/clang/lib/Driver/ToolChains/Cuda.cpp#L137
Thanks very much.
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.
Possibly introduce a similar option for us: -fsycl-devicelib-path=<arg>
which will point to the desired location for the device libraries. Currently we rely on expected locations and the known directory structure to find and pick these up. Is there a build target we can set a REQUIRES
to for the test?
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.
Adding the libsycldevice as dependency for sycl-device-lib makes sense for fixing this issue. I agree that we can consider adding a driver option like "-fsycl-devicelib-path=XXX" as a separate issue.
Hi, @bader and @andykaylor
Do you have any concern if we follow this approach?
Thanks very much.
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 don't think it's a good solution. The dependency on libsycldevice
is not needed to test clang's driver functionality. Having mock files in test Inputs
and configuring search path through existing options like -system
should be enough.
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.
Hi, @bader @vzakhari @mdtoguchi @andykaylor
It seems that we have 2 options here:
- Adding libsycldevice as dependency for sycl-device-lib test.
- Having mock input files and providing some way to configure the search patch for device library binaries in driver.
For 1,
Pros: No change needed in clang driver.
Cons: This approach doesn't align with other targets like CUDA.
For 2,
Pros: align with other targets' approach and this clang driver lit test won't have any dependency other than OS.
Cons: we need support configuring sycl device library search path in driver, either via any existing options like -isystem, -isysroot or sycl specific option like "-fsycl-device-lib-path".
It seems that we can consider another question firstly, do we need to support configuring sycl device library search path in driver? If we have strong reasons to support, I think approach 2 is better since it aligns with other targets and libsycldevice dependency will be unnecessary at that time.
Thanks very much.
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.
Hi, @bader @vzakhari @mdtoguchi @andykaylor
Do you have any preference for option 1 and option 2 mentioned above?
If no objection, I plan to follow Alexey's suggestion to support searching sycl device libraries through existing option "--sysroot".
Thanks very much.
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.
Having the test be compartmentalized (driver specific) is a good thing. I'm OK with #2.
Please, link the issue, so it's closed when pull request is merged. |
Signed-off-by: gejin <[email protected]>
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.
Overall, this looks OK. For practical purposes, would there be any expectation that the device libraries will ever be located in which we require usage of --sysroot
?
No objections for new approach from my side. Thanks!
Hi, @mdtoguchi |
clang/lib/Driver/Driver.cpp
Outdated
llvm::sys::path::append(LibLoc, "/../lib"); | ||
SmallVector<SmallString<128>, 4> LibLocCandidates; | ||
LibLocCandidates.emplace_back(TC->getDriver().Dir + "/../lib"); | ||
LibLocCandidates.emplace_back(TC->getDriver().SysRoot + "/lib"); |
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.
According to my understanding SysRoot
default value matches Dir/../
, so probably we can simplify the code and use only one candidate. 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.
Hi, @bader
I just checked that if we don't specify "--sysroot=..." in command line, the "TC->getDriver().SysRoot" will be empty string.
So, we have to keep 2 candidates here.
Thanks very much.
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.
Okay. I just noticed that similar logic for HIP/ROCM is implemented in toolchain specific file.
See RocmInstallationDetector
in https://github.com/intel/llvm/blob/sycl/clang/lib/Driver/ToolChains/AMDGPU.cpp#L171 .
@mdtoguchi, should we move this code to https://github.com/intel/llvm/blob/sycl/clang/lib/Driver/ToolChains/SYCL.cpp?
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.
Sure - maybe add a dir vector that holds the known locations in which the libs can be searched for.
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.
Hi, @bader and @mdtoguchi
So, do you mean we need to add a "SyclInstallationDectector" in SYCL.cpp and use it to record search paths for libs, bins, include?
Thanks very much.
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.
@jinge90, I don't think we need to add a full installation detector as everything is provided with the compiler. I think just add the lib search directories when the SYCLToolChain is created.
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.
Hi, @mdtoguchi
I suggest to add a very simple "SyclInstallationDectector" which only provide APIs to query lib search path for now. If we have new request, we can extend the simple "SyclInstallDetector", is it OK?
Thanks very much.
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.
Hi, @mdtoguchi and @bader
I added a very simple SYCLInstallationDetector, there is no much to do in this function since we don't have many requirements for detecting installation structure currently. If we have some requirements in the future such as adding some option like "-fsycl-installation=...", it is easy to extend this class.
Thanks very much.
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 just add the lib search directories when the SYCLToolChain is created.
I thought that Mike suggestion is that we move addSYCLDeviceLibs
to SYCLToolChain.
Signed-off-by: gejin <[email protected]>
Signed-off-by: gejin <[email protected]>
/summary: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.
Looks reasonable to me. We could use this framework for setting up the search location for the headers too.
Signed-off-by: gejin [email protected]