| 49 | } |
| 50 | |
| 51 | TEST(GPUVMemAllocatorTest, VMemCreate) { |
| 52 | PlatformGpuId platform_gpu_id(0); |
| 53 | se::StreamExecutor* se = |
| 54 | GpuIdUtil::ExecutorForPlatformGpuId(platform_gpu_id).ValueOrDie(); |
| 55 | GPUMemAllocator* sub_allocator = new GPUMemAllocator( |
| 56 | se, platform_gpu_id, false /*use_unified_memory*/, {}, {}); |
| 57 | Allocator* device_allocator = new GPUBFCAllocator(sub_allocator, 1 << 30, "GPU_0_bfc"); |
| 58 | |
| 59 | // VMEM disabled, expect OOM |
| 60 | setenv("TF_GPU_VMEM", "false", 1); |
| 61 | Allocator* allocator = maybe_create_gpu_vmem_allocator(device_allocator, |
| 62 | 0, platform_gpu_id, 0, se); |
| 63 | void* raw_ptr = allocator->AllocateRaw(1, (1 << 30) + 1024); |
| 64 | CHECK_EQ(raw_ptr, nullptr); |
| 65 | |
| 66 | // VMEM enabled, expect success |
| 67 | setenv("TF_GPU_VMEM", "true", 1); |
| 68 | setenv("TF_CUDA_HOST_MEM_LIMIT_IN_MB", "1025", 1); |
| 69 | allocator = maybe_create_gpu_vmem_allocator(device_allocator, |
| 70 | 0, platform_gpu_id, 0, se); |
| 71 | raw_ptr = allocator->AllocateRaw(1, (1 << 30) + 1024); |
| 72 | CHECK_NE(raw_ptr, nullptr); |
| 73 | |
| 74 | // VMEM enbaled, but exceeds host memory size, expect OOM |
| 75 | setenv("TF_GPU_VMEM", "true", 1); |
| 76 | setenv("TF_CUDA_HOST_MEM_LIMIT_IN_MB", "1024", 1); |
| 77 | allocator = maybe_create_gpu_vmem_allocator(device_allocator, |
| 78 | 0, platform_gpu_id, 0, se); |
| 79 | raw_ptr = allocator->AllocateRaw(1, (1 << 30) + 1024); |
| 80 | CHECK_EQ(raw_ptr, nullptr); |
| 81 | } |
| 82 | |
| 83 | TEST(GPUVMemAllocatorTest, VMemNoDups) { |
| 84 | PlatformGpuId platform_gpu_id(0); |
nothing calls this directly
no test coverage detected