Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions projects/clr/hipamd/src/hip_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,6 @@ hipError_t hipMemSetAccess(void* ptr, size_t size, const hipMemAccessDesc* desc,
if (accessLocationType != hipMemLocationTypeDevice && accessLocationType != hipMemLocationTypeHost) {
HIP_RETURN(hipErrorInvalidValue);
}
if (accessLocationType == hipMemLocationTypeHost &&
memLocationType != hipMemLocationTypeHost) {
HIP_RETURN(hipErrorInvalidValue)
}

if (desc[desc_idx].location.id >= g_devices.size()) {
HIP_RETURN(hipErrorInvalidValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1398,47 +1398,6 @@ TEST_CASE("Unit_hipMemSetAccessHostDevice_hostalloc") {
HIP_CHECK(hipMemRelease(handle));
}

TEST_CASE("Unit_hipMemSetAccessHost_devicealloc") {
// Ensure device 0 is selected
REQUIRE(hipSetDevice(0) == hipSuccess);

// ---- Describe a DEVICE-backed allocation
hipMemAllocationProp prop{};
prop.type = hipMemAllocationTypePinned; // pinned system RAM
prop.location.type = hipMemLocationTypeDevice; // generic host
prop.location.id = 0; // host id must be 0
prop.requestedHandleType = hipMemHandleTypeNone;

constexpr size_t N = 1024;
constexpr size_t bytes = N * sizeof(int);

//get minimum granularity
size_t gran = 0;
HIP_CHECK(hipMemGetAllocationGranularity(&gran, &prop, hipMemAllocationGranularityMinimum));
size_t mapSize = ((bytes + gran - 1) / gran) * gran;

// Create host-backed allocation handle
hipMemGenericAllocationHandle_t handle{};
HIP_CHECK(hipMemCreate(&handle, mapSize, &prop, 0 /*flags*/));

// Reserve VA and map
void* addr = nullptr;
HIP_CHECK(hipMemAddressReserve(&addr, mapSize, 0 /*align*/, 0 /*addr*/, 0 /*flags*/));

HIP_CHECK(hipMemMap(addr, mapSize, 0 /*offset*/, handle, 0 /*flags*/));

// Grant HOST access.
hipMemAccessDesc accHost{};
accHost.flags = hipMemAccessFlagsProtReadWrite;
accHost.location.type = hipMemLocationTypeHost;
accHost.location.id = 0;
HIP_CHECK_ERROR(hipMemSetAccess(addr, mapSize, &accHost, 1), hipErrorInvalidValue);

HIP_CHECK(hipMemUnmap(addr, mapSize));
HIP_CHECK(hipMemAddressFree(addr, mapSize));
HIP_CHECK(hipMemRelease(handle));
}

/**
* End doxygen group VirtualMemoryManagementTest.
* @}
Expand Down
Loading