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
2 changes: 1 addition & 1 deletion .github/intel-llvm-mirror-base-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
84518c193adb9d8b03ae449345d892c6c9984846
cbea6003f58953ebf25e1ed353d3d7ac37191e8c
2 changes: 2 additions & 0 deletions include/ur_api.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions scripts/core/program.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ returns:
- "If `pFunctionName` couldn't be found in `hProgram`."
- $X_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE:
- "If `pFunctionName` could be located, but its address couldn't be retrieved."
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the backend does not support querying function pointers."
--- #--------------------------------------------------------------------------
type: function
desc: "Retrieves a pointer to a device global variable."
Expand Down
67 changes: 57 additions & 10 deletions source/adapters/level_zero/v2/command_list_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,19 +907,66 @@ ur_result_t ur_command_list_manager::bindlessImagesImageCopyExp(
}

ur_result_t ur_command_list_manager::bindlessImagesWaitExternalSemaphoreExp(
ur_exp_external_semaphore_handle_t /*hSemaphore*/, bool /*hasWaitValue*/,
uint64_t /*waitValue*/, uint32_t /*numEventsInWaitList*/,
const ur_event_handle_t * /*phEventWaitList*/,
ur_event_handle_t /*phEvent*/) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
ur_exp_external_semaphore_handle_t hSemaphore, bool hasWaitValue,
uint64_t waitValue, uint32_t numEventsInWaitList,
const ur_event_handle_t *phEventWaitList, ur_event_handle_t phEvent) {
auto hPlatform = hContext->getPlatform();
if (!hPlatform->ZeExternalSemaphoreExt.Supported == false ||
!hPlatform->ZeExternalSemaphoreExt.LoaderExtension) {
UR_LOG_LEGACY(ERR,
logger::LegacyMessage("[UR][L0] {} function not supported!"),
"{} function not supported!", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

auto zeSignalEvent =
getSignalEvent(phEvent, UR_COMMAND_EXTERNAL_SEMAPHORE_WAIT_EXP);
auto [pWaitEvents, numWaitEvents] =
getWaitListView(phEventWaitList, numEventsInWaitList);

ze_external_semaphore_wait_params_ext_t waitParams = {
ZE_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_WAIT_PARAMS_EXT, nullptr, 0};
waitParams.value = hasWaitValue ? waitValue : 0;
ze_external_semaphore_ext_handle_t hExtSemaphore =
reinterpret_cast<ze_external_semaphore_ext_handle_t>(hSemaphore);
ZE2UR_CALL(hPlatform->ZeExternalSemaphoreExt
.zexCommandListAppendWaitExternalSemaphoresExp,
(zeCommandList.get(), 1, &hExtSemaphore, &waitParams,
zeSignalEvent, numWaitEvents, pWaitEvents));

return UR_RESULT_SUCCESS;
}

ur_result_t ur_command_list_manager::bindlessImagesSignalExternalSemaphoreExp(
ur_exp_external_semaphore_handle_t /*hSemaphore*/, bool /*hasSignalValue*/,
uint64_t /*signalValue*/, uint32_t /*numEventsInWaitList*/,
const ur_event_handle_t * /*phEventWaitList*/,
ur_event_handle_t /*phEvent*/) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
ur_exp_external_semaphore_handle_t hSemaphore, bool hasSignalValue,
uint64_t signalValue, uint32_t numEventsInWaitList,
const ur_event_handle_t *phEventWaitList, ur_event_handle_t phEvent) {
auto hPlatform = hContext->getPlatform();
if (!hPlatform->ZeExternalSemaphoreExt.Supported == false ||
!hPlatform->ZeExternalSemaphoreExt.LoaderExtension) {
UR_LOG_LEGACY(ERR,
logger::LegacyMessage("[UR][L0] {} function not supported!"),
"{} function not supported!", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

auto zeSignalEvent =
getSignalEvent(phEvent, UR_COMMAND_EXTERNAL_SEMAPHORE_SIGNAL_EXP);
auto [pWaitEvents, numWaitEvents] =
getWaitListView(phEventWaitList, numEventsInWaitList);

ze_external_semaphore_signal_params_ext_t signalParams = {
ZE_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_EXT, nullptr, 0};
signalParams.value = hasSignalValue ? signalValue : 0;
ze_external_semaphore_ext_handle_t hExtSemaphore =
reinterpret_cast<ze_external_semaphore_ext_handle_t>(hSemaphore);

ZE2UR_CALL(hPlatform->ZeExternalSemaphoreExt
.zexCommandListAppendSignalExternalSemaphoresExp,
(zeCommandList.get(), 1, &hExtSemaphore, &signalParams,
zeSignalEvent, numWaitEvents, pWaitEvents));

return UR_RESULT_SUCCESS;
}

ur_result_t ur_command_list_manager::appendNativeCommandExp(
Expand Down
9 changes: 9 additions & 0 deletions source/adapters/offload/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetGlobalVariablePointer(

return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL
urProgramGetFunctionPointer([[maybe_unused]] ur_device_handle_t hDevice,
[[maybe_unused]] ur_program_handle_t hProgram,
[[maybe_unused]] const char *pFunctionName,
[[maybe_unused]] void **ppFunctionPointer) {
// liboffload doesn't support a representation of function pointers (yet)
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
2 changes: 1 addition & 1 deletion source/adapters/offload/ur_interface_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable(
pDdiTable->pfnCreateWithIL = urProgramCreateWithIL;
pDdiTable->pfnCreateWithNativeHandle = urProgramCreateWithNativeHandle;
pDdiTable->pfnGetBuildInfo = nullptr;
pDdiTable->pfnGetFunctionPointer = nullptr;
pDdiTable->pfnGetFunctionPointer = urProgramGetFunctionPointer;
pDdiTable->pfnGetGlobalVariablePointer = urProgramGetGlobalVariablePointer;
pDdiTable->pfnGetInfo = urProgramGetInfo;
pDdiTable->pfnGetNativeHandle = urProgramGetNativeHandle;
Expand Down
2 changes: 2 additions & 0 deletions source/loader/ur_libapi.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions source/ur_api.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 35 additions & 14 deletions test/conformance/event/urEventSetCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,24 @@

#include "fixtures.h"
#include "uur/known_failure.h"
using namespace std::chrono_literals;

/* Using urEventReferenceTest to be able to release the event during the test */
using urEventSetCallbackTest = uur::event::urEventReferenceTest;
struct urEventSetCallbackTest : uur::event::urEventReferenceTest {
std::mutex m;
std::condition_variable cv;
int flag = 0;

void WaitForFlag(int Target = 1) {
std::unique_lock lk(m);
cv.wait_for(lk, 1000ms, [&] { return flag == Target; });
}

void SetFlag() {
flag++;
cv.notify_one();
}
};

/**
* Checks that the callback function is called.
Expand All @@ -22,19 +37,19 @@ TEST_P(urEventSetCallbackTest, Success) {
[[maybe_unused]] ur_execution_info_t execStatus,
void *pUserData) {

auto status = reinterpret_cast<bool *>(pUserData);
*status = true;
auto that = reinterpret_cast<urEventSetCallbackTest *>(pUserData);
that->SetFlag();
}
};

bool didRun = false;
ASSERT_SUCCESS(
urEventSetCallback(event, ur_execution_info_t::UR_EXECUTION_INFO_COMPLETE,
Callback::callback, &didRun));
Callback::callback, this));

ASSERT_SUCCESS(urEventWait(1, &event));
ASSERT_SUCCESS(urEventRelease(event));
ASSERT_TRUE(didRun);
WaitForFlag();
ASSERT_EQ(flag, 1);
}

/**
Expand All @@ -45,6 +60,7 @@ TEST_P(urEventSetCallbackTest, ValidateParameters) {
uur::LevelZeroV2{}, uur::NativeCPU{});

struct CallbackParameters {
urEventSetCallbackTest *test;
ur_event_handle_t event;
ur_execution_info_t execStatus;
};
Expand All @@ -56,17 +72,19 @@ TEST_P(urEventSetCallbackTest, ValidateParameters) {
auto parameters = reinterpret_cast<CallbackParameters *>(pUserData);
parameters->event = hEvent;
parameters->execStatus = execStatus;
parameters->test->SetFlag();
}
};

CallbackParameters parameters{};
CallbackParameters parameters{this, nullptr, UR_EXECUTION_INFO_QUEUED};

ASSERT_SUCCESS(
urEventSetCallback(event, ur_execution_info_t::UR_EXECUTION_INFO_COMPLETE,
Callback::callback, &parameters));

ASSERT_SUCCESS(urEventWait(1, &event));
ASSERT_SUCCESS(urEventRelease(event));
WaitForFlag();
ASSERT_EQ(event, parameters.event);
ASSERT_EQ(ur_execution_info_t::UR_EXECUTION_INFO_COMPLETE,
parameters.execStatus);
Expand All @@ -80,6 +98,7 @@ TEST_P(urEventSetCallbackTest, AllStates) {
uur::LevelZeroV2{}, uur::NativeCPU{});

struct CallbackStatus {
urEventSetCallbackTest *test = nullptr;
bool submitted = false;
bool running = false;
bool complete = false;
Expand Down Expand Up @@ -107,10 +126,12 @@ TEST_P(urEventSetCallbackTest, AllStates) {
FAIL() << "Invalid execution info enumeration";
}
}

status->test->SetFlag();
}
};

CallbackStatus status{};
CallbackStatus status{this};

ASSERT_SUCCESS(urEventSetCallback(
event, ur_execution_info_t::UR_EXECUTION_INFO_SUBMITTED,
Expand All @@ -124,6 +145,7 @@ TEST_P(urEventSetCallbackTest, AllStates) {

ASSERT_SUCCESS(urEventWait(1, &event));
ASSERT_SUCCESS(urEventRelease(event));
WaitForFlag(3);

ASSERT_TRUE(status.submitted);
ASSERT_TRUE(status.running);
Expand All @@ -145,19 +167,18 @@ TEST_P(urEventSetCallbackTest, EventAlreadyCompleted) {
[[maybe_unused]] ur_execution_info_t execStatus,
void *pUserData) {

auto status = reinterpret_cast<bool *>(pUserData);
*status = true;
auto that = reinterpret_cast<urEventSetCallbackTest *>(pUserData);
that->SetFlag();
}
};

bool didRun = false;

ASSERT_SUCCESS(
urEventSetCallback(event, ur_execution_info_t::UR_EXECUTION_INFO_COMPLETE,
Callback::callback, &didRun));
Callback::callback, this));

ASSERT_SUCCESS(urEventRelease(event));
ASSERT_TRUE(didRun);
WaitForFlag();
ASSERT_EQ(flag, 1);
}

UUR_INSTANTIATE_DEVICE_TEST_SUITE(urEventSetCallbackTest);
Expand Down
16 changes: 5 additions & 11 deletions test/conformance/program/urProgramGetFunctionPointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ TEST_P(urProgramGetFunctionPointerTest, Success) {
void *function_pointer = nullptr;
ur_result_t res = urProgramGetFunctionPointer(
device, program, function_name.data(), &function_pointer);
if (res == UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE) {
if (res == UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE ||
res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
return;
}
ASSERT_SUCCESS(res);
Expand All @@ -36,17 +37,10 @@ TEST_P(urProgramGetFunctionPointerTest, InvalidKernelName) {
std::string missing_function = "aFakeFunctionName";
auto result = urProgramGetFunctionPointer(
device, program, missing_function.data(), &function_pointer);
ur_backend_t backend;
ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND,
sizeof(backend), &backend, nullptr));
// TODO: level zero backend incorrectly returns
// UR_RESULT_ERROR_UNSUPPORTED_FEATURE
if (backend == UR_BACKEND_LEVEL_ZERO) {
ASSERT_EQ(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
} else {
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_KERNEL_NAME, result);
if (result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) {
return;
}

ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_KERNEL_NAME, result);
ASSERT_EQ(function_pointer, nullptr);
}

Expand Down