Skip to content

Commit

Permalink
[SYCL] Fix dependency compilation after PI removal (#14843)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-semenov committed Aug 1, 2024
1 parent 41d8977 commit 914561a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
11 changes: 3 additions & 8 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,14 +1507,9 @@ ProgramManager::ProgramPtr ProgramManager::build(
LinkPrograms.push_back(Program.get());

for (ur_program_handle_t Prg : ExtraProgramsToLink) {
auto Result =
Plugin->call_nocheck(urProgramCompileExp, Prg, /* num devices =*/1,
&Device, CompileOptions.c_str());
if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
Plugin->call(urProgramCompile, Context->getHandleRef(), Prg,
CompileOptions.c_str());
}
Plugin->checkUrResult(Result);
auto Res = doCompile(Plugin, Prg, /*num devices =*/1, &Device,
Context->getHandleRef(), CompileOptions.c_str());
Plugin->checkUrResult(Res);

LinkPrograms.push_back(Prg);
}
Expand Down
26 changes: 26 additions & 0 deletions sycl/unittests/program_manager/DynamicLinking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,30 @@ TEST(DynamicLinking, AheadOfTime) {
}
}

static ur_result_t redefined_urProgramCompileExp(void *pParams) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

TEST(DynamicLinking, UnsupportedCompileExp) {
sycl::unittest::UrMock<> Mock;
setupRuntimeLinkingMock();
mock::getCallbacks().set_replace_callback("urProgramCompileExp",
redefined_urProgramCompileExp);

sycl::platform Plt = sycl::platform();
sycl::queue Q(Plt.get_devices()[0]);

CapturedLinkingData.clear();

Q.single_task<DynamicLinkingTest::BasicCaseKernel>([=]() {});
ASSERT_EQ(CapturedLinkingData.NumOfUrProgramCreateCalls, 3u);
// Both programs should be linked together.
ASSERT_EQ(CapturedLinkingData.NumOfUrProgramLinkCalls, 1u);
ASSERT_TRUE(CapturedLinkingData.LinkedProgramsContains(
{BASIC_CASE_PRG, BASIC_CASE_PRG_DEP, BASIC_CASE_PRG_DEP_DEP}));
// And the linked program should be used to create a kernel.
ASSERT_EQ(CapturedLinkingData.ProgramUsedToCreateKernel,
BASIC_CASE_PRG * BASIC_CASE_PRG_DEP * BASIC_CASE_PRG_DEP_DEP);
}

} // anonymous namespace

0 comments on commit 914561a

Please sign in to comment.