No description
Find a file
2020-08-18 21:24:23 +01:00
external Removed glm dependency 2020-08-12 21:40:20 +01:00
seldon Added seldon 2020-08-05 08:12:51 +01:00
shaders Updated shaders to match example in slides 2020-08-04 21:12:09 +01:00
src updated typos and misaligned types 2020-08-18 21:24:23 +01:00
test Added initial base for iteration with command buffer and experimetation with baseoperator 2020-08-16 18:09:56 +01:00
.ccls Added initial base for opcreatetensor 2020-08-18 21:13:33 +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 Added latest seldon file 2020-08-08 17:27:05 +01:00
Makefile Added initial base for opcreatetensor 2020-08-18 21:13:33 +01:00
README.md Added initial base for opcreatetensor 2020-08-18 21:13:33 +01:00

Vulkan Kompute

Principles

  • 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

Use default equations

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

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

    kp::Tensor inputTwo;
    inputTwo = kManager.eval<kp::OpCreateTensor>(&inputTwo);

    kp::Tensor output = kManager.eval<kp::OpMult>(inputOne, inputTwo);

    std::cout << output << std::endl;
}
int main() {
    kp::Manager kManager(); // Chooses device 0 

    kp::Tensor inputOne = kManager.eval<kp::OpCreateTensor>({0, 1, 2, 3}); // Mounts to device and binds to 0
    kp::Tensor inputTwo = kManager.eval<kp::OpCreateTensor>({0, 1, 2, 3}); // Mounts to device and binds to 1


    kp::Tensor inputOne({0, 1, 2, 3}); 
    kManager.eval<kp::OpCreateTensor>(&inputOne); // Mounts to device and binds to 0

    kp::Tensor inputOne({0, 1, 2, 3}); 
    kManager.eval<kp::OpCreateTensor>(&inputTwo); // Mounts to device and binds to 0

    kp::Tensor output = kManager.eval<kp::OpMult>(inputOne, inputTwo);

    std::cout << output << std::endl;
}

Create your own operation

class CustomOp : kp::BaseOperator {
    CusomOp() {
        this->mAlgorithm = kp::Algorithm("path/to/your/shader.compute.spv")
    }

    kp::Tensor init(kp::Tensor* rhs, kp::Tensor* lhs, kp::Tensor* result) override {
        this->appendParameter(kp::Parameter(rhs)); // Binding 0
        this->appendParameter(kp::Parameter(lhs)); // Binding 1
        this->appendParameter(kp::Parameter(result)); // Binding 2
    }
}

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;
    kManager.eval<kp::CustomOp>(&inputOne, &inputTwo, &output);

    std::cout << output << std::endl;
}

Use equations to group operations on memory and execution step

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

    kp::Sequence sq;
    kManager.createSequence(&sq);

    sq.begin();

    kp::Tensor inputOne; 
    sq.record<kp::OpCreateTensor>(&inputOne, {0, 1, 2, 3}); // Mounts to device and binds to 0

    kp::Tensor inputTwo;
    sq.record<kp::OpCreateTensor>(&inputTwo, {0, 1, 2, 3}); // Mounts to device and binds to 1

    kp::Tensor output;
    sq.record<kp::OpMult>(&inputOne, &inputTwo, &output);

    sq.end();
    sq.eval();

    std::cout << output << std::endl;
}

Development

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