Skip to content

Commit

Permalink
Use the designated UR value for coarse-grain memory advise
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeWeb committed Jan 11, 2024
1 parent 6f3237a commit c53137f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions source/adapters/hip/enqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ ur_result_t setHipMemAdvise(const void *DevPtr, const size_t Size,
ur_usm_advice_flags_t URAdviceFlags,
hipDevice_t Device) {
// Handle unmapped memory advice flags
// FIXME: Temporary use UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY and
// UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY for controlling coarse-grain
// memory until we introduce a new flag more appropriately. Add them back to
// unsupported when that happens.
if (URAdviceFlags &
(UR_USM_ADVICE_FLAG_BIAS_CACHED | UR_USM_ADVICE_FLAG_BIAS_UNCACHED)) {
(UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY |
UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY |
UR_USM_ADVICE_FLAG_BIAS_CACHED | UR_USM_ADVICE_FLAG_BIAS_UNCACHED
#if !defined(__HIP_PLATFORM_AMD__)
| UR_USM_ADVICE_FLAG_SET_NON_COHERENT_MEMORY |
UR_USM_ADVICE_FLAG_CLEAR_NON_COHERENT_MEMORY
#endif
)) {
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}

Expand All @@ -120,9 +123,9 @@ ur_result_t setHipMemAdvise(const void *DevPtr, const size_t Size,
std::make_pair(UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE,
hipMemAdviseUnsetAccessedBy),
#if defined(__HIP_PLATFORM_AMD__)
std::make_pair(UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY,
std::make_pair(UR_USM_ADVICE_FLAG_SET_NON_COHERENT_MEMORY,
hipMemAdviseSetCoarseGrain),
std::make_pair(UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY,
std::make_pair(UR_USM_ADVICE_FLAG_CLEAR_NON_COHERENT_MEMORY,
hipMemAdviseUnsetCoarseGrain),
#endif
};
Expand Down

0 comments on commit c53137f

Please sign in to comment.