[llvm] [OFFLOAD] Add memory data locking API for libomptarget migration (PR #173138)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 8 14:56:42 PST 2026
https://github.com/fineg74 updated https://github.com/llvm/llvm-project/pull/173138
>From afe6006c32d9c9bf6cb16655f42518c5b66aa662 Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Fri, 12 Dec 2025 14:06:54 -0800
Subject: [PATCH 1/8] Add memory data lock API
---
offload/liboffload/API/Memory.td | 24 ++++++++++++++++++++++++
offload/liboffload/src/OffloadImpl.cpp | 15 +++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/offload/liboffload/API/Memory.td b/offload/liboffload/API/Memory.td
index 79e8038330048..cf77055837155 100644
--- a/offload/liboffload/API/Memory.td
+++ b/offload/liboffload/API/Memory.td
@@ -131,3 +131,27 @@ def olMemFill : Function {
Return<"OL_ERRC_INVALID_SIZE", ["`FillSize % PatternSize != 0`"]>
];
}
+
+def olMemDataLock : Function {
+ let desc = "Locks / pins host memory using the plugin runtime.";
+ let params = [
+ Param<"ol_device_handle_t", "Device", "handle of the device to allocate on", PARAM_IN>,
+ Param<"void *", "Ptr", "Host Pointer", PARAM_IN>,
+ Param<"size_t", "Size", "size of the allocation in bytes", PARAM_IN>,
+ Param<"void**", "LockedPtr", "output for the allocated pointer", PARAM_OUT>
+ ];
+ let returns = [
+ Return<"OL_ERRC_INVALID_SIZE", [
+ "`Size == 0`"
+ ]>
+ ];
+}
+
+def olMemDataUnLock : Function {
+ let desc = "Unlocks / unpins host memory using the plugin runtime.";
+ let params = [
+ Param<"ol_device_handle_t", "Device", "handle of the device to allocate on", PARAM_IN>,
+ Param<"void *", "Ptr", "Host Pointer", PARAM_IN>
+ ];
+ let returns = [];
+}
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index eab9627217ca8..f17a2e7c5a7e8 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -1214,5 +1214,20 @@ Error olLaunchHostFunction_impl(ol_queue_handle_t Queue,
Queue->AsyncInfo);
}
+Error olMemDataLock_impl(ol_device_handle_t Device, void *Ptr, size_t Size,
+ void** LockedPtr) {
+ Expected<void*> LockedPtrOrErr = Device->Device->dataLock(Ptr, Size);
+ if (!LockedPtrOrErr)
+ return LockedPtrOrErr.takeError();
+
+ *LockedPtr = *LockedPtrOrErr;
+
+ return Error::success();
+}
+
+Error olMemDataUnLock_impl(ol_device_handle_t Device, void *Ptr) {
+ return Device->Device->dataUnlock(Ptr);
+}
+
} // namespace offload
} // namespace llvm
>From 127bda393c8b459e12925cc7b5ab686941aba42d Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Mon, 22 Dec 2025 09:54:34 -0800
Subject: [PATCH 2/8] Fix format issues
---
offload/liboffload/src/OffloadImpl.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index f17a2e7c5a7e8..7709e879c0dfa 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -1215,8 +1215,8 @@ Error olLaunchHostFunction_impl(ol_queue_handle_t Queue,
}
Error olMemDataLock_impl(ol_device_handle_t Device, void *Ptr, size_t Size,
- void** LockedPtr) {
- Expected<void*> LockedPtrOrErr = Device->Device->dataLock(Ptr, Size);
+ void **LockedPtr) {
+ Expected<void *> LockedPtrOrErr = Device->Device->dataLock(Ptr, Size);
if (!LockedPtrOrErr)
return LockedPtrOrErr.takeError();
>From 938bee5729b4eade86dee879c822d9470557d1b1 Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Mon, 22 Dec 2025 17:43:44 -0800
Subject: [PATCH 3/8] Address PR comments
---
offload/liboffload/API/Memory.td | 26 ++++++++++++++++----------
offload/liboffload/src/OffloadImpl.cpp | 5 +++--
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/offload/liboffload/API/Memory.td b/offload/liboffload/API/Memory.td
index cf77055837155..21f2959abb0eb 100644
--- a/offload/liboffload/API/Memory.td
+++ b/offload/liboffload/API/Memory.td
@@ -19,6 +19,11 @@ def ol_alloc_type_t : Enum {
];
}
+def ol_memory_register_flags_t : Typedef {
+ let desc = "Memory registering/locking flags";
+ let value = "uint32_t";
+}
+
def olMemAlloc : Function {
let desc = "Creates a memory allocation on the specified device.";
let details = [
@@ -132,13 +137,14 @@ def olMemFill : Function {
];
}
-def olMemDataLock : Function {
- let desc = "Locks / pins host memory using the plugin runtime.";
+def olMemRegister : Function {
+ let desc = "Register and page-lock host memory so it can be accessible by the device.";
let params = [
- Param<"ol_device_handle_t", "Device", "handle of the device to allocate on", PARAM_IN>,
- Param<"void *", "Ptr", "Host Pointer", PARAM_IN>,
- Param<"size_t", "Size", "size of the allocation in bytes", PARAM_IN>,
- Param<"void**", "LockedPtr", "output for the allocated pointer", PARAM_OUT>
+ Param<"ol_device_handle_t", "Device", "handle of the device", PARAM_IN>,
+ Param<"void *", "Ptr", "host pointer", PARAM_IN>,
+ Param<"size_t", "Size", "size of the memory in bytes", PARAM_IN>,
+ Param<"ol_memory_register_flags_t", "Flags", "flags. Reserved for future use", PARAM_IN>,
+ Param<"void**", "LockedPtr", "pointer to the locked memory", PARAM_OUT>
];
let returns = [
Return<"OL_ERRC_INVALID_SIZE", [
@@ -147,11 +153,11 @@ def olMemDataLock : Function {
];
}
-def olMemDataUnLock : Function {
- let desc = "Unlocks / unpins host memory using the plugin runtime.";
+def olMemUnregister : Function {
+ let desc = "Unregister and page-unlock host memory.";
let params = [
- Param<"ol_device_handle_t", "Device", "handle of the device to allocate on", PARAM_IN>,
- Param<"void *", "Ptr", "Host Pointer", PARAM_IN>
+ Param<"ol_device_handle_t", "Device", "handle of the device", PARAM_IN>,
+ Param<"void *", "Ptr", "host pointer", PARAM_IN>
];
let returns = [];
}
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index 7709e879c0dfa..c35e678158b23 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -1214,7 +1214,8 @@ Error olLaunchHostFunction_impl(ol_queue_handle_t Queue,
Queue->AsyncInfo);
}
-Error olMemDataLock_impl(ol_device_handle_t Device, void *Ptr, size_t Size,
+Error olMemRegister_impl(ol_device_handle_t Device, void *Ptr, size_t Size,
+ ol_memory_register_flags_t flags,
void **LockedPtr) {
Expected<void *> LockedPtrOrErr = Device->Device->dataLock(Ptr, Size);
if (!LockedPtrOrErr)
@@ -1225,7 +1226,7 @@ Error olMemDataLock_impl(ol_device_handle_t Device, void *Ptr, size_t Size,
return Error::success();
}
-Error olMemDataUnLock_impl(ol_device_handle_t Device, void *Ptr) {
+Error olMemUnregister_impl(ol_device_handle_t Device, void *Ptr) {
return Device->Device->dataUnlock(Ptr);
}
>From 14e020722ba908d785eb9063ef7a3fe9d464f357 Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Mon, 22 Dec 2025 18:40:01 -0800
Subject: [PATCH 4/8] Add more description details
---
offload/liboffload/API/Memory.td | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/offload/liboffload/API/Memory.td b/offload/liboffload/API/Memory.td
index 21f2959abb0eb..a35202d059cd9 100644
--- a/offload/liboffload/API/Memory.td
+++ b/offload/liboffload/API/Memory.td
@@ -139,6 +139,14 @@ def olMemFill : Function {
def olMemRegister : Function {
let desc = "Register and page-lock host memory so it can be accessible by the device.";
+ let details = [
+ "Pins host memory to optimize transfers and returns the device accessible",
+ "pointer that devices should use for memory transfers involving the host",
+ "pinned allocation. If the buffer intersects with other existing buffer,",
+ "a new user will be registered. A partial overlapping is not allowed.",
+ "The locked pointer can be accessed both on host and device and",
+ "no guarantees are made about consistency."
+ ];
let params = [
Param<"ol_device_handle_t", "Device", "handle of the device", PARAM_IN>,
Param<"void *", "Ptr", "host pointer", PARAM_IN>,
@@ -155,6 +163,11 @@ def olMemRegister : Function {
def olMemUnregister : Function {
let desc = "Unregister and page-unlock host memory.";
+ let details = [
+ "Unpins host memory that was previously pinned or unregister the buffer",
+ "if other users are still using the buffer. If no users are using the buffer",
+ "the memory is unlocked."
+ ];
let params = [
Param<"ol_device_handle_t", "Device", "handle of the device", PARAM_IN>,
Param<"void *", "Ptr", "host pointer", PARAM_IN>
>From 0e1a2b132243d48fb584a30c7a54041adf1801a4 Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Mon, 5 Jan 2026 21:09:58 -0800
Subject: [PATCH 5/8] Address PR comments and att unit tests
---
offload/liboffload/API/Memory.td | 9 ++-
offload/unittests/OffloadAPI/CMakeLists.txt | 3 +-
.../OffloadAPI/memory/olMemRegister.cpp | 81 +++++++++++++++++++
3 files changed, 89 insertions(+), 4 deletions(-)
create mode 100644 offload/unittests/OffloadAPI/memory/olMemRegister.cpp
diff --git a/offload/liboffload/API/Memory.td b/offload/liboffload/API/Memory.td
index a35202d059cd9..c37beb67b06ce 100644
--- a/offload/liboffload/API/Memory.td
+++ b/offload/liboffload/API/Memory.td
@@ -144,15 +144,18 @@ def olMemRegister : Function {
"pointer that devices should use for memory transfers involving the host",
"pinned allocation. If the buffer intersects with other existing buffer,",
"a new user will be registered. A partial overlapping is not allowed.",
- "The locked pointer can be accessed both on host and device and",
- "no guarantees are made about consistency."
+ "The pinned pointer can be accessed both on host and device and",
+ "no guarantees are made about consistency.",
+ "The pinned pointer should be used to execute memory transfers.",
+ "The functionality is currently implemented for AMD only",
+ "where memory is pinned for all devices."
];
let params = [
Param<"ol_device_handle_t", "Device", "handle of the device", PARAM_IN>,
Param<"void *", "Ptr", "host pointer", PARAM_IN>,
Param<"size_t", "Size", "size of the memory in bytes", PARAM_IN>,
Param<"ol_memory_register_flags_t", "Flags", "flags. Reserved for future use", PARAM_IN>,
- Param<"void**", "LockedPtr", "pointer to the locked memory", PARAM_OUT>
+ Param<"void**", "PinnedPtr", "pointer to the pinned memory", PARAM_OUT>
];
let returns = [
Return<"OL_ERRC_INVALID_SIZE", [
diff --git a/offload/unittests/OffloadAPI/CMakeLists.txt b/offload/unittests/OffloadAPI/CMakeLists.txt
index 50c99a5d5b639..546d7dac692d3 100644
--- a/offload/unittests/OffloadAPI/CMakeLists.txt
+++ b/offload/unittests/OffloadAPI/CMakeLists.txt
@@ -29,7 +29,8 @@ add_offload_unittest("memory"
memory/olMemFree.cpp
memory/olMemcpy.cpp
memory/olGetMemInfo.cpp
- memory/olGetMemInfoSize.cpp)
+ memory/olGetMemInfoSize.cpp
+ memory/olMemRegister.cpp)
add_offload_unittest("platform"
platform/olGetPlatformInfo.cpp
diff --git a/offload/unittests/OffloadAPI/memory/olMemRegister.cpp b/offload/unittests/OffloadAPI/memory/olMemRegister.cpp
new file mode 100644
index 0000000000000..f54e23db8c19b
--- /dev/null
+++ b/offload/unittests/OffloadAPI/memory/olMemRegister.cpp
@@ -0,0 +1,81 @@
+//===------- Offload API tests - olMemRegister -----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "../common/Fixtures.hpp"
+#include <OffloadAPI.h>
+#include <gtest/gtest.h>
+
+using olMemRegisterTest = OffloadDeviceTest;
+OFFLOAD_TESTS_INSTANTIATE_DEVICE_FIXTURE(olMemRegisterTest);
+
+TEST_P(olMemRegisterTest, SuccessRegister) {
+ int Arr[50];
+ ol_memory_register_flags_t Flags={};
+ void *PinnedPtr = nullptr;
+ ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr));
+ ASSERT_NE(PinnedPtr, nullptr);
+ ASSERT_SUCCESS(olMemUnregister(Device, PinnedPtr));
+}
+
+TEST_P(olMemRegisterTest, SuccessMultipleRegister) {
+ int Arr[50];
+ ol_memory_register_flags_t Flags={};
+ void *PinnedPtr = nullptr;
+ void *PinnedPtr1 = nullptr;
+ ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr));
+ ASSERT_NE(PinnedPtr, nullptr);
+ ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr1));
+ ASSERT_NE(PinnedPtr1, nullptr);
+ ASSERT_SUCCESS(olMemUnregister(Device, PinnedPtr));
+ ASSERT_SUCCESS(olMemUnregister(Device, PinnedPtr1));
+}
+
+TEST_P(olMemRegisterTest, InvalidSizeRegister) {
+ int Arr[50];
+ ol_memory_register_flags_t Flags={};
+ void *PinnedPtr = nullptr;
+ ASSERT_ERROR(OL_ERRC_INVALID_SIZE, olMemRegister(Device, Arr, 0, Flags, &PinnedPtr));
+}
+
+TEST_P(olMemRegisterTest, InvalidPtrRegister) {
+ int Arr[50];
+ ol_memory_register_flags_t Flags={};
+ void *PinnedPtr = nullptr;
+ ASSERT_ERROR(OL_ERRC_INVALID_NULL_POINTER, olMemRegister(Device, nullptr, sizeof(Arr), Flags, &PinnedPtr));
+}
+
+TEST_P(olMemRegisterTest, InvalidPtrUnRegister) {
+ int Arr[50];
+ ol_memory_register_flags_t Flags={};
+ void *PinnedPtr = nullptr;
+ ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr));
+ ASSERT_NE(PinnedPtr, nullptr);
+ ASSERT_ERROR(OL_ERRC_INVALID_NULL_POINTER, olMemUnregister(Device, nullptr));
+ ASSERT_SUCCESS(olMemUnregister(Device, PinnedPtr));
+}
+
+TEST_P(olMemRegisterTest, UnregisteredPtrUnRegister) {
+ int Arr[50];
+ int Arr1[50];
+ ol_memory_register_flags_t Flags={};
+ void *PinnedPtr = nullptr;
+ ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr));
+ ASSERT_NE(PinnedPtr, nullptr);
+ ASSERT_ERROR(OL_ERRC_INVALID_ARGUMENT, olMemUnregister(Device, Arr1));
+ ASSERT_SUCCESS(olMemUnregister(Device, PinnedPtr));
+}
+
+TEST_P(olMemRegisterTest, PartialOverlapPtrRegister) {
+ int Arr[50];
+ ol_memory_register_flags_t Flags={};
+ void *PinnedPtr = nullptr;
+ ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr));
+ ASSERT_NE(PinnedPtr, nullptr);
+ ASSERT_ERROR(OL_ERRC_INVALID_ARGUMENT, olMemRegister(Device, Arr + 2 , sizeof(Arr), Flags, &PinnedPtr));
+ ASSERT_SUCCESS(olMemUnregister(Device, PinnedPtr));
+}
>From e23bbbdb2a10d2a9a91c98d5eb4b25afc4c70fc4 Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Tue, 6 Jan 2026 09:37:55 -0800
Subject: [PATCH 6/8] Make level zero plugin behave the same way as other
plugins for unsupported memory locking API
---
offload/plugins-nextgen/level_zero/include/L0Device.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/offload/plugins-nextgen/level_zero/include/L0Device.h b/offload/plugins-nextgen/level_zero/include/L0Device.h
index ada7450302aaf..9490bed28435b 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Device.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Device.h
@@ -554,9 +554,10 @@ class L0DeviceTy final : public GenericDeviceTy {
TargetAllocTy Kind) override;
Error free(void *TgtPtr, TargetAllocTy Kind = TARGET_ALLOC_DEFAULT) override;
+ /// This plugin does nothing to lock buffers. Do not return an error, just
+ /// return the same pointer as the device pointer.
Expected<void *> dataLockImpl(void *HstPtr, int64_t Size) override {
- return Plugin::error(error::ErrorCode::UNKNOWN,
- "dataLockImpl not supported");
+ return HstPtr;
}
Error dataUnlockImpl(void *HstPtr) override { return Plugin::success(); }
>From e3d12060d1fe5409551d2e28679d600e4e2b9bfd Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Thu, 8 Jan 2026 14:27:32 -0800
Subject: [PATCH 7/8] Update API description
---
offload/liboffload/API/Memory.td | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/offload/liboffload/API/Memory.td b/offload/liboffload/API/Memory.td
index c37beb67b06ce..7e8c013819f87 100644
--- a/offload/liboffload/API/Memory.td
+++ b/offload/liboffload/API/Memory.td
@@ -141,14 +141,13 @@ def olMemRegister : Function {
let desc = "Register and page-lock host memory so it can be accessible by the device.";
let details = [
"Pins host memory to optimize transfers and returns the device accessible",
- "pointer that devices should use for memory transfers involving the host",
+ "stable pointer that devices should use for memory transfers involving the host",
"pinned allocation. If the buffer intersects with other existing buffer,",
"a new user will be registered. A partial overlapping is not allowed.",
"The pinned pointer can be accessed both on host and device and",
"no guarantees are made about consistency.",
- "The pinned pointer should be used to execute memory transfers.",
- "The functionality is currently implemented for AMD only",
- "where memory is pinned for all devices."
+ "The pinned pointer should be used to execute memory transfers",
+ "as it is a stable pointer for memory access."
];
let params = [
Param<"ol_device_handle_t", "Device", "handle of the device", PARAM_IN>,
>From 4da9d3235fc248ce508696e67edad4f4f670f446 Mon Sep 17 00:00:00 2001
From: "Fine, Gregory" <gregory.fine at intel.com>
Date: Thu, 8 Jan 2026 14:56:29 -0800
Subject: [PATCH 8/8] Fix formatting issues
---
offload/liboffload/src/OffloadImpl.cpp | 3 +--
.../OffloadAPI/memory/olMemRegister.cpp | 25 +++++++++++--------
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index 2fde20032d997..4a4f6652054a1 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -1217,8 +1217,7 @@ Error olLaunchHostFunction_impl(ol_queue_handle_t Queue,
}
Error olMemRegister_impl(ol_device_handle_t Device, void *Ptr, size_t Size,
- ol_memory_register_flags_t flags,
- void **LockedPtr) {
+ ol_memory_register_flags_t flags, void **LockedPtr) {
Expected<void *> LockedPtrOrErr = Device->Device->dataLock(Ptr, Size);
if (!LockedPtrOrErr)
return LockedPtrOrErr.takeError();
diff --git a/offload/unittests/OffloadAPI/memory/olMemRegister.cpp b/offload/unittests/OffloadAPI/memory/olMemRegister.cpp
index f54e23db8c19b..6c81dfab5ea24 100644
--- a/offload/unittests/OffloadAPI/memory/olMemRegister.cpp
+++ b/offload/unittests/OffloadAPI/memory/olMemRegister.cpp
@@ -1,4 +1,4 @@
-//===------- Offload API tests - olMemRegister -----------------------------===//
+//===------- Offload API tests - olMemRegister ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,7 +15,7 @@ OFFLOAD_TESTS_INSTANTIATE_DEVICE_FIXTURE(olMemRegisterTest);
TEST_P(olMemRegisterTest, SuccessRegister) {
int Arr[50];
- ol_memory_register_flags_t Flags={};
+ ol_memory_register_flags_t Flags = {};
void *PinnedPtr = nullptr;
ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr));
ASSERT_NE(PinnedPtr, nullptr);
@@ -24,7 +24,7 @@ TEST_P(olMemRegisterTest, SuccessRegister) {
TEST_P(olMemRegisterTest, SuccessMultipleRegister) {
int Arr[50];
- ol_memory_register_flags_t Flags={};
+ ol_memory_register_flags_t Flags = {};
void *PinnedPtr = nullptr;
void *PinnedPtr1 = nullptr;
ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr));
@@ -37,21 +37,23 @@ TEST_P(olMemRegisterTest, SuccessMultipleRegister) {
TEST_P(olMemRegisterTest, InvalidSizeRegister) {
int Arr[50];
- ol_memory_register_flags_t Flags={};
+ ol_memory_register_flags_t Flags = {};
void *PinnedPtr = nullptr;
- ASSERT_ERROR(OL_ERRC_INVALID_SIZE, olMemRegister(Device, Arr, 0, Flags, &PinnedPtr));
+ ASSERT_ERROR(OL_ERRC_INVALID_SIZE,
+ olMemRegister(Device, Arr, 0, Flags, &PinnedPtr));
}
TEST_P(olMemRegisterTest, InvalidPtrRegister) {
int Arr[50];
- ol_memory_register_flags_t Flags={};
+ ol_memory_register_flags_t Flags = {};
void *PinnedPtr = nullptr;
- ASSERT_ERROR(OL_ERRC_INVALID_NULL_POINTER, olMemRegister(Device, nullptr, sizeof(Arr), Flags, &PinnedPtr));
+ ASSERT_ERROR(OL_ERRC_INVALID_NULL_POINTER,
+ olMemRegister(Device, nullptr, sizeof(Arr), Flags, &PinnedPtr));
}
TEST_P(olMemRegisterTest, InvalidPtrUnRegister) {
int Arr[50];
- ol_memory_register_flags_t Flags={};
+ ol_memory_register_flags_t Flags = {};
void *PinnedPtr = nullptr;
ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr));
ASSERT_NE(PinnedPtr, nullptr);
@@ -62,7 +64,7 @@ TEST_P(olMemRegisterTest, InvalidPtrUnRegister) {
TEST_P(olMemRegisterTest, UnregisteredPtrUnRegister) {
int Arr[50];
int Arr1[50];
- ol_memory_register_flags_t Flags={};
+ ol_memory_register_flags_t Flags = {};
void *PinnedPtr = nullptr;
ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr));
ASSERT_NE(PinnedPtr, nullptr);
@@ -72,10 +74,11 @@ TEST_P(olMemRegisterTest, UnregisteredPtrUnRegister) {
TEST_P(olMemRegisterTest, PartialOverlapPtrRegister) {
int Arr[50];
- ol_memory_register_flags_t Flags={};
+ ol_memory_register_flags_t Flags = {};
void *PinnedPtr = nullptr;
ASSERT_SUCCESS(olMemRegister(Device, Arr, sizeof(Arr), Flags, &PinnedPtr));
ASSERT_NE(PinnedPtr, nullptr);
- ASSERT_ERROR(OL_ERRC_INVALID_ARGUMENT, olMemRegister(Device, Arr + 2 , sizeof(Arr), Flags, &PinnedPtr));
+ ASSERT_ERROR(OL_ERRC_INVALID_ARGUMENT,
+ olMemRegister(Device, Arr + 2 , sizeof(Arr), Flags, &PinnedPtr));
ASSERT_SUCCESS(olMemUnregister(Device, PinnedPtr));
}
More information about the llvm-commits
mailing list