Skip to content

Commit

Permalink
Unify tensor and image sync operations.
Browse files Browse the repository at this point in the history
OpTensor/ImageSyncDevice -> OpSyncDevice
OpTensor/ImageSyncLocal -> OpSyncLocal

Signed-off-by: Robert Quill <robert.quill@imgtec.com>
  • Loading branch information
robquill committed Aug 27, 2024
1 parent 4fa4dfd commit 1cb86a1
Show file tree
Hide file tree
Showing 29 changed files with 355 additions and 604 deletions.
8 changes: 3 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ add_library(kompute Algorithm.cpp
OpMemoryBarrier.cpp
OpTensorCopy.cpp
OpTensorCopyToImage.cpp
OpTensorSyncDevice.cpp
OpTensorSyncLocal.cpp
OpSyncDevice.cpp
OpSyncLocal.cpp
Sequence.cpp
Tensor.cpp
Core.cpp
Image.cpp
Memory.cpp
OpImageCopy.cpp
OpImageCopyToTensor.cpp
OpImageSyncDevice.cpp
OpImageSyncLocal.cpp)
OpImageCopyToTensor.cpp)

add_library(kompute::kompute ALIAS kompute)

Expand Down
57 changes: 0 additions & 57 deletions src/OpImageSyncDevice.cpp

This file was deleted.

74 changes: 0 additions & 74 deletions src/OpImageSyncLocal.cpp

This file was deleted.

51 changes: 51 additions & 0 deletions src/OpSyncDevice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0

#include "kompute/operations/OpSyncDevice.hpp"

namespace kp {

OpSyncDevice::OpSyncDevice(
const std::vector<std::shared_ptr<Memory>>& memObjects)
{
KP_LOG_DEBUG("Kompute OpSyncDevice constructor with params");

if (memObjects.size() < 1) {
throw std::runtime_error(
"Kompute OpSyncDevice called with less than 1 memory object");
}

this->mMemObjects = memObjects;
}

OpSyncDevice::~OpSyncDevice()
{
KP_LOG_DEBUG("Kompute OpSyncDevice destructor started");

this->mMemObjects.clear();
}

void
OpSyncDevice::record(const vk::CommandBuffer& commandBuffer)
{
KP_LOG_DEBUG("Kompute OpSyncDevice record called");

for (size_t i = 0; i < this->mMemObjects.size(); i++) {
if (this->mMemObjects[i]->memoryType() == Tensor::MemoryTypes::eDevice) {
this->mMemObjects[i]->recordCopyFromStagingToDevice(commandBuffer);
}
}
}

void
OpSyncDevice::preEval(const vk::CommandBuffer& /*commandBuffer*/)
{
KP_LOG_DEBUG("Kompute OpSyncDevice preEval called");
}

void
OpSyncDevice::postEval(const vk::CommandBuffer& /*commandBuffer*/)
{
KP_LOG_DEBUG("Kompute OpSyncDevice postEval called");
}

}
70 changes: 70 additions & 0 deletions src/OpSyncLocal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// SPDX-License-Identifier: Apache-2.0

#include "kompute/Tensor.hpp"

#include "kompute/operations/OpSyncLocal.hpp"

namespace kp {

OpSyncLocal::OpSyncLocal(
const std::vector<std::shared_ptr<Memory>>& memObjects)
{
KP_LOG_DEBUG("Kompute OpSyncLocal constructor with params");

if (memObjects.size() < 1) {
throw std::runtime_error(
"Kompute OpSyncLocal called with less than 1 memory object");
}

this->mMemObjects = memObjects;
}

OpSyncLocal::~OpSyncLocal()
{
KP_LOG_DEBUG("Kompute OpSyncLocal destructor started");
}

void
OpSyncLocal::record(const vk::CommandBuffer& commandBuffer)
{
KP_LOG_DEBUG("Kompute OpSyncLocal record called");

for (size_t i = 0; i < this->mMemObjects.size(); i++) {
if (this->mMemObjects[i]->memoryType() == Memory::MemoryTypes::eDevice) {

this->mMemObjects[i]->recordPrimaryMemoryBarrier(
commandBuffer,
vk::AccessFlagBits::eShaderWrite,
// FIXME: eTransferRead is not supported for the compute pipeline
vk::AccessFlagBits::eTransferRead,
vk::PipelineStageFlagBits::eComputeShader,
vk::PipelineStageFlagBits::eTransfer);

this->mMemObjects[i]->recordCopyFromDeviceToStaging(commandBuffer);

this->mMemObjects[i]->recordPrimaryMemoryBarrier(
commandBuffer,
// FIXME: eTransferRead is not supported for the compute pipeline
vk::AccessFlagBits::eTransferWrite,
vk::AccessFlagBits::eHostRead,
vk::PipelineStageFlagBits::eTransfer,
vk::PipelineStageFlagBits::eHost);
}
}
}

void
OpSyncLocal::preEval(const vk::CommandBuffer& /*commandBuffer*/)
{
KP_LOG_DEBUG("Kompute OpSyncLocal preEval called");
}

void
OpSyncLocal::postEval(const vk::CommandBuffer& /*commandBuffer*/)
{
KP_LOG_DEBUG("Kompute OpSyncLocal postEval called");

KP_LOG_DEBUG("Kompute OpSyncLocal mapping data into tensor local");
}

}
57 changes: 0 additions & 57 deletions src/OpTensorSyncDevice.cpp

This file was deleted.

Loading

0 comments on commit 1cb86a1

Please sign in to comment.