test case

This commit is contained in:
alexander-g 2021-03-07 14:16:50 +01:00
parent 6da6bca339
commit 259d3f1d13
4 changed files with 34 additions and 4 deletions

View file

@ -13,7 +13,7 @@ VCPKG_WIN_PATH ?= "C:\\Users\\axsau\\Programming\\lib\\vcpkg\\scripts\\buildsyst
VCPKG_UNIX_PATH ?= "/c/Users/axsau/Programming/lib/vcpkg/scripts/buildsystems/vcpkg.cmake"
# Regext to pass to catch2 to filter tests
FILTER_TESTS ?= "-TestAsyncOperations.TestManagerParallelExecution"
FILTER_TESTS ?= "-TestAsyncOperations.TestManagerParallelExecution:TestSequence.SequenceTimestamps"
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
CMAKE_BIN ?= "C:\Program Files\CMake\bin\cmake.exe"

View file

@ -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 total_timestamps)
Manager::sequence(uint32_t queueIndex, uint32_t totalTimestamps)
{
KP_LOG_DEBUG("Kompute Manager sequence() with queueIndex: {}", queueIndex);
@ -440,7 +440,7 @@ Manager::sequence(uint32_t queueIndex, uint32_t total_timestamps)
this->mDevice,
this->mComputeQueues[queueIndex],
this->mComputeQueueFamilyIndices[queueIndex],
total_timestamps) };
totalTimestamps) };
if (this->mManageResources) {
this->mManagedSequences.push_back(sq);

View file

@ -64,7 +64,7 @@ class Manager
* If zero (default), disables latching of timestamps.
* @returns Shared pointer with initialised sequence
*/
std::shared_ptr<Sequence> sequence(uint32_t queueIndex = 0, uint32_t nrOfTimestamps = 0);
std::shared_ptr<Sequence> sequence(uint32_t queueIndex = 0, uint32_t totalTimestamps = 0);
/**
* Create a managed tensor that will be destroyed by this manager

View file

@ -100,3 +100,33 @@ TEST(TestSequence, RerecordSequence)
EXPECT_EQ(tensorB->data(), std::vector<float>({2, 8, 18}));
}
TEST(TestSequence, SequenceTimestamps)
{
kp::Manager mgr;
std::shared_ptr<kp::Tensor> tensorA = mgr.tensor({ 0, 0, 0 });
std::string shader(R"(
#version 450
layout (local_size_x = 1) in;
layout(set = 0, binding = 0) buffer a { float pa[]; };
void main() {
uint index = gl_GlobalInvocationID.x;
pa[index] = pa[index] + 1;
})");
std::vector<uint32_t> spirv = kp::Shader::compile_source(shader);
auto seq = mgr.sequence(0, 100); //100 timestamps
seq->record<kp::OpTensorSyncDevice>({ tensorA })
->record<kp::OpAlgoDispatch>(mgr.algorithm({ tensorA }, spirv))
->record<kp::OpAlgoDispatch>(mgr.algorithm({ tensorA }, spirv))
->record<kp::OpAlgoDispatch>(mgr.algorithm({ tensorA }, spirv))
->record<kp::OpTensorSyncLocal>({ tensorA })
->eval();
const std::vector<uint64_t> timestamps = seq->getTimestamps();
EXPECT_EQ(timestamps.size(), 6); //1 timestamp at start + 1 after each operation
}