diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index 18f08d726a..a6bb6cb853 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -1701,6 +1701,14 @@ hsa_status_t Runtime::SetSvmAttrib(void* ptr, size_t size, attribs.push_back(kmtPair(HSA_SVM_ATTR_PREFERRED_LOC, agent->node_id())); break; } + case HSA_AMD_SVM_ATTRIB_READ_MOSTLY: { + Check(attrib); + if (value) + set_flags |= HSA_SVM_FLAG_GPU_READ_MOSTLY; + else + clear_flags |= HSA_SVM_FLAG_GPU_READ_MOSTLY; + break; + } case HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE: { Agent* agent = Convert(value); ConfirmNew(agent); @@ -1786,7 +1794,8 @@ hsa_status_t Runtime::GetSvmAttrib(void* ptr, size_t size, switch (attrib) { case HSA_AMD_SVM_ATTRIB_GLOBAL_FLAG: case HSA_AMD_SVM_ATTRIB_READ_ONLY: - case HSA_AMD_SVM_ATTRIB_HIVE_LOCAL: { + case HSA_AMD_SVM_ATTRIB_HIVE_LOCAL: + case HSA_AMD_SVM_ATTRIB_READ_MOSTLY: { getFlags = true; kmtIndices[i] = -1; break; @@ -1868,6 +1877,10 @@ hsa_status_t Runtime::GetSvmAttrib(void* ptr, size_t size, case HSA_AMD_SVM_ATTRIB_PREFETCH_LOCATION: { break; } + case HSA_AMD_SVM_ATTRIB_READ_MOSTLY: { + value = (attribs[attribs.size() - 1].value & HSA_SVM_FLAG_GPU_READ_MOSTLY); + break; + } case HSA_AMD_SVM_ATTRIB_ACCESS_QUERY: { if (kmtIndices[i] == -1) { if (attribs[attribs.size() - 1].value & HSA_SVM_FLAG_HOST_ACCESS) diff --git a/runtime/hsa-runtime/inc/hsa_ext_amd.h b/runtime/hsa-runtime/inc/hsa_ext_amd.h index a0bc5d1d99..cc5a34f214 100644 --- a/runtime/hsa-runtime/inc/hsa_ext_amd.h +++ b/runtime/hsa-runtime/inc/hsa_ext_amd.h @@ -2150,7 +2150,7 @@ typedef enum hsa_amd_svm_attribute_s { HSA_AMD_SVM_ATTRIB_PREFERRED_LOCATION = 4, // This attribute can not be used in ::hsa_amd_svm_attributes_set (see // ::hsa_amd_svm_prefetch_async). - // Physical location of most recent prefetch command. + // Queries the physical location of most recent prefetch command. // If the prefetch location has not been set or is not uniform across the // address range then returned hsa_agent_t::handle will be 0. // Querying this attribute will return the destination agent of the most @@ -2160,6 +2160,10 @@ typedef enum hsa_amd_svm_attribute_s { // the location of the most recently completed prefetch. // Type of this attribute is hsa_agent_t. HSA_AMD_SVM_ATTRIB_PREFETCH_LOCATION = 5, + // Optimizes with the anticipation that the majority of operations to the + // range will be read operations. + // Type of this attribute is bool. + HSA_AMD_SVM_ATTRIB_READ_MOSTLY = 6, // This attribute can not be used in ::hsa_amd_svm_attributes_get. // Enables an agent for access to the range. Access may incur a page fault // and associated memory migration. Either this or