SWDEV-440866 - [hip-roclr] Adds support to batch memory operations APIs
Change-Id: I5ac63a6626af8c2b4ac382c52dfe1aaf0b3716b8
Esse commit está contido em:
commit de
Ajay GunaShekar
pai
3ad8f1b811
commit
03dbcd8ca7
@@ -61,7 +61,7 @@
|
||||
// - Reset any of the *_STEP_VERSION defines to zero if the corresponding *_MAJOR_VERSION increases
|
||||
#define HIP_API_TABLE_STEP_VERSION 0
|
||||
#define HIP_COMPILER_API_TABLE_STEP_VERSION 0
|
||||
#define HIP_RUNTIME_API_TABLE_STEP_VERSION 6
|
||||
#define HIP_RUNTIME_API_TABLE_STEP_VERSION 7
|
||||
|
||||
// HIP API interface
|
||||
typedef hipError_t (*t___hipPopCallConfiguration)(dim3* gridDim, dim3* blockDim, size_t* sharedMem,
|
||||
@@ -722,6 +722,8 @@ typedef hipError_t (*t_hipStreamWriteValue32)(hipStream_t stream, void* ptr, uin
|
||||
unsigned int flags);
|
||||
typedef hipError_t (*t_hipStreamWriteValue64)(hipStream_t stream, void* ptr, uint64_t value,
|
||||
unsigned int flags);
|
||||
typedef hipError_t (*t_hipStreamBatchMemOp)(hipStream_t stream, unsigned int count,
|
||||
hipStreamBatchMemOpParams* paramArray, unsigned int flags);
|
||||
typedef hipError_t (*t_hipTexObjectCreate)(hipTextureObject_t* pTexObject,
|
||||
const HIP_RESOURCE_DESC* pResDesc,
|
||||
const HIP_TEXTURE_DESC* pTexDesc,
|
||||
@@ -1519,6 +1521,9 @@ struct HipDispatchTable {
|
||||
// HIP_RUNTIME_API_TABLE_STEP_VERSION == 6
|
||||
t_hipDeviceGetTexture1DLinearMaxWidth hipDeviceGetTexture1DLinearMaxWidth_fn;
|
||||
|
||||
// HIP_RUNTIME_API_TABLE_STEP_VERSION == 7
|
||||
t_hipStreamBatchMemOp hipStreamBatchMemOp_fn;
|
||||
|
||||
// DO NOT EDIT ABOVE!
|
||||
// HIP_RUNTIME_API_TABLE_STEP_VERSION == 7
|
||||
|
||||
|
||||
@@ -425,7 +425,8 @@ enum hip_api_id_t {
|
||||
HIP_API_ID_hipMemcpyHtoAAsync = 405,
|
||||
HIP_API_ID_hipSetValidDevices = 406,
|
||||
HIP_API_ID_hipExtHostAlloc = 407,
|
||||
HIP_API_ID_LAST = 407,
|
||||
HIP_API_ID_hipStreamBatchMemOp = 408,
|
||||
HIP_API_ID_LAST = 408,
|
||||
|
||||
HIP_API_ID_hipChooseDevice = HIP_API_ID_CONCAT(HIP_API_ID_,hipChooseDevice),
|
||||
HIP_API_ID_hipGetDeviceProperties = HIP_API_ID_CONCAT(HIP_API_ID_,hipGetDeviceProperties),
|
||||
@@ -545,7 +546,6 @@ static inline const char* hip_api_name(const uint32_t id) {
|
||||
case HIP_API_ID_hipEventQuery: return "hipEventQuery";
|
||||
case HIP_API_ID_hipEventRecord: return "hipEventRecord";
|
||||
case HIP_API_ID_hipEventSynchronize: return "hipEventSynchronize";
|
||||
case HIP_API_ID_hipExtGetLastError: return "hipExtGetLastError";
|
||||
case HIP_API_ID_hipExtGetLinkTypeAndHopCount: return "hipExtGetLinkTypeAndHopCount";
|
||||
case HIP_API_ID_hipExtLaunchKernel: return "hipExtLaunchKernel";
|
||||
case HIP_API_ID_hipExtLaunchMultiKernelMultiDevice: return "hipExtLaunchMultiKernelMultiDevice";
|
||||
@@ -859,6 +859,8 @@ static inline const char* hip_api_name(const uint32_t id) {
|
||||
case HIP_API_ID_hipUserObjectRelease: return "hipUserObjectRelease";
|
||||
case HIP_API_ID_hipUserObjectRetain: return "hipUserObjectRetain";
|
||||
case HIP_API_ID_hipWaitExternalSemaphoresAsync: return "hipWaitExternalSemaphoresAsync";
|
||||
case HIP_API_ID_hipExtGetLastError: return "hipExtGetLastError";
|
||||
case HIP_API_ID_hipStreamBatchMemOp: return "hipStreamBatchMemOp";
|
||||
};
|
||||
return "unknown";
|
||||
};
|
||||
@@ -1262,6 +1264,7 @@ static inline uint32_t hipApiIdByName(const char* name) {
|
||||
if (strcmp("hipUserObjectRelease", name) == 0) return HIP_API_ID_hipUserObjectRelease;
|
||||
if (strcmp("hipUserObjectRetain", name) == 0) return HIP_API_ID_hipUserObjectRetain;
|
||||
if (strcmp("hipWaitExternalSemaphoresAsync", name) == 0) return HIP_API_ID_hipWaitExternalSemaphoresAsync;
|
||||
if (strcmp("hipStreamBatchMemOp", name) == 0) return HIP_API_ID_hipStreamBatchMemOp;
|
||||
return HIP_API_ID_NONE;
|
||||
}
|
||||
|
||||
@@ -3623,6 +3626,13 @@ typedef struct hip_api_data_s {
|
||||
unsigned int numExtSems;
|
||||
hipStream_t stream;
|
||||
} hipWaitExternalSemaphoresAsync;
|
||||
struct {
|
||||
hipStream_t stream;
|
||||
unsigned int count;
|
||||
hipStreamBatchMemOpParams* paramArray;
|
||||
hipStreamBatchMemOpParams paramArray__val;
|
||||
unsigned int flags;
|
||||
} hipStreamBatchMemOp;
|
||||
} args;
|
||||
uint64_t *phase_data;
|
||||
} hip_api_data_t;
|
||||
@@ -5892,6 +5902,15 @@ typedef struct hip_api_data_s {
|
||||
cb_data.args.hipStreamWriteValue64.value = (uint64_t)value; \
|
||||
cb_data.args.hipStreamWriteValue64.flags = (unsigned int)flags; \
|
||||
};
|
||||
|
||||
// hipStreamBatchMemOp[('hipStream_t', 'stream'), ('unsigned int', 'count'),
|
||||
// ('hipStreamBatchMemOpParams*', 'paramArray'), ('unsigned int', 'flags')]
|
||||
#define INIT_hipStreamBatchMemOp_CB_ARGS_DATA(cb_data) { \
|
||||
cb_data.args.hipStreamBatchMemOp.stream = (hipStream_t)stream; \
|
||||
cb_data.args.hipStreamBatchMemOp.count = (unsigned int)count; \
|
||||
cb_data.args.hipStreamBatchMemOp.paramArray= (hipStreamBatchMemOpParams*)paramArray; \
|
||||
cb_data.args.hipStreamBatchMemOp.flags = (unsigned int)flags; \
|
||||
};
|
||||
// hipTexRefGetAddress[('hipDeviceptr_t*', 'dev_ptr'), ('const textureReference*', 'texRef')]
|
||||
#define INIT_hipTexRefGetAddress_CB_ARGS_DATA(cb_data) { \
|
||||
cb_data.args.hipTexRefGetAddress.dev_ptr = (hipDeviceptr_t*)dptr; \
|
||||
@@ -7527,6 +7546,11 @@ static inline void hipApiArgsInit(hip_api_id_t id, hip_api_data_t* data) {
|
||||
// hipStreamWriteValue64[('hipStream_t', 'stream'), ('void*', 'ptr'), ('uint64_t', 'value'), ('unsigned int', 'flags')]
|
||||
case HIP_API_ID_hipStreamWriteValue64:
|
||||
break;
|
||||
// hipStreamBatchMemOp[('hipStream_t', 'stream'), ('unsigned int', 'count'),
|
||||
// ('hipStreamBatchMemOpParams*', 'paramArray'), ('unsigned int', 'flags')]
|
||||
case HIP_API_ID_hipStreamBatchMemOp:
|
||||
if (data->args.hipStreamBatchMemOp.paramArray) data->args.hipStreamBatchMemOp.paramArray__val = *(data->args.hipStreamBatchMemOp.paramArray);
|
||||
break;
|
||||
// hipTexRefGetAddress[('hipDeviceptr_t*', 'dev_ptr'), ('const textureReference*', 'texRef')]
|
||||
case HIP_API_ID_hipTexRefGetAddress:
|
||||
if (data->args.hipTexRefGetAddress.dev_ptr) data->args.hipTexRefGetAddress.dev_ptr__val = *(data->args.hipTexRefGetAddress.dev_ptr);
|
||||
@@ -10614,6 +10638,15 @@ static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* da
|
||||
oss << ", flags="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamWriteValue64.flags);
|
||||
oss << ")";
|
||||
break;
|
||||
case HIP_API_ID_hipStreamBatchMemOp:
|
||||
oss << "hipStreamBatchMemOp(";
|
||||
oss << "stream="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamBatchMemOp.stream);
|
||||
oss << ", count="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamBatchMemOp.count);
|
||||
if (data->args.hipStreamBatchMemOp.paramArray == NULL) oss << ", paramArray=NULL";
|
||||
else { oss << ", paramArray="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamBatchMemOp.paramArray__val); }
|
||||
oss << ", flags="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamBatchMemOp.flags);
|
||||
oss << ")";
|
||||
break;
|
||||
case HIP_API_ID_hipTexRefGetAddress:
|
||||
oss << "hipTexRefGetAddress(";
|
||||
if (data->args.hipTexRefGetAddress.dev_ptr == NULL) oss << "dev_ptr=NULL";
|
||||
|
||||
@@ -299,7 +299,7 @@ if(WIN32 OR NOT BUILD_SHARED_LIBS)
|
||||
# rocprofiler-register is not support on Windows
|
||||
set(HIP_ENABLE_ROCPROFILER_REGISTER OFF)
|
||||
else()
|
||||
option(HIP_ENABLE_ROCPROFILER_REGISTER "Enable rocprofiler-register support" ON)
|
||||
option(HIP_ENABLE_ROCPROFILER_REGISTER "Enable rocprofiler-register support" ON)
|
||||
endif()
|
||||
|
||||
if(HIP_ENABLE_ROCPROFILER_REGISTER)
|
||||
|
||||
@@ -480,3 +480,4 @@ hipGraphExecNodeSetParams
|
||||
hipDrvGraphMemcpyNodeSetParams
|
||||
hipDrvGraphMemcpyNodeGetParams
|
||||
hipExtHostAlloc
|
||||
hipStreamBatchMemOp
|
||||
|
||||
@@ -602,6 +602,8 @@ hipError_t hipStreamWaitValue64(hipStream_t stream, void* ptr, uint64_t value, u
|
||||
uint64_t mask);
|
||||
hipError_t hipStreamWriteValue32(hipStream_t stream, void* ptr, uint32_t value, unsigned int flags);
|
||||
hipError_t hipStreamWriteValue64(hipStream_t stream, void* ptr, uint64_t value, unsigned int flags);
|
||||
hipError_t hipStreamBatchMemOp(hipStream_t stream, unsigned int count,
|
||||
hipStreamBatchMemOpParams* paramArray, unsigned int flags);
|
||||
hipError_t hipTexObjectCreate(hipTextureObject_t* pTexObject, const HIP_RESOURCE_DESC* pResDesc,
|
||||
const HIP_TEXTURE_DESC* pTexDesc,
|
||||
const HIP_RESOURCE_VIEW_DESC* pResViewDesc);
|
||||
@@ -1197,6 +1199,7 @@ void UpdateDispatchTable(HipDispatchTable* ptrDispatchTable) {
|
||||
ptrDispatchTable->hipStreamWaitValue64_fn = hip::hipStreamWaitValue64;
|
||||
ptrDispatchTable->hipStreamWriteValue32_fn = hip::hipStreamWriteValue32;
|
||||
ptrDispatchTable->hipStreamWriteValue64_fn = hip::hipStreamWriteValue64;
|
||||
ptrDispatchTable->hipStreamBatchMemOp_fn = hip::hipStreamBatchMemOp;
|
||||
ptrDispatchTable->hipTexObjectCreate_fn = hip::hipTexObjectCreate;
|
||||
ptrDispatchTable->hipTexObjectDestroy_fn = hip::hipTexObjectDestroy;
|
||||
ptrDispatchTable->hipTexObjectGetResourceDesc_fn = hip::hipTexObjectGetResourceDesc;
|
||||
@@ -1887,6 +1890,9 @@ HIP_ENFORCE_ABI(HipDispatchTable, hipDrvGraphMemcpyNodeSetParams_fn, 460)
|
||||
HIP_ENFORCE_ABI(HipDispatchTable, hipExtHostAlloc_fn, 461)
|
||||
// HIP_RUNTIME_API_TABLE_STEP_VERSION == 6
|
||||
HIP_ENFORCE_ABI(HipDispatchTable, hipDeviceGetTexture1DLinearMaxWidth_fn, 462)
|
||||
// HIP_RUNTIME_API_TABLE_STEP_VERSION == 7
|
||||
HIP_ENFORCE_ABI(HipDispatchTable, hipStreamBatchMemOp_fn, 463);
|
||||
|
||||
|
||||
// if HIP_ENFORCE_ABI entries are added for each new function pointer in the table, the number below
|
||||
// will be +1 of the number in the last HIP_ENFORCE_ABI line. E.g.:
|
||||
@@ -1894,9 +1900,9 @@ HIP_ENFORCE_ABI(HipDispatchTable, hipDeviceGetTexture1DLinearMaxWidth_fn, 462)
|
||||
// HIP_ENFORCE_ABI(<table>, <functor>, 8)
|
||||
//
|
||||
// HIP_ENFORCE_ABI_VERSIONING(<table>, 9) <- 8 + 1 = 9
|
||||
HIP_ENFORCE_ABI_VERSIONING(HipDispatchTable, 463)
|
||||
HIP_ENFORCE_ABI_VERSIONING(HipDispatchTable, 464)
|
||||
|
||||
static_assert(HIP_RUNTIME_API_TABLE_MAJOR_VERSION == 0 && HIP_RUNTIME_API_TABLE_STEP_VERSION == 6,
|
||||
static_assert(HIP_RUNTIME_API_TABLE_MAJOR_VERSION == 0 && HIP_RUNTIME_API_TABLE_STEP_VERSION == 7,
|
||||
"If you get this error, add new HIP_ENFORCE_ABI(...) code for the new function "
|
||||
"pointers and then update this check so it is true");
|
||||
#endif
|
||||
|
||||
@@ -583,6 +583,7 @@ local:
|
||||
hip_6.3 {
|
||||
global:
|
||||
hipExtHostAlloc;
|
||||
hipStreamBatchMemOp;
|
||||
local:
|
||||
*;
|
||||
} hip_6.2;
|
||||
|
||||
@@ -23,8 +23,34 @@
|
||||
#include "platform/command_utils.hpp"
|
||||
|
||||
namespace hip {
|
||||
hipError_t ihipBatchMemOperation(hipStream_t stream, cl_command_type cmdType, unsigned int count,
|
||||
hipStreamBatchMemOpParams* paramArray, unsigned int flags) {
|
||||
if (paramArray == nullptr || flags != 0 || count > 256) {
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
|
||||
if (!hip::isValid(stream)) {
|
||||
return hipErrorContextIsDestroyed;
|
||||
}
|
||||
|
||||
hip::Stream* hip_stream = hip::getStream(stream);
|
||||
amd::Command::EventWaitList waitList;
|
||||
|
||||
amd::BatchMemoryOperationCommand* command = new amd::BatchMemoryOperationCommand(
|
||||
*hip_stream, cmdType, count, flags, waitList, paramArray, sizeof(hipStreamBatchMemOpParams));
|
||||
|
||||
if (command == nullptr) {
|
||||
return hipErrorOutOfMemory;
|
||||
}
|
||||
command->enqueue();
|
||||
command->release();
|
||||
HIP_RETURN(hipSuccess);
|
||||
}
|
||||
|
||||
|
||||
hipError_t ihipStreamOperation(hipStream_t stream, cl_command_type cmdType, void* ptr,
|
||||
uint64_t value, uint64_t mask, unsigned int flags, size_t sizeBytes) {
|
||||
uint64_t value, uint64_t mask, unsigned int flags,
|
||||
size_t sizeBytes) {
|
||||
size_t offset = 0;
|
||||
unsigned int outFlags = 0;
|
||||
|
||||
@@ -136,4 +162,15 @@ hipError_t hipStreamWriteValue64(hipStream_t stream, void* ptr, uint64_t value,
|
||||
0, // flags un-used for now set it to 0
|
||||
sizeof(uint64_t)));
|
||||
}
|
||||
|
||||
hipError_t hipStreamBatchMemOp(hipStream_t stream, unsigned int count,
|
||||
hipStreamBatchMemOpParams* paramArray, unsigned int flags) {
|
||||
HIP_INIT_API(hipStreamBatchMemOp, count, paramArray, flags);
|
||||
HIP_RETURN_DURATION(ihipBatchMemOperation(
|
||||
stream,
|
||||
ROCCLR_COMMAND_BATCH_STREAM,
|
||||
count,
|
||||
paramArray,
|
||||
flags));
|
||||
}
|
||||
} // namespace hip
|
||||
|
||||
@@ -1413,6 +1413,10 @@ hipError_t hipStreamWriteValue64(hipStream_t stream, void* ptr, uint64_t value,
|
||||
unsigned int flags) {
|
||||
return hip::GetHipDispatchTable()->hipStreamWriteValue64_fn(stream, ptr, value, flags);
|
||||
}
|
||||
hipError_t hipStreamBatchMemOp(hipStream_t stream, unsigned int count,
|
||||
hipStreamBatchMemOpParams* paramArray, unsigned int flags) {
|
||||
return hip::GetHipDispatchTable()->hipStreamBatchMemOp_fn(stream, count, paramArray, flags);
|
||||
}
|
||||
hipError_t hipTexObjectCreate(hipTextureObject_t* pTexObject, const HIP_RESOURCE_DESC* pResDesc,
|
||||
const HIP_TEXTURE_DESC* pTexDesc,
|
||||
const HIP_RESOURCE_VIEW_DESC* pResViewDesc) {
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário