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 efd31dffa1..355c3c90d3 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 @@ -363,7 +363,8 @@ enum hip_api_id_t { HIP_API_ID_hipGraphKernelNodeCopyAttributes = 350, HIP_API_ID_hipGraphNodeGetEnabled = 351, HIP_API_ID_hipGraphNodeSetEnabled = 352, - HIP_API_ID_LAST = 352, + HIP_API_ID_hipPointerSetAttribute = 353, + HIP_API_ID_LAST = 353, HIP_API_ID_hipArray3DGetDescriptor = HIP_API_ID_NONE, HIP_API_ID_hipArrayGetDescriptor = HIP_API_ID_NONE, @@ -708,6 +709,7 @@ static inline const char* hip_api_name(const uint32_t id) { case HIP_API_ID_hipPeekAtLastError: return "hipPeekAtLastError"; case HIP_API_ID_hipPointerGetAttribute: return "hipPointerGetAttribute"; case HIP_API_ID_hipPointerGetAttributes: return "hipPointerGetAttributes"; + case HIP_API_ID_hipPointerSetAttribute: return "hipPointerSetAttribute"; case HIP_API_ID_hipProfilerStart: return "hipProfilerStart"; case HIP_API_ID_hipProfilerStop: return "hipProfilerStop"; case HIP_API_ID_hipRuntimeGetVersion: return "hipRuntimeGetVersion"; @@ -1063,6 +1065,7 @@ static inline uint32_t hipApiIdByName(const char* name) { if (strcmp("hipPeekAtLastError", name) == 0) return HIP_API_ID_hipPeekAtLastError; if (strcmp("hipPointerGetAttribute", name) == 0) return HIP_API_ID_hipPointerGetAttribute; if (strcmp("hipPointerGetAttributes", name) == 0) return HIP_API_ID_hipPointerGetAttributes; + if (strcmp("hipPointerSetAttribute", name) == 0) return HIP_API_ID_hipPointerSetAttribute; if (strcmp("hipProfilerStart", name) == 0) return HIP_API_ID_hipProfilerStart; if (strcmp("hipProfilerStop", name) == 0) return HIP_API_ID_hipProfilerStop; if (strcmp("hipRuntimeGetVersion", name) == 0) return HIP_API_ID_hipRuntimeGetVersion; @@ -2878,6 +2881,11 @@ typedef struct hip_api_data_s { hipPointerAttribute_t attributes__val; const void* ptr; } hipPointerGetAttributes; + struct { + const void* value; + hipPointer_attribute attribute; + hipDeviceptr_t ptr; + } hipPointerSetAttribute; struct { int* runtimeVersion; int runtimeVersion__val; @@ -4972,6 +4980,12 @@ typedef struct hip_api_data_s { cb_data.args.hipPointerGetAttributes.attributes = (hipPointerAttribute_t*)attributes; \ cb_data.args.hipPointerGetAttributes.ptr = (const void*)ptr; \ }; +// hipPointerSetAttribute[('const void*', 'value'), ('hipPointer_attribute', 'attribute'), ('hipDeviceptr_t', 'ptr')] +#define INIT_hipPointerSetAttribute_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipPointerSetAttribute.value = (const void*)value; \ + cb_data.args.hipPointerSetAttribute.attribute = (hipPointer_attribute)attribute; \ + cb_data.args.hipPointerSetAttribute.ptr = (hipDeviceptr_t)ptr; \ +}; // hipProfilerStart[] #define INIT_hipProfilerStart_CB_ARGS_DATA(cb_data) { \ }; @@ -6488,6 +6502,9 @@ static inline void hipApiArgsInit(hip_api_id_t id, hip_api_data_t* data) { case HIP_API_ID_hipPointerGetAttributes: if (data->args.hipPointerGetAttributes.attributes) data->args.hipPointerGetAttributes.attributes__val = *(data->args.hipPointerGetAttributes.attributes); break; +// hipPointerSetAttribute[('const void*', 'value'), ('hipPointer_attribute', 'attribute'), ('hipDeviceptr_t', 'ptr')] + case HIP_API_ID_hipPointerSetAttribute: + break; // hipProfilerStart[] case HIP_API_ID_hipProfilerStart: break; @@ -9065,6 +9082,13 @@ static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* da oss << ", ptr="; roctracer::hip_support::detail::operator<<(oss, data->args.hipPointerGetAttributes.ptr); oss << ")"; break; + case HIP_API_ID_hipPointerSetAttribute: + oss << "hipPointerSetAttribute("; + oss << "value=" << data->args.hipPointerSetAttribute.value; + oss << ", attribute=" << data->args.hipPointerSetAttribute.attribute; + oss << ", ptr=" << data->args.hipPointerSetAttribute.ptr; + oss << ")"; + break; case HIP_API_ID_hipProfilerStart: oss << "hipProfilerStart("; oss << ")"; diff --git a/projects/clr/hipamd/src/hip_hcc.def.in b/projects/clr/hipamd/src/hip_hcc.def.in index 2045f7a011..cad7b46eb3 100644 --- a/projects/clr/hipamd/src/hip_hcc.def.in +++ b/projects/clr/hipamd/src/hip_hcc.def.in @@ -175,6 +175,7 @@ hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags hipFuncGetAttribute hipFuncGetAttributes hipPeekAtLastError +hipPointerSetAttribute hipPointerGetAttributes hipProfilerStart hipProfilerStop diff --git a/projects/clr/hipamd/src/hip_hcc.map.in b/projects/clr/hipamd/src/hip_hcc.map.in index ab86e6e35b..8f9f76f312 100644 --- a/projects/clr/hipamd/src/hip_hcc.map.in +++ b/projects/clr/hipamd/src/hip_hcc.map.in @@ -155,6 +155,7 @@ global: hipFuncGetAttribute; hipFuncGetAttributes; hipPeekAtLastError; + hipPointerSetAttribute; hipPointerGetAttributes; hipProfilerStart; hipProfilerStop; diff --git a/projects/clr/hipamd/src/hip_memory.cpp b/projects/clr/hipamd/src/hip_memory.cpp index 116ecb103d..517427c838 100644 --- a/projects/clr/hipamd/src/hip_memory.cpp +++ b/projects/clr/hipamd/src/hip_memory.cpp @@ -2809,8 +2809,9 @@ hipError_t ihipMemset(void* dst, int64_t value, size_t valueSize, size_t sizeByt size_t offset = 0; amd::Memory* memObj = getMemoryObject(dst, offset); auto flags = memObj->getMemFlags(); - if (offset == 0 && - !(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_SVM_ATOMICS | CL_MEM_SVM_FINE_GRAIN_BUFFER))) { + if ((memObj->getUserData().sync_mem_ops_) + || (offset == 0 && !(flags & (CL_MEM_SVM_FINE_GRAIN_BUFFER + | CL_MEM_SVM_ATOMICS | CL_MEM_USE_HOST_PTR)))) { isAsync = true; } } @@ -3240,6 +3241,25 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void HIP_RETURN(hipErrorInvalidValue); } +// ================================================================================================ +hipError_t ihipPointerSetAttribute(const void* value, hipPointer_attribute attribute, + hipDeviceptr_t ptr) { + if (attribute != HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS) { + return hipErrorInvalidValue; + } + + size_t offset = 0; + amd::Memory* memObj = getMemoryObject(ptr, offset); + if (memObj == nullptr) { + return hipErrorInvalidDevicePointer; + } + + memObj->getUserData().sync_mem_ops_ + = static_cast(*(reinterpret_cast(value))); + + return hipSuccess; +} + // ================================================================================================ hipError_t ihipPointerGetAttributes(void* data, hipPointer_attribute attribute, hipDeviceptr_t ptr) { @@ -3437,6 +3457,19 @@ hipError_t ihipPointerGetAttributes(void* data, hipPointer_attribute attribute, } // ================================================================================================ +hipError_t hipPointerSetAttribute(const void* value, hipPointer_attribute attribute, + hipDeviceptr_t ptr) { + HIP_INIT_API(hipPointerSetAttribute, value, attribute, ptr); + + if (ptr == nullptr || value == nullptr) { + HIP_RETURN(hipErrorInvalidValue); + } + + HIP_RETURN(ihipPointerSetAttribute(value, attribute, ptr)); +} + +// ================================================================================================ + hipError_t hipPointerGetAttribute(void* data, hipPointer_attribute attribute, hipDeviceptr_t ptr) { HIP_INIT_API(hipPointerGetAttribute, data, attribute, ptr);