MLIR 22.0.0git
LevelZeroRuntimeWrappers.cpp File Reference
#include "llvm/ADT/Twine.h"
#include "level_zero/ze_api.h"
#include <cassert>
#include <deque>
#include <exception>
#include <functional>
#include <iostream>
#include <limits>
#include <unordered_set>
#include <vector>

Go to the source code of this file.

Classes

struct  ZeContextDeleter
struct  ZeCommandListDeleter
struct  L0RTContextWrapper
struct  ZeEventDeleter
struct  ZeEventPoolDeleter
struct  DynamicEventPool
struct  StreamWrapper

Macros

#define L0_SAFE_CALL(call)

Typedefs

using UniqueZeContext
using UniqueZeCommandList
using UniqueZeEvent
using UniqueZeEventPool

Functions

static ze_driver_handle_t getDriver (uint32_t idx=0)
static ze_device_handle_t getDevice (const uint32_t driverIdx=0, const int32_t devIdx=0)
static ze_context_handle_t getContext (ze_driver_handle_t driver)
static L0RTContextWrappergetRtContext ()
static DynamicEventPoolgetDynamicEventPool ()
static ze_module_handle_t loadModule (const void *data, size_t dataSize)
StreamWrappermgpuStreamCreate ()
void mgpuStreamSynchronize (StreamWrapper *stream)
void mgpuStreamDestroy (StreamWrapper *stream)
void mgpuStreamWaitEvent (StreamWrapper *stream, ze_event_handle_t event)
ze_event_handle_t mgpuEventCreate ()
void mgpuEventDestroy (ze_event_handle_t event)
void mgpuEventSynchronize (ze_event_handle_t event)
void mgpuEventRecord (ze_event_handle_t event, StreamWrapper *stream)
voidmgpuMemAlloc (uint64_t size, StreamWrapper *stream, bool isShared)
void mgpuMemFree (void *ptr, StreamWrapper *stream)
void mgpuMemcpy (void *dst, void *src, size_t sizeBytes, StreamWrapper *stream)
template<typename PATTERN_TYPE>
static void mgpuMemset (void *dst, PATTERN_TYPE value, size_t count, StreamWrapper *stream)
void mgpuMemset32 (void *dst, unsigned int value, size_t count, StreamWrapper *stream)
void mgpuMemset16 (void *dst, unsigned short value, size_t count, StreamWrapper *stream)
ze_module_handle_t mgpuModuleLoad (const void *data, size_t gpuBlobSize)
ze_kernel_handle_t mgpuModuleGetFunction (ze_module_handle_t module, const char *name)
void mgpuLaunchKernel (ze_kernel_handle_t kernel, size_t gridX, size_t gridY, size_t gridZ, size_t blockX, size_t blockY, size_t blockZ, size_t sharedMemBytes, StreamWrapper *stream, void **params, void **, size_t paramsCount)
void mgpuModuleUnload (ze_module_handle_t module)
void mgpuSetDefaultDevice (int32_t devIdx)

Macro Definition Documentation

◆ L0_SAFE_CALL

#define L0_SAFE_CALL ( call)
Value:
{ \
ze_result_t status = (call); \
if (status != ZE_RESULT_SUCCESS) { \
const char *errorString; \
zeDriverGetLastErrorDescription(NULL, &errorString); \
std::cerr << "L0 error " << status << ": " << errorString << std::endl; \
std::abort(); \
} \
}

Definition at line 39 of file LevelZeroRuntimeWrappers.cpp.

Referenced by DynamicEventPool::createNewPool(), getContext(), getDevice(), getDriver(), L0RTContextWrapper::L0RTContextWrapper(), loadModule(), mgpuEventRecord(), mgpuEventSynchronize(), mgpuLaunchKernel(), mgpuMemAlloc(), mgpuMemcpy(), mgpuMemFree(), mgpuMemset(), mgpuModuleGetFunction(), mgpuModuleUnload(), ZeCommandListDeleter::operator()(), ZeContextDeleter::operator()(), ZeEventDeleter::operator()(), ZeEventPoolDeleter::operator()(), DynamicEventPool::releaseEvent(), StreamWrapper::sync(), and DynamicEventPool::takeEvent().

Typedef Documentation

◆ UniqueZeCommandList

Initial value:
std::unique_ptr<std::remove_pointer<ze_command_list_handle_t>::type,

Definition at line 136 of file LevelZeroRuntimeWrappers.cpp.

◆ UniqueZeContext

Initial value:
std::unique_ptr<std::remove_pointer<ze_context_handle_t>::type,

Definition at line 133 of file LevelZeroRuntimeWrappers.cpp.

◆ UniqueZeEvent

Initial value:
std::unique_ptr<std::remove_pointer<ze_event_handle_t>::type,

Definition at line 234 of file LevelZeroRuntimeWrappers.cpp.

◆ UniqueZeEventPool

Initial value:
std::unique_ptr<std::remove_pointer<ze_event_pool_handle_t>::type,

Definition at line 237 of file LevelZeroRuntimeWrappers.cpp.

Function Documentation

◆ getContext()

ze_context_handle_t getContext ( ze_driver_handle_t driver)
static

Definition at line 105 of file LevelZeroRuntimeWrappers.cpp.

References L0_SAFE_CALL.

◆ getDevice()

ze_device_handle_t getDevice ( const uint32_t driverIdx = 0,
const int32_t devIdx = 0 )
static

◆ getDriver()

ze_driver_handle_t getDriver ( uint32_t idx = 0)
static

Definition at line 58 of file LevelZeroRuntimeWrappers.cpp.

References L0_SAFE_CALL.

Referenced by getDevice(), and L0RTContextWrapper::L0RTContextWrapper().

◆ getDynamicEventPool()

DynamicEventPool & getDynamicEventPool ( )
static

◆ getRtContext()

◆ loadModule()

ze_module_handle_t loadModule ( const void * data,
size_t dataSize )
static

◆ mgpuEventCreate()

ze_event_handle_t mgpuEventCreate ( )

◆ mgpuEventDestroy()

void mgpuEventDestroy ( ze_event_handle_t event)

◆ mgpuEventRecord()

void mgpuEventRecord ( ze_event_handle_t event,
StreamWrapper * stream )

◆ mgpuEventSynchronize()

void mgpuEventSynchronize ( ze_event_handle_t event)

Definition at line 440 of file LevelZeroRuntimeWrappers.cpp.

References L0_SAFE_CALL.

◆ mgpuLaunchKernel()

void mgpuLaunchKernel ( ze_kernel_handle_t kernel,
size_t gridX,
size_t gridY,
size_t gridZ,
size_t blockX,
size_t blockY,
size_t blockZ,
size_t sharedMemBytes,
StreamWrapper * stream,
void ** params,
void ** ,
size_t paramsCount )

◆ mgpuMemAlloc()

void * mgpuMemAlloc ( uint64_t size,
StreamWrapper * stream,
bool isShared )

◆ mgpuMemcpy()

void mgpuMemcpy ( void * dst,
void * src,
size_t sizeBytes,
StreamWrapper * stream )

◆ mgpuMemFree()

void mgpuMemFree ( void * ptr,
StreamWrapper * stream )

◆ mgpuMemset()

template<typename PATTERN_TYPE>
void mgpuMemset ( void * dst,
PATTERN_TYPE value,
size_t count,
StreamWrapper * stream )
static

◆ mgpuMemset16()

void mgpuMemset16 ( void * dst,
unsigned short value,
size_t count,
StreamWrapper * stream )

Definition at line 514 of file LevelZeroRuntimeWrappers.cpp.

References mgpuMemset().

◆ mgpuMemset32()

void mgpuMemset32 ( void * dst,
unsigned int value,
size_t count,
StreamWrapper * stream )

Definition at line 509 of file LevelZeroRuntimeWrappers.cpp.

References mgpuMemset().

◆ mgpuModuleGetFunction()

ze_kernel_handle_t mgpuModuleGetFunction ( ze_module_handle_t module,
const char * name )

Definition at line 524 of file LevelZeroRuntimeWrappers.cpp.

References L0_SAFE_CALL.

◆ mgpuModuleLoad()

ze_module_handle_t mgpuModuleLoad ( const void * data,
size_t gpuBlobSize )

Definition at line 519 of file LevelZeroRuntimeWrappers.cpp.

References loadModule().

◆ mgpuModuleUnload()

void mgpuModuleUnload ( ze_module_handle_t module)

Definition at line 562 of file LevelZeroRuntimeWrappers.cpp.

References L0_SAFE_CALL.

◆ mgpuSetDefaultDevice()

void mgpuSetDefaultDevice ( int32_t devIdx)

◆ mgpuStreamCreate()

StreamWrapper * mgpuStreamCreate ( )

Definition at line 414 of file LevelZeroRuntimeWrappers.cpp.

References getDynamicEventPool().

◆ mgpuStreamDestroy()

void mgpuStreamDestroy ( StreamWrapper * stream)

Definition at line 423 of file LevelZeroRuntimeWrappers.cpp.

◆ mgpuStreamSynchronize()

void mgpuStreamSynchronize ( StreamWrapper * stream)

Definition at line 418 of file LevelZeroRuntimeWrappers.cpp.

References StreamWrapper::sync().

◆ mgpuStreamWaitEvent()

void mgpuStreamWaitEvent ( StreamWrapper * stream,
ze_event_handle_t event )

Definition at line 425 of file LevelZeroRuntimeWrappers.cpp.

References StreamWrapper::sync().