Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,16 +816,19 @@ ur_program_handle_t ProgramManager::getBuiltURProgram(
// If device image is not SPIR-V, DeviceLibReqMask will be 0 which means
// no fallback device library will be linked.
uint32_t DeviceLibReqMask = 0;
if (!DeviceCodeWasInCache &&
Img.getFormat() == SYCL_DEVICE_BINARY_TYPE_SPIRV &&
!SYCLConfig<SYCL_DEVICELIB_NO_FALLBACK>::get())
bool UseDeviceLibs = !DeviceCodeWasInCache &&
Img.getFormat() == SYCL_DEVICE_BINARY_TYPE_SPIRV &&
!SYCLConfig<SYCL_DEVICELIB_NO_FALLBACK>::get();
if (UseDeviceLibs)
DeviceLibReqMask = getDeviceLibReqMask(Img);

std::vector<ur_program_handle_t> ProgramsToLink;
// If we had a program in cache, then it should have been the fully linked
// program already.
if (!DeviceCodeWasInCache) {
for (RTDeviceBinaryImage *BinImg : DeviceImagesToLink) {
if (UseDeviceLibs)
DeviceLibReqMask |= getDeviceLibReqMask(*BinImg);
device_image_plain DevImagePlain =
getDeviceImageFromBinaryImage(BinImg, Context, Device);
const std::shared_ptr<detail::device_image_impl> &DeviceImageImpl =
Expand Down
27 changes: 27 additions & 0 deletions sycl/test-e2e/DeviceDependencies/math_device_lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// REQUIRES: aspect-fp64
// UNSUPPORTED: hip || cuda

// DEFINE: %{mathflags} = %if cl_options %{/clang:-fno-fast-math%} %else %{-fno-fast-math%}

// RUN: %{build} -fsycl-allow-device-image-dependencies -fsycl-device-lib-jit-link %{mathflags} -o %t.out
// RUN: %{run} %t.out

#include <cmath>
#include <sycl/detail/core.hpp>

using namespace sycl;

// Check that device lib dependencies are resolved with
// -fsycl-allow-device-image-dependencies.
// TODO this test will become redundant once
// -fsycl-allow-device-image-dependencies is enabled by default.
int main() {
range<1> Range{1};
queue q;
buffer<double, 1> buffer1(Range);
q.submit([&](sycl::handler &cgh) {
auto Acc = buffer1.get_access<access::mode::write>(cgh);
cgh.single_task<class DeviceMathTest>([=]() { Acc[0] = std::acosh(1.0); });
});
return 0;
}
Loading