Skip to content

Commit

Permalink
Add tests for cu::DeviceMemory operator T *()
Browse files Browse the repository at this point in the history
  • Loading branch information
csbnw committed Sep 21, 2023
1 parent 7435205 commit d86bb12
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_cu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit d86bb12

Please sign in to comment.