| 26 | namespace tensorflow { |
| 27 | |
| 28 | void* GPUVMemAllocator::AllocateRaw(size_t alignment, size_t num_bytes) { |
| 29 | mutex_lock l(lock_); |
| 30 | AllocationAttributes new_attr; |
| 31 | // Tell the device_allocator_ not to retry |
| 32 | // since we can alloc host memory as backup |
| 33 | new_attr.no_retry_on_failure = true; |
| 34 | void* ret = device_allocator_->AllocateRaw(alignment, num_bytes, new_attr); |
| 35 | if (ret != nullptr) { |
| 36 | device_ptrs_.insert(ret); |
| 37 | return ret; |
| 38 | } |
| 39 | ret = host_allocator_->AllocateRaw(alignment, num_bytes); |
| 40 | VLOG(3) << "host_allocator_ allocates " << (num_bytes/1024.0/1024) << " MiB"; |
| 41 | return ret; |
| 42 | } |
| 43 | |
| 44 | void* GPUVMemAllocator::AllocateRaw(size_t alignment, size_t num_bytes, |
| 45 | const AllocationAttributes& allocation_attr) { |