| 124 | }; |
| 125 | |
| 126 | TEST_F(GPUDeviceTest, CudaMallocAsync) { |
| 127 | SessionOptions opts = MakeSessionOptions("0", 0, 1, {}, |
| 128 | /*use_cuda_malloc_async=*/true); |
| 129 | std::vector<std::unique_ptr<Device>> devices; |
| 130 | Status status; |
| 131 | int number_instantiated = GpuCudaMallocAsyncAllocator::GetInstantiatedCountTestOnly(); |
| 132 | { // The new scope is to trigger the destruction of the object. |
| 133 | status = DeviceFactory::GetFactory("GPU")->CreateDevices( |
| 134 | opts, kDeviceNamePrefix, &devices); |
| 135 | EXPECT_EQ(devices.size(), 1); |
| 136 | Device* device = devices[0].get(); |
| 137 | auto* device_info = device->tensorflow_gpu_device_info(); |
| 138 | CHECK(device_info); |
| 139 | DeviceContext* device_context = device_info->default_context; |
| 140 | |
| 141 | AllocatorAttributes allocator_attributes = AllocatorAttributes(); |
| 142 | allocator_attributes.set_gpu_compatible(true); |
| 143 | Allocator* allocator = devices[0]->GetAllocator(allocator_attributes); |
| 144 | void* ptr = allocator->AllocateRaw(Allocator::kAllocatorAlignment, |
| 145 | 1024); |
| 146 | EXPECT_NE(ptr, nullptr); |
| 147 | allocator->DeallocateRaw(ptr); |
| 148 | } |
| 149 | EXPECT_EQ(number_instantiated + 1 , GpuCudaMallocAsyncAllocator::GetInstantiatedCountTestOnly()); |
| 150 | EXPECT_EQ(status.code(), error::OK); |
| 151 | } |
| 152 | |
| 153 | TEST_F(GPUDeviceTest, FailedToParseVisibleDeviceList) { |
| 154 | SessionOptions opts = MakeSessionOptions("0,abc"); |
nothing calls this directly
no test coverage detected