No description
Find a file
2020-08-23 12:30:56 +01:00
external Updated to include and work with cpp header shaders 2020-08-23 12:30:56 +01:00
scripts Updated to include and work with cpp header shaders 2020-08-23 12:30:56 +01:00
seldon Added seldon 2020-08-05 08:12:51 +01:00
shaders Removed obsolete hpp header 2020-08-23 11:07:45 +01:00
src Updated to include and work with cpp header shaders 2020-08-23 12:30:56 +01:00
test Added initial base for iteration with command buffer and experimetation with baseoperator 2020-08-16 18:09:56 +01:00
.ccls Updated to include and work with cpp header shaders 2020-08-23 12:30:56 +01:00
.gitignore Reformat 2020-08-09 15:37:13 +01:00
Dockerfile Updated vulkan application to be containerised 2020-08-05 07:42:16 +01:00
Dockerfile.seldon Updated versions 2020-08-05 18:39:03 +00:00
Makefile Updated to include and work with cpp header shaders 2020-08-23 12:30:56 +01:00
pylintrc Added python converter for shader scripts 2020-08-23 09:50:44 +01:00
README.md Updated readme description 2020-08-23 06:50:52 +01:00

Vulkan Kompute

Principles

  • Single header easy to import library to boost your Vulkan compute experience
  • Non-vulkan naming convention to disambiguate Vulkan vs Kompute components
  • Extends the existing vulkan API with a simpler compute-specific interface
  • BYOV: Play nice with existing Vulkan applications with a bring-your-own-Vulkan design
  • TODO

Getting Started

Run your tensors against default or custom equations via the Manager.

int main() {

    kp::Manager mgr; // Automatically selects Device 0

    std::shared_ptr<kp::Tensor> tensorLHS{ new kp::Tensor({ 0.0, 1.0, 2.0 }) };
    mgr.evalOp<kp::OpCreateTensor>({ tensorLHS });

    std::shared_ptr<kp::Tensor> tensorRHS{ new kp::Tensor( { 2.0, 4.0, 6.0 }) };
    mgr.evalOp<kp::OpCreateTensor>({ tensorRHS });

    // TODO: Add capabilities for just output tensor types
    std::shared_ptr<kp::Tensor> tensorOutput{ new kp::Tensor({ 0.0, 0.0, 0.0 }) };
    mgr.evalOp<kp::OpCreateTensor>({ tensorOutput });

    mgr.evalOp<kp::OpMult>({ tensorLHS, tensorRHS, tensorOutput });

    std::cout << fmt::format("Output: {}", tensorOutput.data()) << std::endl;
}

Record commands in a single submit by using a Sequence.

int main() {
    kp::Manager mgr;

    std::shared_ptr<kp::Tensor> tensorLHS{ new kp::Tensor({ 0.0, 1.0, 2.0 }) };
    std::shared_ptr<kp::Tensor> tensorRHS{ new kp::Tensor( { 2.0, 4.0, 6.0 }) };
    std::shared_ptr<kp::Tensor> tensorOutput{ new kp::Tensor({ 0.0, 0.0, 0.0 }) };

    kp::Sequence sq = mgr.constructSequence();
    // Begin recoding commands
    sq.begin();

    // Record sequence of operations to be sent to GPU in batch
    {
        sq.record<kp::OpCreateTensor>({ tensorLHS });
        sq.record<kp::OpCreateTensor>({ tensorRHS });
        sq.record<kp::OpCreateTensor>({ tensorOutput });

        sq.record<kp::OpMult<>>({ tensorLHS, tensorRHS, tensorOutput });
    }
    // Stop recording
    sq.end();
    // Submit operations to GPU
    sq.eval();

    std::cout << fmt::format("Output: {}", tensorOutput.data()) << std::endl;
}

Create your own operation

class CustomOp : kp::OpBase {
    // ...
    void init(std::shared_ptr<Tensor> tensors) {
        // ... extra steps to initialise tensors
        this->mAlgorithm->init("path/to/your/shader.compute.spv", tensors);
    }
}

int main() {
    kp::Manager kManager(); // Chooses device 0 

    kp::Tensor inputOne({0, 1, 2, 3}); 

    kp::Tensor inputTwo({0, 1, 2, 3});

    kp::Tensor output( {0, 0, 0, 0} );
    kManager.eval<kp::CustomOp>({ inputOne, inputTwo, output });

    std::cout << fmt::format("Output: {}", tensorOutput.data()) << std::endl;
}

Development

Follows Mozilla C++ Style Guide https://www-archive.mozilla.org/hacking/mozilla-style-guide.html