Skip to content

Commit

Permalink
[HIP] Allow global control of hipMallocHost flags
Browse files Browse the repository at this point in the history
  • Loading branch information
npmiller committed Dec 12, 2023
1 parent 69a56ea commit 9014466
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/adapters/hip/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//
//===----------------------------------------------------------------------===//

#include <limits>
#include <cassert>

#include "adapter.hpp"
Expand Down Expand Up @@ -133,7 +134,15 @@ ur_result_t USMHostAllocImpl(void **ResultPtr,
ur_usm_host_mem_flags_t *, size_t Size,
[[maybe_unused]] uint32_t Alignment) {
try {
UR_CHECK_ERROR(hipHostMalloc(ResultPtr, Size));
unsigned flag = 0;

if (const char *e = getenv("UR_HIP_HOST_ALLOC_FLAGS")) {
unsigned long long u;
u = strtoull(e, nullptr, 0);
assert(flag < std::numeric_limits<unsigned>::max());
flag = u;
}
UR_CHECK_ERROR(hipHostMalloc(ResultPtr, Size, flag));
} catch (ur_result_t Err) {
return Err;
}
Expand Down

0 comments on commit 9014466

Please sign in to comment.