MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / DeviceAllocate

Method DeviceAllocate

tensorflow/stream_executor/cuda/cuda_driver.cc:782–803  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

780}
781
782/* static */ void* GpuDriver::DeviceAllocate(GpuContext* context,
783 uint64 bytes) {
784 if (bytes == 0) {
785 return nullptr;
786 }
787
788 ScopedActivateContext activated{context};
789 CUdeviceptr result = 0;
790 CUresult res = cuMemAlloc(&result, bytes);
791 if (res != CUDA_SUCCESS) {
792 // LOG(INFO) because this isn't always important to users (e.g. BFCAllocator
793 // implements a retry if the first allocation fails).
794 LOG(INFO) << "failed to allocate "
795 << port::HumanReadableNumBytes::ToString(bytes) << " (" << bytes
796 << " bytes) from device: " << ToString(res);
797 return nullptr;
798 }
799 void* ptr = reinterpret_cast<void*>(result);
800 VLOG(2) << "allocated " << ptr << " for context " << context->context()
801 << " of " << bytes << " bytes";
802 return ptr;
803}
804
805/* static */ void GpuDriver::DeviceDeallocate(GpuContext* context,
806 void* location) {

Callers

nothing calls this directly

Calls 2

ToStringFunction · 0.70
contextMethod · 0.45

Tested by

no test coverage detected