| 36 | namespace { |
| 37 | |
| 38 | TEST(GPUDebugAllocatorTest, OverwriteDetection_None) { |
| 39 | const PlatformGpuId platform_gpu_id(0); |
| 40 | GPUMemAllocator* sub_allocator = new GPUMemAllocator( |
| 41 | GpuIdUtil::ExecutorForPlatformGpuId(platform_gpu_id).ValueOrDie(), |
| 42 | platform_gpu_id, false /*use_unified_memory*/, {}, {}); |
| 43 | GPUDebugAllocator a(new GPUBFCAllocator(sub_allocator, 1 << 30, ""), |
| 44 | platform_gpu_id); |
| 45 | auto stream_exec = |
| 46 | GpuIdUtil::ExecutorForPlatformGpuId(platform_gpu_id).ValueOrDie(); |
| 47 | |
| 48 | for (int s : {8}) { |
| 49 | std::vector<int64> cpu_array(s); |
| 50 | memset(&cpu_array[0], 0, cpu_array.size() * sizeof(int64)); |
| 51 | int64* gpu_array = |
| 52 | TypedAllocator::Allocate<int64>(&a, cpu_array.size(), {}); |
| 53 | se::DeviceMemory<int64> gpu_array_ptr{se::DeviceMemoryBase{gpu_array}}; |
| 54 | ASSERT_TRUE(stream_exec->SynchronousMemcpy(&gpu_array_ptr, &cpu_array[0], |
| 55 | s * sizeof(int64))); |
| 56 | EXPECT_TRUE(a.CheckHeader(gpu_array)); |
| 57 | EXPECT_TRUE(a.CheckFooter(gpu_array)); |
| 58 | |
| 59 | // Confirm no error on free. |
| 60 | a.DeallocateRaw(gpu_array); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | TEST(GPUDebugAllocatorTest, OverwriteDetection_Header) { |
| 65 | for (int s : {8, 211}) { |
nothing calls this directly
no test coverage detected