예제 #1
0
void *ConvBaseProjection::getSpaceBytes(size_t size) {
  std::vector<MemoryHandlePtr> &convMem = *convMem_;
  if (convMem.empty()) {
    int numDevices = hl_get_device_count();
    convMem.resize(numDevices);
  }

  int devId = hl_get_device();
  MemoryHandlePtr localMem = convMem[devId];
  if (NULL == localMem || size > localMem->getAllocSize()) {
    localMem = std::make_shared<GpuMemoryHandle>(size);
  }
  return localMem->getBuf();
}
예제 #2
0
GpuMemoryHandle::GpuMemoryHandle(size_t size) : MemoryHandle(size) {
  CHECK(size != 0) << " allocate 0 bytes";
  deviceId_ = hl_get_device();
  allocator_ = StorageEngine::singleton()->getGpuAllocator(deviceId_);
  buf_ = allocator_->alloc(allocSize_);
}