Skip to content

Commit fdaac35

Browse files
authored
[UR][CUDA] Fix unmap of buffer WRITE_INVALIDATE_REGION mappings (#19028)
Buffers mapped with `UR_MAP_FLAG_WRITE_INVALIDATE_REGION` need to copy back to the buffer's device memory when unmapped. The HIP adapter was already doing this, seems like an accidental omission in the CUDA adapter.
1 parent 3b42472 commit fdaac35

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

unified-runtime/source/adapters/cuda/enqueue.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemUnmap(
13841384
BufferImpl.MemAllocMode == BufferMem::AllocMode::AllocHostPtr;
13851385

13861386
ur_result_t Result = UR_RESULT_SUCCESS;
1387-
if (!IsPinned && (Map->getMapFlags() & UR_MAP_FLAG_WRITE)) {
1387+
if (!IsPinned &&
1388+
(Map->getMapFlags() &
1389+
(UR_MAP_FLAG_WRITE | UR_MAP_FLAG_WRITE_INVALIDATE_REGION))) {
13881390
// Pinned host memory is only on host so it doesn't need to be written to.
13891391
Result = urEnqueueMemBufferWrite(
13901392
hQueue, hMem, true, Map->getMapOffset(), Map->getMapSize(), pMappedPtr,

unified-runtime/test/conformance/enqueue/urEnqueueMemBufferMap.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ UUR_DEVICE_TEST_SUITE_WITH_PARAM(
5050
TEST_P(urEnqueueMemBufferMapTestWithWriteFlagParam, SuccessWrite) {
5151
UUR_KNOWN_FAILURE_ON(uur::LevelZero{});
5252

53-
if (getParam().map_flag == UR_MAP_FLAG_WRITE_INVALIDATE_REGION) {
54-
UUR_KNOWN_FAILURE_ON(uur::CUDA{});
55-
}
56-
5753
const std::vector<uint32_t> input(count, 0);
5854
ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, true, 0, size,
5955
input.data(), 0, nullptr, nullptr));

0 commit comments

Comments
 (0)