diff --git a/projects/clr/CHANGELOG.md b/projects/clr/CHANGELOG.md index cb0e7b19da..63ef0c856b 100644 --- a/projects/clr/CHANGELOG.md +++ b/projects/clr/CHANGELOG.md @@ -14,6 +14,8 @@ Full documentation for HIP is available at [rocm.docs.amd.com](https://rocm.docs - `hipMemsetD2D16Async` Used for setting 2D memory range with specified 16-bit values asynchronously - `hipMemsetD2D32` Used for setting 2D memory range with specified 32-bit values - `hipMemsetD2D32Async` Used for setting 2D memory range with specified 32-bit values asynchronously + - `hipStreamSetAttribute` sets attributes such as synchronization policy for a given stream + - `hipStreamGetAttribute` returns attributes such as priority for a given stream ## HIP 7.0 for ROCm 7.0 diff --git a/projects/clr/hipamd/include/hip/amd_detail/hip_api_trace.hpp b/projects/clr/hipamd/include/hip/amd_detail/hip_api_trace.hpp index de4273250a..59f27677c5 100644 --- a/projects/clr/hipamd/include/hip/amd_detail/hip_api_trace.hpp +++ b/projects/clr/hipamd/include/hip/amd_detail/hip_api_trace.hpp @@ -1059,6 +1059,11 @@ typedef hipError_t (*t_hipMemsetD2D32)(hipDeviceptr_t dst, size_t dstPitch, unsi size_t width, size_t height); typedef hipError_t (*t_hipMemsetD2D32Async)(hipDeviceptr_t dst, size_t dstPitch, unsigned int value, size_t width, size_t height, hipStream_t stream); +typedef hipError_t (*t_hipStreamSetAttribute)(hipStream_t stream, hipStreamAttrID attr, + const hipStreamAttrValue *value); +typedef hipError_t (*t_hipStreamGetAttribute)(hipStream_t stream, hipStreamAttrID attr, + hipStreamAttrValue *value_out); + // HIP Compiler dispatch table struct HipCompilerDispatchTable { // HIP_COMPILER_API_TABLE_STEP_VERSION == 0 @@ -1608,6 +1613,8 @@ struct HipDispatchTable { t_hipMemsetD2D16Async hipMemsetD2D16Async_fn; t_hipMemsetD2D32 hipMemsetD2D32_fn; t_hipMemsetD2D32Async hipMemsetD2D32Async_fn; + t_hipStreamGetAttribute hipStreamGetAttribute_fn; + t_hipStreamSetAttribute hipStreamSetAttribute_fn; // HIP_RUNTIME_API_TABLE_STEP_VERSION = 14 // removed HIP_MEMSET_NODE_PARAMS replaced by hipMemsetParams diff --git a/projects/clr/hipamd/include/hip/amd_detail/hip_prof_str.h b/projects/clr/hipamd/include/hip/amd_detail/hip_prof_str.h index 4179556414..6a10b8342f 100644 --- a/projects/clr/hipamd/include/hip/amd_detail/hip_prof_str.h +++ b/projects/clr/hipamd/include/hip/amd_detail/hip_prof_str.h @@ -445,7 +445,9 @@ enum hip_api_id_t { HIP_API_ID_hipMemsetD2D32Async = 425, HIP_API_ID_hipMemsetD2D8 = 426, HIP_API_ID_hipMemsetD2D8Async = 427, - HIP_API_ID_LAST = 427, + HIP_API_ID_hipStreamGetAttribute = 428, + HIP_API_ID_hipStreamSetAttribute = 429, + HIP_API_ID_LAST = 429, HIP_API_ID_hipChooseDevice = HIP_API_ID_CONCAT(HIP_API_ID_,hipChooseDevice), HIP_API_ID_hipGetDeviceProperties = HIP_API_ID_CONCAT(HIP_API_ID_,hipGetDeviceProperties), @@ -860,6 +862,7 @@ static inline const char* hip_api_name(const uint32_t id) { case HIP_API_ID_hipStreamCreateWithPriority: return "hipStreamCreateWithPriority"; case HIP_API_ID_hipStreamDestroy: return "hipStreamDestroy"; case HIP_API_ID_hipStreamEndCapture: return "hipStreamEndCapture"; + case HIP_API_ID_hipStreamGetAttribute: return "hipStreamGetAttribute"; case HIP_API_ID_hipStreamGetCaptureInfo: return "hipStreamGetCaptureInfo"; case HIP_API_ID_hipStreamGetCaptureInfo_v2: return "hipStreamGetCaptureInfo_v2"; case HIP_API_ID_hipStreamGetDevice: return "hipStreamGetDevice"; @@ -867,6 +870,7 @@ static inline const char* hip_api_name(const uint32_t id) { case HIP_API_ID_hipStreamGetPriority: return "hipStreamGetPriority"; case HIP_API_ID_hipStreamIsCapturing: return "hipStreamIsCapturing"; case HIP_API_ID_hipStreamQuery: return "hipStreamQuery"; + case HIP_API_ID_hipStreamSetAttribute: return "hipStreamSetAttribute"; case HIP_API_ID_hipStreamSynchronize: return "hipStreamSynchronize"; case HIP_API_ID_hipStreamUpdateCaptureDependencies: return "hipStreamUpdateCaptureDependencies"; case HIP_API_ID_hipStreamWaitEvent: return "hipStreamWaitEvent"; @@ -1282,6 +1286,7 @@ static inline uint32_t hipApiIdByName(const char* name) { if (strcmp("hipStreamCreateWithPriority", name) == 0) return HIP_API_ID_hipStreamCreateWithPriority; if (strcmp("hipStreamDestroy", name) == 0) return HIP_API_ID_hipStreamDestroy; if (strcmp("hipStreamEndCapture", name) == 0) return HIP_API_ID_hipStreamEndCapture; + if (strcmp("hipStreamGetAttribute", name) == 0) return HIP_API_ID_hipStreamGetAttribute; if (strcmp("hipStreamGetCaptureInfo", name) == 0) return HIP_API_ID_hipStreamGetCaptureInfo; if (strcmp("hipStreamGetCaptureInfo_v2", name) == 0) return HIP_API_ID_hipStreamGetCaptureInfo_v2; if (strcmp("hipStreamGetDevice", name) == 0) return HIP_API_ID_hipStreamGetDevice; @@ -1289,6 +1294,7 @@ static inline uint32_t hipApiIdByName(const char* name) { if (strcmp("hipStreamGetPriority", name) == 0) return HIP_API_ID_hipStreamGetPriority; if (strcmp("hipStreamIsCapturing", name) == 0) return HIP_API_ID_hipStreamIsCapturing; if (strcmp("hipStreamQuery", name) == 0) return HIP_API_ID_hipStreamQuery; + if (strcmp("hipStreamSetAttribute", name) == 0) return HIP_API_ID_hipStreamSetAttribute; if (strcmp("hipStreamSynchronize", name) == 0) return HIP_API_ID_hipStreamSynchronize; if (strcmp("hipStreamUpdateCaptureDependencies", name) == 0) return HIP_API_ID_hipStreamUpdateCaptureDependencies; if (strcmp("hipStreamWaitEvent", name) == 0) return HIP_API_ID_hipStreamWaitEvent; @@ -3591,6 +3597,12 @@ typedef struct hip_api_data_s { hipGraph_t* pGraph; hipGraph_t pGraph__val; } hipStreamEndCapture; + struct { + hipStream_t stream; + hipLaunchAttributeID attr; + const hipLaunchAttributeValue* value_out; + hipLaunchAttributeValue value_out__val; + } hipStreamGetAttribute; struct { hipStream_t stream; hipStreamCaptureStatus* pCaptureStatus; @@ -3634,6 +3646,12 @@ typedef struct hip_api_data_s { struct { hipStream_t stream; } hipStreamQuery; + struct { + hipStream_t stream; + hipLaunchAttributeID attr; + const hipLaunchAttributeValue* value; + hipLaunchAttributeValue value__val; + } hipStreamSetAttribute; struct { hipStream_t stream; } hipStreamSynchronize; @@ -6138,6 +6156,9 @@ typedef struct hip_api_data_s { cb_data.args.hipStreamEndCapture.stream = (hipStream_t)stream; \ cb_data.args.hipStreamEndCapture.pGraph = (hipGraph_t*)pGraph; \ }; +// hipStreamGetAttribute[('hipStream_t', 'stream'), ('hipLaunchAttributeID', 'attr'), ('const hipLaunchAttributeValue*', 'value_out')] +#define INIT_hipStreamGetAttribute_CB_ARGS_DATA(cb_data) { \ +}; // hipStreamGetCaptureInfo[('hipStream_t', 'stream'), ('hipStreamCaptureStatus*', 'pCaptureStatus'), ('unsigned long long*', 'pId')] #define INIT_hipStreamGetCaptureInfo_CB_ARGS_DATA(cb_data) { \ cb_data.args.hipStreamGetCaptureInfo.stream = (hipStream_t)stream; \ @@ -6177,6 +6198,9 @@ typedef struct hip_api_data_s { #define INIT_hipStreamQuery_CB_ARGS_DATA(cb_data) { \ cb_data.args.hipStreamQuery.stream = (hipStream_t)stream; \ }; +// hipStreamSetAttribute[('hipStream_t', 'stream'), ('hipLaunchAttributeID', 'attr'), ('const hipLaunchAttributeValue*', 'value')] +#define INIT_hipStreamSetAttribute_CB_ARGS_DATA(cb_data) { \ +}; // hipStreamSynchronize[('hipStream_t', 'stream')] #define INIT_hipStreamSynchronize_CB_ARGS_DATA(cb_data) { \ cb_data.args.hipStreamSynchronize.stream = (hipStream_t)stream; \ @@ -7889,6 +7913,10 @@ static inline void hipApiArgsInit(hip_api_id_t id, hip_api_data_t* data) { case HIP_API_ID_hipStreamEndCapture: if (data->args.hipStreamEndCapture.pGraph) data->args.hipStreamEndCapture.pGraph__val = *(data->args.hipStreamEndCapture.pGraph); break; +// hipStreamGetAttribute[('hipStream_t', 'stream'), ('hipLaunchAttributeID', 'attr'), ('const hipLaunchAttributeValue*', 'value_out')] + case HIP_API_ID_hipStreamGetAttribute: + if (data->args.hipStreamGetAttribute.value_out) data->args.hipStreamGetAttribute.value_out__val = *(data->args.hipStreamGetAttribute.value_out); + break; // hipStreamGetCaptureInfo[('hipStream_t', 'stream'), ('hipStreamCaptureStatus*', 'pCaptureStatus'), ('unsigned long long*', 'pId')] case HIP_API_ID_hipStreamGetCaptureInfo: if (data->args.hipStreamGetCaptureInfo.pCaptureStatus) data->args.hipStreamGetCaptureInfo.pCaptureStatus__val = *(data->args.hipStreamGetCaptureInfo.pCaptureStatus); @@ -7921,6 +7949,10 @@ static inline void hipApiArgsInit(hip_api_id_t id, hip_api_data_t* data) { // hipStreamQuery[('hipStream_t', 'stream')] case HIP_API_ID_hipStreamQuery: break; +// hipStreamSetAttribute[('hipStream_t', 'stream'), ('hipLaunchAttributeID', 'attr'), ('const hipLaunchAttributeValue*', 'value')] + case HIP_API_ID_hipStreamSetAttribute: + if (data->args.hipStreamSetAttribute.value) data->args.hipStreamSetAttribute.value__val = *(data->args.hipStreamSetAttribute.value); + break; // hipStreamSynchronize[('hipStream_t', 'stream')] case HIP_API_ID_hipStreamSynchronize: break; @@ -11094,6 +11126,14 @@ static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* da else { oss << ", pGraph="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamEndCapture.pGraph__val); } oss << ")"; break; + case HIP_API_ID_hipStreamGetAttribute: + oss << "hipStreamGetAttribute("; + oss << "stream="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamGetAttribute.stream); + oss << ", attr="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamGetAttribute.attr); + if (data->args.hipStreamGetAttribute.value_out == NULL) oss << ", value_out=NULL"; + else { oss << ", value_out="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamGetAttribute.value_out__val); } + oss << ")"; + break; case HIP_API_ID_hipStreamGetCaptureInfo: oss << "hipStreamGetCaptureInfo("; oss << "stream="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamGetCaptureInfo.stream); @@ -11151,6 +11191,14 @@ static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* da oss << "stream="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamQuery.stream); oss << ")"; break; + case HIP_API_ID_hipStreamSetAttribute: + oss << "hipStreamSetAttribute("; + oss << "stream="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamSetAttribute.stream); + oss << ", attr="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamSetAttribute.attr); + if (data->args.hipStreamSetAttribute.value == NULL) oss << ", value=NULL"; + else { oss << ", value="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamSetAttribute.value__val); } + oss << ")"; + break; case HIP_API_ID_hipStreamSynchronize: oss << "hipStreamSynchronize("; oss << "stream="; roctracer::hip_support::detail::operator<<(oss, data->args.hipStreamSynchronize.stream); diff --git a/projects/clr/hipamd/src/amdhip.def b/projects/clr/hipamd/src/amdhip.def index a93edcca5d..1f0372e078 100644 --- a/projects/clr/hipamd/src/amdhip.def +++ b/projects/clr/hipamd/src/amdhip.def @@ -499,3 +499,5 @@ hipMemsetD2D16 hipMemsetD2D16Async hipMemsetD2D32 hipMemsetD2D32Async +hipStreamGetAttribute +hipStreamSetAttribute diff --git a/projects/clr/hipamd/src/hip_api_trace.cpp b/projects/clr/hipamd/src/hip_api_trace.cpp index 1e4f4ca22d..72cbaba390 100644 --- a/projects/clr/hipamd/src/hip_api_trace.cpp +++ b/projects/clr/hipamd/src/hip_api_trace.cpp @@ -828,7 +828,7 @@ hipError_t hipEventRecordWithFlags(hipEvent_t event, hipStream_t stream, unsigne hipError_t hipLaunchKernelExC(const hipLaunchConfig_t* config, const void* fPtr, void** args); hipError_t hipDrvLaunchKernelEx(const HIP_LAUNCH_CONFIG* config, hipFunction_t f, void** params, void** extra); -hipError_t hipMemGetHandleForAddressRange(void* handle, hipDeviceptr_t dptr, size_t size, +hipError_t hipMemGetHandleForAddressRange(void* handle, hipDeviceptr_t dptr, size_t size, hipMemRangeHandleType handleType, unsigned long long flags); hipError_t hipMemsetD2D8(hipDeviceptr_t dst, size_t dstPitch, unsigned char value, size_t width, @@ -843,7 +843,10 @@ hipError_t hipMemsetD2D32(hipDeviceptr_t dst, size_t dstPitch, unsigned int valu size_t height); hipError_t hipMemsetD2D32Async(hipDeviceptr_t dst, size_t dstPitch, unsigned int value, size_t width, size_t height, hipStream_t stream); - +hipError_t hipStreamGetAttribute(hipStream_t stream, hipStreamAttrID attr, + hipStreamAttrValue *value); +hipError_t hipStreamSetAttribute(hipStream_t stream, hipStreamAttrID attr, + const hipStreamAttrValue *value); } // namespace hip namespace hip { @@ -1366,6 +1369,8 @@ void UpdateDispatchTable(HipDispatchTable* ptrDispatchTable) { ptrDispatchTable->hipMemsetD2D16Async_fn = hip::hipMemsetD2D16Async; ptrDispatchTable->hipMemsetD2D32_fn = hip::hipMemsetD2D32; ptrDispatchTable->hipMemsetD2D32Async_fn = hip::hipMemsetD2D32Async; + ptrDispatchTable->hipStreamGetAttribute_fn = hip::hipStreamGetAttribute; + ptrDispatchTable->hipStreamSetAttribute_fn = hip::hipStreamSetAttribute; } #if HIP_ROCPROFILER_REGISTER > 0 @@ -2017,14 +2022,15 @@ HIP_ENFORCE_ABI(HipDispatchTable, hipMemsetD2D16_fn, 480); HIP_ENFORCE_ABI(HipDispatchTable, hipMemsetD2D16Async_fn, 481); HIP_ENFORCE_ABI(HipDispatchTable, hipMemsetD2D32_fn, 482); HIP_ENFORCE_ABI(HipDispatchTable, hipMemsetD2D32Async_fn, 483); - +HIP_ENFORCE_ABI(HipDispatchTable, hipStreamGetAttribute_fn, 484); +HIP_ENFORCE_ABI(HipDispatchTable, hipStreamSetAttribute_fn, 485); // 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.: // // HIP_ENFORCE_ABI(