Skip to content
Open
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
28 changes: 6 additions & 22 deletions sycl/source/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,23 +230,13 @@ make_kernel_bundle(ur_native_handle_t NativeHandle,
switch (BinaryType) {
case (UR_PROGRAM_BINARY_TYPE_NONE):
if (State == bundle_state::object) {
auto Res = Adapter.call_nocheck<UrApiKind::urProgramCompileExp>(
UrProgram, 1u, &Dev, nullptr);
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
Res = Adapter.call_nocheck<UrApiKind::urProgramCompile>(
ContextImpl.getHandleRef(), UrProgram, nullptr);
}
Adapter.checkUrResult<errc::build>(Res);
Adapter.call<errc::build, UrApiKind::urProgramCompile>(UrProgram, 1,
&Dev, nullptr);
}

else if (State == bundle_state::executable) {
auto Res = Adapter.call_nocheck<UrApiKind::urProgramBuildExp>(
UrProgram, 1u, &Dev, nullptr);
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
Res = Adapter.call_nocheck<UrApiKind::urProgramBuild>(
ContextImpl.getHandleRef(), UrProgram, nullptr);
}
Adapter.checkUrResult<errc::build>(Res);
Adapter.call<errc::build, UrApiKind::urProgramBuild>(UrProgram, 1, &Dev,
nullptr);
}

break;
Expand All @@ -259,15 +249,9 @@ make_kernel_bundle(ur_native_handle_t NativeHandle,
detail::codeToString(UR_RESULT_ERROR_INVALID_VALUE));
if (State == bundle_state::executable) {
ur_program_handle_t UrLinkedProgram = nullptr;
auto Res = Adapter.call_nocheck<UrApiKind::urProgramLinkExp>(
ContextImpl.getHandleRef(), 1u, &Dev, 1u, &UrProgram, nullptr,
Adapter.call<errc::build, UrApiKind::urProgramLink>(
ContextImpl.getHandleRef(), 1, &Dev, 1, &UrProgram, nullptr,
&UrLinkedProgram);
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
Res = Adapter.call_nocheck<UrApiKind::urProgramLink>(
ContextImpl.getHandleRef(), 1u, &UrProgram, nullptr,
&UrLinkedProgram);
}
Adapter.checkUrResult<errc::build>(Res);
if (UrLinkedProgram != nullptr) {
UrProgram = UrLinkedProgram;
}
Expand Down
9 changes: 2 additions & 7 deletions sycl/source/detail/device_image_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,13 +783,8 @@ class device_image_impl
UrProgram = createProgramFromSource(Devices, BuildOptions, LogPtr);

std::string XsFlags = extractXsFlags(BuildOptions, MRTCBinInfo->MLanguage);
auto Res = Adapter.call_nocheck<UrApiKind::urProgramBuildExp>(
UrProgram, DeviceVec.size(), DeviceVec.data(), XsFlags.c_str());
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
Res = Adapter.call_nocheck<UrApiKind::urProgramBuild>(
ContextImpl.getHandleRef(), UrProgram, XsFlags.c_str());
}
Adapter.checkUrResult<errc::build>(Res);
Adapter.call<UrApiKind::urProgramBuild>(UrProgram, DeviceVec.size(),
DeviceVec.data(), XsFlags.c_str());

// Get the number of kernels in the program.
size_t NumKernels;
Expand Down
48 changes: 11 additions & 37 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,16 +1327,9 @@ static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) {

static ur_result_t doCompile(adapter_impl &Adapter, ur_program_handle_t Program,
uint32_t NumDevs, ur_device_handle_t *Devs,
ur_context_handle_t Ctx, const char *Opts) {
// Try to compile with given devices, fall back to compiling with the program
// context if unsupported by the adapter
auto Result = Adapter.call_nocheck<UrApiKind::urProgramCompileExp>(
Program, NumDevs, Devs, Opts);
if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
return Adapter.call_nocheck<UrApiKind::urProgramCompile>(Ctx, Program,
Opts);
}
return Result;
const char *Opts) {
return Adapter.call_nocheck<UrApiKind::urProgramCompile>(Program, NumDevs,
Devs, Opts);
}

static ur_program_handle_t
Expand Down Expand Up @@ -1407,9 +1400,8 @@ loadDeviceLibFallback(context_impl &Context, DeviceLibExt Extension,
// Do not use compile options for library programs: it is not clear if user
// options (image options) are supposed to be applied to library program as
// well, and what actually happens to a SPIR-V program if we apply them.
ur_result_t Error =
doCompile(Adapter, URProgram, DevicesToCompile.size(),
DevicesToCompile.data(), Context.getHandleRef(), "");
ur_result_t Error = doCompile(Adapter, URProgram, DevicesToCompile.size(),
DevicesToCompile.data(), "");
if (Error != UR_RESULT_SUCCESS) {
EraseProgramForDevices();
throw detail::set_ur_error(
Expand Down Expand Up @@ -1753,12 +1745,8 @@ ProgramManager::ProgramPtr ProgramManager::build(
const std::string &Options = LinkOptions.empty()
? CompileOptions
: (CompileOptions + " " + LinkOptions);
ur_result_t Error = Adapter.call_nocheck<UrApiKind::urProgramBuildExp>(
ur_result_t Error = Adapter.call_nocheck<UrApiKind::urProgramBuild>(
Program.get(), Devices.size(), Devices.data(), Options.c_str());
if (Error == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
Error = Adapter.call_nocheck<UrApiKind::urProgramBuild>(
Context.getHandleRef(), Program.get(), Options.c_str());
}

if (Error != UR_RESULT_SUCCESS)
throw detail::set_ur_error(
Expand All @@ -1772,32 +1760,26 @@ ProgramManager::ProgramPtr ProgramManager::build(
// Include the main program and compile/link everything together
if (!CreatedFromBinary) {
auto Res = doCompile(Adapter, Program.get(), Devices.size(), Devices.data(),
Context.getHandleRef(), CompileOptions.c_str());
CompileOptions.c_str());
Adapter.checkUrResult<errc::build>(Res);
}
LinkPrograms.push_back(Program.get());

for (ur_program_handle_t Prg : ExtraProgramsToLink) {
if (!CreatedFromBinary) {
auto Res = doCompile(Adapter, Prg, Devices.size(), Devices.data(),
Context.getHandleRef(), CompileOptions.c_str());
CompileOptions.c_str());
Adapter.checkUrResult<errc::build>(Res);
}
LinkPrograms.push_back(Prg);
}

ur_program_handle_t LinkedProg = nullptr;
auto doLink = [&] {
auto Res = Adapter.call_nocheck<UrApiKind::urProgramLinkExp>(
return Adapter.call_nocheck<UrApiKind::urProgramLink>(
Context.getHandleRef(), Devices.size(), Devices.data(),
LinkPrograms.size(), LinkPrograms.data(), LinkOptions.c_str(),
&LinkedProg);
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
Res = Adapter.call_nocheck<UrApiKind::urProgramLink>(
Context.getHandleRef(), LinkPrograms.size(), LinkPrograms.data(),
LinkOptions.c_str(), &LinkedProg);
}
return Res;
};
ur_result_t Error = doLink();
if (Error == UR_RESULT_ERROR_OUT_OF_RESOURCES ||
Expand Down Expand Up @@ -2872,9 +2854,7 @@ ProgramManager::compile(const DevImgPlainWithDeps &ImgWithDeps,
appendCompileEnvironmentVariablesThatAppend(CompileOptions);
ur_result_t Error =
doCompile(Adapter, ObjectImpl->get_ur_program_ref(), Devs.size(),
URDevices.data(),
getSyclObjImpl(InputImpl.get_context()).get()->getHandleRef(),
CompileOptions.c_str());
URDevices.data(), CompileOptions.c_str());
if (Error != UR_RESULT_SUCCESS)
throw sycl::exception(
make_error_code(errc::build),
Expand Down Expand Up @@ -2981,16 +2961,10 @@ ProgramManager::link(const std::vector<device_image_plain> &Imgs,

ur_program_handle_t LinkedProg = nullptr;
auto doLink = [&] {
auto Res = Adapter.call_nocheck<UrApiKind::urProgramLinkExp>(
return Adapter.call_nocheck<UrApiKind::urProgramLink>(
ContextImpl.getHandleRef(), URDevices.size(), URDevices.data(),
URPrograms.size(), URPrograms.data(), LinkOptionsStr.c_str(),
&LinkedProg);
if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
Res = Adapter.call_nocheck<UrApiKind::urProgramLink>(
ContextImpl.getHandleRef(), URPrograms.size(), URPrograms.data(),
LinkOptionsStr.c_str(), &LinkedProg);
}
return Res;
};
ur_result_t Error = doLink();
if (Error == UR_RESULT_ERROR_OUT_OF_RESOURCES ||
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/ESIMD/spec_const/spec_const_redefine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ int main(int argc, char **argv) {
}

// --- Check that only two JIT compilation happened:
// CHECK-COUNT-2: <--- urProgramBuildExp
// CHECK-NOT: <--- urProgramBuildExp
// CHECK-COUNT-2: <--- urProgramBuild
// CHECK-NOT: <--- urProgramBuild
7 changes: 2 additions & 5 deletions sycl/test-e2e/ESIMD/sycl_esimd_mix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ int main(void) {

// Regular SYCL kernel is compiled without -vc-codegen option

// Some backends will call urProgramBuild and some will call
// urProgramBuildExp depending on urProgramBuildExp support.

// CHECK-LABEL: <--- urProgramBuild{{(Exp)?}}
// CHECK-LABEL: <--- urProgramBuild
// CHECK-NOT: -vc-codegen
// CHECK-WITH-VAR: -g
// CHECK-NOT: -vc-codegen
Expand All @@ -134,7 +131,7 @@ int main(void) {
// For ESIMD kernels, -vc-codegen option is always preserved,
// regardless of SYCL_PROGRAM_COMPILE_OPTIONS value.

// CHECK-LABEL: <--- urProgramBuild{{(Exp)?}}
// CHECK-LABEL: <--- urProgramBuild
// CHECK-NO-VAR: -vc-codegen
// CHECK-WITH-VAR: -g -vc-codegen
// CHECK: {{.*}}-> UR_RESULT_SUCCESS
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/Explicit/kernel_bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// CHECK-SAME: .phProgram = {{.*}} ([[PROGRAM_HANDLE1:[0-9a-fA-Fx]+]])

//
// CHECK:<--- urProgramBuildExp(
// CHECK:<--- urProgramBuild(
// CHECK-SAME: .hProgram = [[PROGRAM_HANDLE1]]
//
// CHECK:<--- urProgramRetain(.hProgram = [[PROGRAM_HANDLE1]]) -> UR_RESULT_SUCCESS
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/RecordReplay/kernel_bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// CHECK-SAME: .phProgram = {{.*}} ([[PROGRAM_HANDLE1:[0-9a-fA-Fx]+]])
// CHECK-SAME: -> UR_RESULT_SUCCESS;
//
// CHECK:<--- urProgramBuildExp(
// CHECK:<--- urProgramBuild(
// CHECK-SAME: .hProgram = [[PROGRAM_HANDLE1]]
//
// CHECK:<--- urProgramRetain(
Expand Down
7 changes: 2 additions & 5 deletions sycl/test-e2e/KernelAndProgram/cache_env_vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@
// CPU OCL JIT 0.12 0.12 0.16 1.1 16
// CPU OCL Cache 0.01 0.01 0.01 0.02 0.08

// Some backends will call urProgramBuild and some will call
// urProgramBuildExp depending on urProgramBuildExp support.

// CHECK-BUILD-NOT: <--- urProgramCreateWithBinary(
// CHECK-BUILD: <--- urProgramCreateWithIL(
// CHECK-BUILD: <--- urProgramBuild{{(Exp)?}}(
// CHECK-BUILD: <--- urProgramBuild(

// CHECK-CACHE-NOT: <--- urProgramCreateWithIL(
// CHECK-CACHE: <--- urProgramCreateWithBinary(
// CHECK-CACHE: <--- urProgramBuild{{(Exp)?}}(
// CHECK-CACHE: <--- urProgramBuild(

#include "cache_env_vars.hpp"
6 changes: 2 additions & 4 deletions sycl/test-e2e/KernelAndProgram/cache_env_vars_lin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
// RUN: env SYCL_CACHE_PERSISTENT=1 HOME=%t/cache_dir SYCL_UR_TRACE=2 env -u XDG_CACHE_HOME env -u SYCL_CACHE_DIR %{run} %t.out | FileCheck %s --check-prefixes=CHECK-BUILD
// RUN: env SYCL_CACHE_PERSISTENT=1 HOME=%t/cache_dir SYCL_UR_TRACE=2 env -u XDG_CACHE_HOME env -u SYCL_CACHE_DIR %{run} %t.out | FileCheck %s --check-prefixes=CHECK-CACHE

// Some backends will call urProgramBuild and some will call urProgramBuildExp depending on urProgramBuildExp support.

// CHECK-BUILD-NOT: <--- urProgramCreateWithBinary(
// CHECK-BUILD: <--- urProgramCreateWithIL(
// CHECK-BUILD: <--- urProgramBuild{{(Exp)?}}(
// CHECK-BUILD: <--- urProgramBuild(

// CHECK-CACHE-NOT: <--- urProgramCreateWithIL(
// CHECK-CACHE: <--- urProgramCreateWithBinary(
// CHECK-CACHE: <--- urProgramBuild{{(Exp)?}}(
// CHECK-CACHE: <--- urProgramBuild(

#include "cache_env_vars.hpp"
10 changes: 3 additions & 7 deletions sycl/test-e2e/KernelAndProgram/kernel-bundle-merge-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
// RUN: env SYCL_UR_TRACE=2 %{run} %t.out | FileCheck %s
// UNSUPPORTED: hip

// Note that the UR call might be urProgramBuild OR urProgramBuildExp .
// The same is true for Compile and Link.
// We want the first match. Don't put parentheses after.

#include "kernel-bundle-merge-options.hpp"

// CHECK: <--- urProgramBuild
// CHECK: <--- urProgramBuild(
// CHECK-SAME: -g

// CHECK: <--- urProgramCompile
// CHECK: <--- urProgramCompile(
// CHECK-SAME: -g

// TODO: Uncomment when build options are properly passed to link
// commands for kernel_bundle
// xCHECK: <--- urProgramLink
// xCHECK: <--- urProgramLink(
// xCHECK-SAME: -g
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// RUN: env SYCL_UR_TRACE=2 %{run} %t_without.out 2>&1 | FileCheck %if system-windows %{ --implicit-check-not=-ze-intel-enable-auto-large-GRF-mode %} %else %{ --check-prefix=CHECK-OPT %} %s
// RUN: env SYCL_UR_TRACE=2 %{run} %t_default.out 2>&1 | FileCheck --implicit-check-not=-ze-intel-enable-auto-large-GRF-mode %s

// CHECK-OPT: <--- urProgramBuildExp(
// CHECK-OPT: <--- urProgramBuild(
// CHECK-SAME-OPT: -ze-intel-enable-auto-large-GRF-mode

#include <sycl/detail/core.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ int main() {
}

// --- Check that only a single program is built:
// CHECK: <--- urProgramBuildExp
// CHECK-NOT: <--- urProgramBuildExp
// CHECK: <--- urProgramBuild
// CHECK-NOT: <--- urProgramBuild
8 changes: 4 additions & 4 deletions sycl/unittests/helpers/RuntimeLinkingCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ static ur_result_t redefined_urProgramCreateWithBinary(void *pParams) {
return UR_RESULT_SUCCESS;
}

static ur_result_t redefined_urProgramLinkExp(void *pParams) {
auto Params = *static_cast<ur_program_link_exp_params_t *>(pParams);
static ur_result_t redefined_urProgramLink(void *pParams) {
auto Params = *static_cast<ur_program_link_params_t *>(pParams);
unsigned ResProgram = 1;
auto Programs = *Params.pphPrograms;
for (uint32_t I = 0; I < *Params.pcount; ++I) {
Expand Down Expand Up @@ -82,8 +82,8 @@ static void setupRuntimeLinkingMock() {
redefined_urProgramCreateWithIL);
mock::getCallbacks().set_replace_callback(
"urProgramCreateWithBinary", redefined_urProgramCreateWithBinary);
mock::getCallbacks().set_replace_callback("urProgramLinkExp",
redefined_urProgramLinkExp);
mock::getCallbacks().set_replace_callback("urProgramLink",
redefined_urProgramLink);
mock::getCallbacks().set_replace_callback("urKernelCreate",
redefined_urKernelCreate);
}
12 changes: 6 additions & 6 deletions sycl/unittests/kernel-and-program/KernelBuildOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct KernelInfo<BuildOptsTestKernel> : public unittest::MockKernelInfoBase {
} // namespace sycl

static ur_result_t redefinedProgramBuild(void *pParams) {
auto params = *static_cast<ur_program_build_exp_params_t *>(pParams);
auto params = *static_cast<ur_program_build_params_t *>(pParams);
if (*params.ppOptions)
BuildOpts = *params.ppOptions;
else
Expand All @@ -42,7 +42,7 @@ static ur_result_t redefinedProgramBuild(void *pParams) {
}

static ur_result_t redefinedProgramCompile(void *pParams) {
auto params = *static_cast<ur_program_compile_exp_params_t *>(pParams);
auto params = *static_cast<ur_program_compile_params_t *>(pParams);
if (*params.ppOptions)
BuildOpts = *params.ppOptions;
else
Expand All @@ -51,7 +51,7 @@ static ur_result_t redefinedProgramCompile(void *pParams) {
}

static ur_result_t redefinedProgramLink(void *pParams) {
auto params = *static_cast<ur_program_link_exp_params_t *>(pParams);
auto params = *static_cast<ur_program_link_params_t *>(pParams);
if (*params.ppOptions)
BuildOpts = *params.ppOptions;
else
Expand All @@ -61,11 +61,11 @@ static ur_result_t redefinedProgramLink(void *pParams) {

static void setupCommonMockAPIs(sycl::unittest::UrMock<> &Mock) {
using namespace sycl::detail;
mock::getCallbacks().set_before_callback("urProgramCompileExp",
mock::getCallbacks().set_before_callback("urProgramCompile",
&redefinedProgramCompile);
mock::getCallbacks().set_before_callback("urProgramLinkExp",
mock::getCallbacks().set_before_callback("urProgramLink",
&redefinedProgramLink);
mock::getCallbacks().set_before_callback("urProgramBuildExp",
mock::getCallbacks().set_before_callback("urProgramBuild",
&redefinedProgramBuild);
}

Expand Down
2 changes: 1 addition & 1 deletion sycl/unittests/kernel-and-program/OutOfResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ TEST_P(OutOfResourcesTestSuite, urProgramLink) {
nProgramLink = 0;
sycl::unittest::UrMock<> Mock;
ErrorCode = GetParam();
mock::getCallbacks().set_before_callback("urProgramLinkExp",
mock::getCallbacks().set_before_callback("urProgramLink",
&redefinedProgramLink);

sycl::platform Plt{sycl::platform()};
Expand Down
Loading