MLIR 24.0.0git
RocmRuntimeWrappers.cpp File Reference
#include <cassert>
#include <cstdint>
#include <cstdio>
#include "mlir/ExecutionEngine/CRunnerUtils.h"
#include "hip/hip_runtime.h"

Go to the source code of this file.

Macros

#define MLIR_ROCM_WRAPPERS_EXPORT   __attribute__((visibility("default")))
#define HIP_REPORT_IF_ERROR(expr)

Functions

MLIR_ROCM_WRAPPERS_EXPORT hipModule_t mgpuModuleLoad (void *data, size_t)
MLIR_ROCM_WRAPPERS_EXPORT hipModule_t mgpuModuleLoadJIT (void *data, int optLevel, size_t)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuModuleUnload (hipModule_t module)
MLIR_ROCM_WRAPPERS_EXPORT hipFunction_t mgpuModuleGetFunction (hipModule_t module, const char *name)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuLaunchKernel (hipFunction_t function, intptr_t gridX, intptr_t gridY, intptr_t gridZ, intptr_t blockX, intptr_t blockY, intptr_t blockZ, int32_t smem, hipStream_t stream, void **params, void **extra, size_t)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuLaunchKernelCooperative (hipFunction_t function, intptr_t gridX, intptr_t gridY, intptr_t gridZ, intptr_t clusterX, intptr_t clusterY, intptr_t clusterZ, intptr_t blockX, intptr_t blockY, intptr_t blockZ, int32_t smem, hipStream_t stream, void **params, void **)
MLIR_ROCM_WRAPPERS_EXPORT hipStream_t mgpuStreamCreate ()
MLIR_ROCM_WRAPPERS_EXPORT void mgpuStreamDestroy (hipStream_t stream)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuStreamSynchronize (hipStream_t stream)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuStreamWaitEvent (hipStream_t stream, hipEvent_t event)
MLIR_ROCM_WRAPPERS_EXPORT hipEvent_t mgpuEventCreate ()
MLIR_ROCM_WRAPPERS_EXPORT void mgpuEventDestroy (hipEvent_t event)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuEventSynchronize (hipEvent_t event)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuEventRecord (hipEvent_t event, hipStream_t stream)
MLIR_ROCM_WRAPPERS_EXPORT voidmgpuMemAlloc (uint64_t sizeBytes, hipStream_t, bool)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemFree (void *ptr, hipStream_t)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemcpy (void *dst, void *src, size_t sizeBytes, hipStream_t stream)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemset32 (void *dst, int value, size_t count, hipStream_t stream)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemset16 (void *dst, int short value, size_t count, hipStream_t stream)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemHostRegister (void *ptr, uint64_t sizeBytes)
 Helper functions for writing mlir example code.
MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemHostRegisterMemRef (int64_t rank, StridedMemRefType< char, 1 > *descriptor, int64_t elementSizeBytes)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemHostUnregister (void *ptr)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemHostUnregisterMemRef (int64_t rank, StridedMemRefType< char, 1 > *descriptor, int64_t elementSizeBytes)
template<typename T>
void mgpuMemGetDevicePointer (T *hostPtr, T **devicePtr)
MLIR_ROCM_WRAPPERS_EXPORT StridedMemRefType< float, 1 > mgpuMemGetDeviceMemRef1dFloat (float *allocated, float *aligned, int64_t offset, int64_t size, int64_t stride)
MLIR_ROCM_WRAPPERS_EXPORT StridedMemRefType< int32_t, 1 > mgpuMemGetDeviceMemRef1dInt32 (int32_t *allocated, int32_t *aligned, int64_t offset, int64_t size, int64_t stride)
MLIR_ROCM_WRAPPERS_EXPORT void mgpuSetDefaultDevice (int32_t device)

Variables

static thread_local int32_t defaultDevice = 0

Macro Definition Documentation

◆ HIP_REPORT_IF_ERROR

#define HIP_REPORT_IF_ERROR ( expr)

◆ MLIR_ROCM_WRAPPERS_EXPORT

#define MLIR_ROCM_WRAPPERS_EXPORT   __attribute__((visibility("default")))

Function Documentation

◆ mgpuEventCreate()

MLIR_ROCM_WRAPPERS_EXPORT hipEvent_t mgpuEventCreate ( )

Definition at line 119 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR, and MLIR_ROCM_WRAPPERS_EXPORT.

◆ mgpuEventDestroy()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuEventDestroy ( hipEvent_t event)

Definition at line 125 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR, and MLIR_ROCM_WRAPPERS_EXPORT.

◆ mgpuEventRecord()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuEventRecord ( hipEvent_t event,
hipStream_t stream )

Definition at line 134 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR, and MLIR_ROCM_WRAPPERS_EXPORT.

◆ mgpuEventSynchronize()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuEventSynchronize ( hipEvent_t event)

Definition at line 130 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

◆ mgpuLaunchKernel()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuLaunchKernel ( hipFunction_t function,
intptr_t gridX,
intptr_t gridY,
intptr_t gridZ,
intptr_t blockX,
intptr_t blockY,
intptr_t blockZ,
int32_t smem,
hipStream_t stream,
void ** params,
void ** extra,
size_t  )

Definition at line 69 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

◆ mgpuLaunchKernelCooperative()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuLaunchKernelCooperative ( hipFunction_t function,
intptr_t gridX,
intptr_t gridY,
intptr_t gridZ,
intptr_t clusterX,
intptr_t clusterY,
intptr_t clusterZ,
intptr_t blockX,
intptr_t blockY,
intptr_t blockZ,
int32_t smem,
hipStream_t stream,
void ** params,
void **  )

Definition at line 81 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR, and MLIR_ROCM_WRAPPERS_EXPORT.

◆ mgpuMemAlloc()

MLIR_ROCM_WRAPPERS_EXPORT void * mgpuMemAlloc ( uint64_t sizeBytes,
hipStream_t ,
bool  )

Definition at line 139 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR, and MLIR_ROCM_WRAPPERS_EXPORT.

◆ mgpuMemcpy()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemcpy ( void * dst,
void * src,
size_t sizeBytes,
hipStream_t stream )

Definition at line 153 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

◆ mgpuMemFree()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemFree ( void * ptr,
hipStream_t  )

Definition at line 147 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR, and MLIR_ROCM_WRAPPERS_EXPORT.

◆ mgpuMemGetDeviceMemRef1dFloat()

MLIR_ROCM_WRAPPERS_EXPORT StridedMemRefType< float, 1 > mgpuMemGetDeviceMemRef1dFloat ( float * allocated,
float * aligned,
int64_t offset,
int64_t size,
int64_t stride )

Definition at line 222 of file RocmRuntimeWrappers.cpp.

References mgpuMemGetDevicePointer().

◆ mgpuMemGetDeviceMemRef1dInt32()

MLIR_ROCM_WRAPPERS_EXPORT StridedMemRefType< int32_t, 1 > mgpuMemGetDeviceMemRef1dInt32 ( int32_t * allocated,
int32_t * aligned,
int64_t offset,
int64_t size,
int64_t stride )

Definition at line 230 of file RocmRuntimeWrappers.cpp.

References mgpuMemGetDevicePointer().

◆ mgpuMemGetDevicePointer()

template<typename T>
void mgpuMemGetDevicePointer ( T * hostPtr,
T ** devicePtr )

◆ mgpuMemHostRegister()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemHostRegister ( void * ptr,
uint64_t sizeBytes )

Helper functions for writing mlir example code.

Definition at line 175 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

Referenced by mgpuMemHostRegisterMemRef().

◆ mgpuMemHostRegisterMemRef()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemHostRegisterMemRef ( int64_t rank,
StridedMemRefType< char, 1 > * descriptor,
int64_t elementSizeBytes )

◆ mgpuMemHostUnregister()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemHostUnregister ( void * ptr)

Definition at line 200 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR, and MLIR_ROCM_WRAPPERS_EXPORT.

Referenced by mgpuMemHostUnregisterMemRef().

◆ mgpuMemHostUnregisterMemRef()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemHostUnregisterMemRef ( int64_t rank,
StridedMemRefType< char, 1 > * descriptor,
int64_t elementSizeBytes )

◆ mgpuMemset16()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemset16 ( void * dst,
int short value,
size_t count,
hipStream_t stream )

Definition at line 165 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

◆ mgpuMemset32()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuMemset32 ( void * dst,
int value,
size_t count,
hipStream_t stream )

Definition at line 159 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

◆ mgpuModuleGetFunction()

MLIR_ROCM_WRAPPERS_EXPORT hipFunction_t mgpuModuleGetFunction ( hipModule_t module,
const char * name )

Definition at line 59 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

◆ mgpuModuleLoad()

MLIR_ROCM_WRAPPERS_EXPORT hipModule_t mgpuModuleLoad ( void * data,
size_t  )

Definition at line 42 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

◆ mgpuModuleLoadJIT()

MLIR_ROCM_WRAPPERS_EXPORT hipModule_t mgpuModuleLoadJIT ( void * data,
int optLevel,
size_t  )

Definition at line 49 of file RocmRuntimeWrappers.cpp.

◆ mgpuModuleUnload()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuModuleUnload ( hipModule_t module)

Definition at line 54 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR, and MLIR_ROCM_WRAPPERS_EXPORT.

◆ mgpuSetDefaultDevice()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuSetDefaultDevice ( int32_t device)

◆ mgpuStreamCreate()

MLIR_ROCM_WRAPPERS_EXPORT hipStream_t mgpuStreamCreate ( )

Definition at line 98 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR, and MLIR_ROCM_WRAPPERS_EXPORT.

◆ mgpuStreamDestroy()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuStreamDestroy ( hipStream_t stream)

Definition at line 105 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

◆ mgpuStreamSynchronize()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuStreamSynchronize ( hipStream_t stream)

Definition at line 110 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

◆ mgpuStreamWaitEvent()

MLIR_ROCM_WRAPPERS_EXPORT void mgpuStreamWaitEvent ( hipStream_t stream,
hipEvent_t event )

Definition at line 115 of file RocmRuntimeWrappers.cpp.

References HIP_REPORT_IF_ERROR.

Variable Documentation

◆ defaultDevice

thread_local int32_t defaultDevice = 0
static

Definition at line 39 of file RocmRuntimeWrappers.cpp.