requested changes
This commit is contained in:
parent
eb47d52047
commit
6da6bca339
5 changed files with 123 additions and 62 deletions
|
|
@ -431,7 +431,7 @@ Manager::algorithm(const std::vector<std::shared_ptr<Tensor>>& tensors,
|
|||
}
|
||||
|
||||
std::shared_ptr<Sequence>
|
||||
Manager::sequence(uint32_t queueIndex, uint32_t nrOfTimestamps)
|
||||
Manager::sequence(uint32_t queueIndex, uint32_t total_timestamps)
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute Manager sequence() with queueIndex: {}", queueIndex);
|
||||
|
||||
|
|
@ -440,7 +440,7 @@ Manager::sequence(uint32_t queueIndex, uint32_t nrOfTimestamps)
|
|||
this->mDevice,
|
||||
this->mComputeQueues[queueIndex],
|
||||
this->mComputeQueueFamilyIndices[queueIndex],
|
||||
nrOfTimestamps) };
|
||||
total_timestamps) };
|
||||
|
||||
if (this->mManageResources) {
|
||||
this->mManagedSequences.push_back(sq);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Sequence::Sequence(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
|
|||
std::shared_ptr<vk::Device> device,
|
||||
std::shared_ptr<vk::Queue> computeQueue,
|
||||
uint32_t queueIndex,
|
||||
uint32_t nrOfTimestamps)
|
||||
uint32_t totalTimestamps)
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute Sequence Constructor with existing device & queue");
|
||||
|
||||
|
|
@ -18,8 +18,8 @@ Sequence::Sequence(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
|
|||
|
||||
this->createCommandPool();
|
||||
this->createCommandBuffer();
|
||||
if(nrOfTimestamps>0)
|
||||
this->createTimestampQueryPool(nrOfTimestamps+1); //+1 for the first one
|
||||
if(totalTimestamps>0)
|
||||
this->createTimestampQueryPool(totalTimestamps+1); //+1 for the first one
|
||||
}
|
||||
|
||||
Sequence::~Sequence()
|
||||
|
|
@ -246,6 +246,16 @@ Sequence::destroy()
|
|||
this->mOperations.clear();
|
||||
}
|
||||
|
||||
if(this->timestampQueryPool){
|
||||
KP_LOG_INFO("Destroying QueryPool");
|
||||
this->mDevice->destroy(
|
||||
*this->timestampQueryPool,
|
||||
(vk::Optional<const vk::AllocationCallbacks>)nullptr);
|
||||
|
||||
this->timestampQueryPool = nullptr;
|
||||
KP_LOG_DEBUG("Kompute Sequence Destroyed QueryPool");
|
||||
}
|
||||
|
||||
if (this->mDevice) {
|
||||
this->mDevice = nullptr;
|
||||
}
|
||||
|
|
@ -325,11 +335,11 @@ Sequence::createCommandBuffer()
|
|||
}
|
||||
|
||||
void
|
||||
Sequence::createTimestampQueryPool(uint32_t query_size)
|
||||
Sequence::createTimestampQueryPool(uint32_t totalTimestamps)
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute Sequence creating query pool");
|
||||
if (!this->mDevice) {
|
||||
throw std::runtime_error("Kompute Sequence device is null");
|
||||
if (!this->isInit()) {
|
||||
throw std::runtime_error("createTimestampQueryPool() called on uninitialized Sequence");
|
||||
}
|
||||
if (!this->mPhysicalDevice) {
|
||||
throw std::runtime_error("Kompute Sequence physical device is null");
|
||||
|
|
@ -339,32 +349,29 @@ Sequence::createTimestampQueryPool(uint32_t query_size)
|
|||
this->mPhysicalDevice->getProperties();
|
||||
|
||||
if(physicalDeviceProperties.limits.timestampComputeAndGraphics){
|
||||
vk::QueryPoolCreateInfo queryPoolInfo;
|
||||
queryPoolInfo.setQueryCount(query_size);
|
||||
queryPoolInfo.setQueryType(vk::QueryType::eTimestamp);
|
||||
this->timestampQueryPool = std::make_shared<vk::QueryPool>(this->mDevice->createQueryPool(queryPoolInfo));
|
||||
vk::QueryPoolCreateInfo queryPoolInfo;
|
||||
queryPoolInfo.setQueryCount(totalTimestamps);
|
||||
queryPoolInfo.setQueryType(vk::QueryType::eTimestamp);
|
||||
this->timestampQueryPool = std::make_shared<vk::QueryPool>(this->mDevice->createQueryPool(queryPoolInfo));
|
||||
|
||||
KP_LOG_DEBUG("Query pool for timestamps created");
|
||||
KP_LOG_DEBUG("Query pool for timestamps created");
|
||||
}
|
||||
else{
|
||||
KP_LOG_DEBUG("Device does not support timestamps");
|
||||
throw std::runtime_error("Device does not support timestamps");
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::uint64_t>
|
||||
Sequence::getTimestamps(){
|
||||
Sequence::getTimestamps()
|
||||
{
|
||||
if(!this->timestampQueryPool)
|
||||
throw std::runtime_error("Timestamp latching not enabled");
|
||||
|
||||
const auto n = this->mOperations.size()+1;
|
||||
std::vector<std::uint64_t> timestamps(n, 0);
|
||||
//XXX: the C++ method this->mDevice->getQueryPoolResults does not compile for me
|
||||
const VkResult result =
|
||||
vkGetQueryPoolResults(*this->mDevice, *this->timestampQueryPool,
|
||||
0, n, timestamps.size()*sizeof(std::uint64_t), timestamps.data(),
|
||||
sizeof(uint64_t), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT);
|
||||
if(result!=VK_SUCCESS)
|
||||
throw std::runtime_error("vkGetQueryPoolResults failed");
|
||||
this->mDevice->getQueryPoolResults(*this->timestampQueryPool,
|
||||
0, n, timestamps.size()*sizeof(std::uint64_t), timestamps.data(),
|
||||
sizeof(uint64_t), vk::QueryResultFlagBits::e64 | vk::QueryResultFlagBits::eWait);
|
||||
|
||||
return timestamps;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ class Sequence : public std::enable_shared_from_this<Sequence>
|
|||
* @param device Vulkan logical device
|
||||
* @param computeQueue Vulkan compute queue
|
||||
* @param queueIndex Vulkan compute queue index in device
|
||||
* @param nrOfTimestamps Maximum number of timestamps to allocate
|
||||
* @param totalTimestamps Maximum number of timestamps to allocate
|
||||
*/
|
||||
Sequence(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
|
||||
std::shared_ptr<vk::Device> device,
|
||||
std::shared_ptr<vk::Queue> computeQueue,
|
||||
uint32_t queueIndex,
|
||||
uint32_t nrOfTimestamps = 0);
|
||||
uint32_t totalTimestamps = 0);
|
||||
/**
|
||||
* Destructor for sequence which is responsible for cleaning all subsequent
|
||||
* owned operations.
|
||||
|
|
@ -286,7 +286,7 @@ class Sequence : public std::enable_shared_from_this<Sequence>
|
|||
// Create functions
|
||||
void createCommandPool();
|
||||
void createCommandBuffer();
|
||||
void createTimestampQueryPool(uint32_t);
|
||||
void createTimestampQueryPool(uint32_t totalTimestamps);
|
||||
};
|
||||
|
||||
} // End namespace kp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue