Skip to content
Closed
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
4 changes: 2 additions & 2 deletions sycl/plugins/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ add_sycl_plugin(level_zero
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_device.hpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_event.hpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_mem.hpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_module.hpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.hpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.hpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_program.hpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_queue.hpp"
Expand All @@ -117,7 +117,7 @@ add_sycl_plugin(level_zero
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_event.cpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_mem.cpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_module.cpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.cpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.cpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_program.cpp"
"../unified_runtime/ur/adapters/level_zero/ur_level_zero_queue.cpp"
Expand Down
4 changes: 2 additions & 2 deletions sycl/plugins/unified_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ add_sycl_library("ur_adapter_level_zero" SHARED
"ur/adapters/level_zero/ur_level_zero_device.hpp"
"ur/adapters/level_zero/ur_level_zero_event.hpp"
"ur/adapters/level_zero/ur_level_zero_mem.hpp"
"ur/adapters/level_zero/ur_level_zero_module.hpp"
"ur/adapters/level_zero/ur_level_zero_kernel.hpp"
"ur/adapters/level_zero/ur_level_zero_platform.hpp"
"ur/adapters/level_zero/ur_level_zero_program.hpp"
"ur/adapters/level_zero/ur_level_zero_queue.hpp"
Expand All @@ -99,7 +99,7 @@ add_sycl_library("ur_adapter_level_zero" SHARED
"ur/adapters/level_zero/ur_level_zero_device.cpp"
"ur/adapters/level_zero/ur_level_zero_event.cpp"
"ur/adapters/level_zero/ur_level_zero_mem.cpp"
"ur/adapters/level_zero/ur_level_zero_module.cpp"
"ur/adapters/level_zero/ur_level_zero_kernel.cpp"
"ur/adapters/level_zero/ur_level_zero_platform.cpp"
"ur/adapters/level_zero/ur_level_zero_program.cpp"
"ur/adapters/level_zero/ur_level_zero_queue.cpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1741,9 +1741,3 @@ ur_result_t urDevicePartition(
}
return UR_RESULT_SUCCESS;
}

ur_result_t urInit(ur_device_init_flags_t device_flags) {
return UR_RESULT_SUCCESS;
}

ur_result_t urTearDown(void *pParams) { return UR_RESULT_SUCCESS; }
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//===-----------------------------------------------------------------===//

#include "ur_level_zero_common.hpp"
#include <stdarg.h>
#include <unordered_map>

std::unordered_map<ze_result_t, ur_result_t> Ze2UrErrorMapping = {
{ZE_RESULT_SUCCESS, UR_RESULT_SUCCESS},
Expand Down Expand Up @@ -45,3 +47,12 @@ ur_result_t ze2urResult(ze_result_t ZeResult) {
}
return It->second;
}

void urPrint(const char *Format, ...) {
if (UrL0Debug & UR_L0_DEBUG_BASIC) {
va_list Args;
va_start(Args, Format);
vfprintf(stderr, Format, Args);
va_end(Args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,29 @@
#include "ur_level_zero_context.hpp"
#include "ur_level_zero_device.hpp"
#include "ur_level_zero_event.hpp"
#include "ur_level_zero_kernel.hpp"
#include "ur_level_zero_mem.hpp"
#include "ur_level_zero_module.hpp"
#include "ur_level_zero_platform.hpp"
#include "ur_level_zero_program.hpp"
#include "ur_level_zero_queue.hpp"
#include "ur_level_zero_sampler.hpp"

// Map Level Zero runtime error code to UR error code.
ur_result_t ze2urResult(ze_result_t ZeResult);

// Controls Level Zero calls tracing.
enum UrDebugLevel {
UR_L0_DEBUG_NONE = 0x0,
UR_L0_DEBUG_BASIC = 0x1,
UR_L0_DEBUG_VALIDATION = 0x2,
UR_L0_DEBUG_CALL_COUNT = 0x4,
UR_L0_DEBUG_ALL = -1
};

const int UrL0Debug = [] {
const char *DebugMode = std::getenv("UR_L0_DEBUG");
Copy link
Contributor Author

@jandres742 jandres742 Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smaslov-intel : what do you think of this format? So instead of ZE_DEBUG, we would have UR_L0_DEBUG, and generally speaking, we would have UR_<ADAPTER>_<KEY>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me (but remember not to remove existing SYCL_PI_LEVEL_ZER0_* vars yet)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smaslov-intel , right, I'm not removing anything. For now, only adding UR variables

return DebugMode ? std::atoi(DebugMode) : UR_L0_DEBUG_NONE;
}();

// Prints to stderr if UR_L0_DEBUG allows it
void urPrint(const char *Format, ...);
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,78 @@
//===-----------------------------------------------------------------===//

#include "ur_level_zero_context.hpp"

UR_APIEXPORT ur_result_t UR_APICALL urContextCreate(
uint32_t DeviceCount, ///< [in] the number of devices given in phDevices
const ur_device_handle_t
*Devices, ///< [in][range(0, DeviceCount)] array of handle of devices.
const ur_context_properties_t
*Properties, ///< [in][optional] pointer to context creation properties.
ur_context_handle_t
*RetContext ///< [out] pointer to handle of context object created
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urContextRetain(
ur_context_handle_t
Context ///< [in] handle of the context to get a reference of.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urContextRelease(
ur_context_handle_t Context ///< [in] handle of the context to release.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urContextGetInfo(
ur_context_handle_t Context, ///< [in] handle of the context
ur_context_info_t ContextInfoType, ///< [in] type of the info to retrieve
size_t PropSize, ///< [in] the number of bytes of memory pointed to by
///< pContextInfo.
void *ContextInfo, ///< [out][optional] array of bytes holding the info.
///< if propSize is not equal to or greater than the
///< real number of bytes needed to return the info then
///< the ::UR_RESULT_ERROR_INVALID_SIZE error is
///< returned and pContextInfo is not used.
size_t *PropSizeRet ///< [out][optional] pointer to the actual size in
///< bytes of data queried by ContextInfoType.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urContextGetNativeHandle(
ur_context_handle_t Context, ///< [in] handle of the context.
ur_native_handle_t *NativeContext ///< [out] a pointer to the native
///< handle of the context.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urContextCreateWithNativeHandle(
ur_native_handle_t
NativeContext, ///< [in] the native handle of the context.
ur_context_handle_t *Context ///< [out] pointer to the handle of the
///< context object created.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urContextSetExtendedDeleter(
ur_context_handle_t Context, ///< [in] handle of the context.
ur_context_extended_deleter_t
Deleter, ///< [in] Function pointer to extended deleter.
void *UserData ///< [in][out][optional] pointer to data to be passed to
///< callback.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,51 @@
//===-----------------------------------------------------------------===//

#include "ur_level_zero_device.hpp"

UR_APIEXPORT ur_result_t UR_APICALL urDeviceSelectBinary(
ur_device_handle_t
Device, ///< [in] handle of the device to select binary for.
const uint8_t **Binaries, ///< [in] the array of binaries to select from.
uint32_t NumBinaries, ///< [in] the number of binaries passed in ppBinaries.
///< Must greater than or equal to zero otherwise
///< ::UR_RESULT_ERROR_INVALID_VALUE is returned.
uint32_t
*SelectedBinary ///< [out] the index of the selected binary in the input
///< array of binaries. If a suitable binary was not
///< found the function returns ${X}_INVALID_BINARY.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetNativeHandle(
ur_device_handle_t Device, ///< [in] handle of the device.
ur_native_handle_t
*NativeDevice ///< [out] a pointer to the native handle of the device.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle(
ur_native_handle_t NativeDevice, ///< [in] the native handle of the device.
ur_platform_handle_t Platform, ///< [in] handle of the platform instance
ur_device_handle_t
*Device ///< [out] pointer to the handle of the device object created.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(
ur_device_handle_t Device, ///< [in] handle of the device instance
uint64_t *DeviceTimestamp, ///< [out][optional] pointer to the Device's
///< global timestamp that correlates with the
///< Host's global timestamp value
uint64_t *HostTimestamp ///< [out][optional] pointer to the Host's global
///< timestamp that correlates with the Device's
///< global timestamp value
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,115 @@
//===-----------------------------------------------------------------===//

#include "ur_level_zero_event.hpp"

UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWait(
ur_queue_handle_t Queue, ///< [in] handle of the queue object
uint32_t NumEventsInWaitList, ///< [in] size of the event wait list
const ur_event_handle_t
*EventWaitList, ///< [in][optional][range(0, numEventsInWaitList)]
///< pointer to a list of events that must be complete
///< before this command can be executed. If nullptr,
///< the numEventsInWaitList must be 0, indicating that
///< all previously enqueued commands must be complete.
ur_event_handle_t *Event ///< [in,out][optional] return an event object that
///< identifies this particular command instance.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier(
ur_queue_handle_t Queue, ///< [in] handle of the queue object
uint32_t NumEventsInWaitList, ///< [in] size of the event wait list
const ur_event_handle_t
*EventWaitList, ///< [in][optional][range(0, numEventsInWaitList)]
///< pointer to a list of events that must be complete
///< before this command can be executed. If nullptr,
///< the numEventsInWaitList must be 0, indicating that
///< all previously enqueued commands must be complete.
ur_event_handle_t *Event ///< [in,out][optional] return an event object that
///< identifies this particular command instance.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urEventGetInfo(
ur_event_handle_t Event, ///< [in] handle of the event object
ur_event_info_t PropName, ///< [in] the name of the event property to query
size_t PropValueSize, ///< [in] size in bytes of the event property value
void *PropValue, ///< [out][optional] value of the event property
size_t
*PropValueSizeRet ///< [out][optional] bytes returned in event property
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urEventGetProfilingInfo(
ur_event_handle_t Event, ///< [in] handle of the event object
ur_profiling_info_t
PropName, ///< [in] the name of the profiling property to query
size_t
PropValueSize, ///< [in] size in bytes of the profiling property value
void *PropValue, ///< [out][optional] value of the profiling property
size_t *PropValueSizeRet ///< [out][optional] pointer to the actual size in
///< bytes returned in propValue
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urEventWait(
uint32_t NumEvents, ///< [in] number of events in the event list
const ur_event_handle_t
*EventWaitList ///< [in][range(0, numEvents)] pointer to a list of
///< events to wait for completion
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urEventRetain(
ur_event_handle_t Event ///< [in] handle of the event object
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urEventRelease(
ur_event_handle_t Event ///< [in] handle of the event object
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urEventGetNativeHandle(
ur_event_handle_t Event, ///< [in] handle of the event.
ur_native_handle_t
*NativeEvent ///< [out] a pointer to the native handle of the event.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle(
ur_native_handle_t NativeEvent, ///< [in] the native handle of the event.
ur_context_handle_t Context, ///< [in] handle of the context object
ur_event_handle_t
*Event ///< [out] pointer to the handle of the event object created.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urEventSetCallback(
ur_event_handle_t Event, ///< [in] handle of the event object
ur_execution_info_t ExecStatus, ///< [in] execution status of the event
ur_event_callback_t Notify, ///< [in] execution status of the event
void *UserData ///< [in][out][optional] pointer to data to be passed to
///< callback.
) {
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
Loading