From d86bb12bd5961f956725cbab32a66cf26228bdc9 Mon Sep 17 00:00:00 2001 From: Bram Veenboer Date: Thu, 21 Sep 2023 12:25:37 +0200 Subject: [PATCH] Add tests for cu::DeviceMemory operator T *() --- tests/test_cu.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_cu.cpp b/tests/test_cu.cpp index 769bcfbe..0f7805c7 100644 --- a/tests/test_cu.cpp +++ b/tests/test_cu.cpp @@ -143,4 +143,17 @@ TEST_CASE("Test zeroing cu::DeviceMemory", "[zero]") { CHECK(data_in == data_out); } + + SECTION("Test cu::DeviceMemory with CU_MEMORYTYPE_DEVICE as host pointer") { + cu::DeviceMemory mem(sizeof(float), CU_MEMORYTYPE_DEVICE, 0); + float* ptr; + CHECK_THROWS(ptr = mem); + } + + SECTION("Test cu::DeviceMemory with CU_MEMORYTYPE_UNIFIED as host pointer") { + cu::DeviceMemory mem(sizeof(float), CU_MEMORYTYPE_UNIFIED, + CU_MEM_ATTACH_GLOBAL); + float* ptr = mem; + CHECK_NOTHROW(ptr[0] = 42.f); + } }