MCPcopy Create free account
hub / github.com/KomputeProject/kompute / allocateMemoryCreateGPUResources

Method allocateMemoryCreateGPUResources

src/Tensor.cpp:395–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393}
394
395void
396Tensor::allocateMemoryCreateGPUResources()
397{
398 KP_LOG_DEBUG("Kompute Tensor creating buffer");
399
400 if (!this->mPhysicalDevice) {
401 throw std::runtime_error("Kompute Tensor phyisical device is null");
402 }
403 if (!this->mDevice) {
404 throw std::runtime_error("Kompute Tensor device is null");
405 }
406
407 KP_LOG_DEBUG("Kompute Tensor creating primary buffer and memory");
408
409 this->mPrimaryBuffer = std::make_shared<vk::Buffer>();
410 this->createBuffer(this->mPrimaryBuffer,
411 this->getPrimaryBufferUsageFlags());
412 this->mFreePrimaryBuffer = true;
413 this->mPrimaryMemory = std::make_shared<vk::DeviceMemory>();
414 this->allocateBindMemory(this->mPrimaryBuffer,
415 this->mPrimaryMemory,
416 this->getPrimaryMemoryPropertyFlags());
417 this->mFreePrimaryMemory = true;
418
419 if (this->mTensorType == TensorTypes::eDevice) {
420 KP_LOG_DEBUG("Kompute Tensor creating staging buffer and memory");
421
422 this->mStagingBuffer = std::make_shared<vk::Buffer>();
423 this->createBuffer(this->mStagingBuffer,
424 this->getStagingBufferUsageFlags());
425 this->mFreeStagingBuffer = true;
426 this->mStagingMemory = std::make_shared<vk::DeviceMemory>();
427 this->allocateBindMemory(this->mStagingBuffer,
428 this->mStagingMemory,
429 this->getStagingMemoryPropertyFlags());
430 this->mFreeStagingMemory = true;
431 }
432
433 KP_LOG_DEBUG("Kompute Tensor buffer & memory creation successful");
434}
435
436void
437Tensor::createBuffer(std::shared_ptr<vk::Buffer> buffer,

Callers 1

rebuildMethod · 0.95

Tested by

no test coverage detected