Giter VIP home page Giter VIP logo

libvc's Introduction

Vulkan Compute for C++ (experimentation project)

libvc is a GPGPU engine based on Vulkan. It eats SPIR-V compute shaders and executes them without any graphical context, much like OpenCL. The interface is very abstract and allows you to get to work with your shaders as quickly as possible. With the current state of compute shaders, you should be able to achieve ~OpenCL 1.2 feature parity.

Compute shaders are constantly being evolved and extended with new versions of OpenGL, GLSL and/or Vulkan. They are here to stay and will only become more competent with time.

  • SSBO's allows for passing mutable linear global memory to your shaders.
  • Vulkan command buffers allows for recording commands once and replaying them multiple times, minimizing CPU overhead.
  • NVIDIA refuse to embrace OpenCL in favor of their proprietary CUDA alternative - but they do embrace Vulkan and OpenGL.

Overview

The interface is still being designed. It will feature abstractions for devices, memory, buffers, shaders, etc.

DevicePool devicePool;
for (Device &device : devicePool.getDevices()) {
    cout << "Found device: " << device.getName() << " from vendor: 0x"
         << hex << device.getVendorId() << dec << endl;

    try {
            // Allocate a buffer & clear it
            Buffer buffer(device, sizeof(double) * 10240);
            buffer.fill(0);

            // Compile the compute shader & prepare to use the buffer as argument
            Program program(device, "shaders/comp.spv", {BUFFER});
            Arguments args(program, {buffer});

            // Create and build the command buffer, making use of the program and arguments
            CommandBuffer commands(device, program, args);
            for (int i = 0; i < 100000; i++) {
                commands.dispatch(10);
                commands.barrier();
            }
            commands.end();

            // Time the execution on the GPU
            for (int i = 0; i < 5; i++) {
                steady_clock::time_point start = steady_clock::now();
                device.submit(commands);
                device.wait();
                cout << duration_cast<milliseconds>(steady_clock::now() - start).count() << "ms" << endl;
            }

            // Download results and show the first scalar
            double results[10240];
            buffer.download(results);
            cout << "Result: " << results[0] << endl;

    } catch(vc::Error e) {
        cout << "vc::Error thrown" << endl;
    }
}

libvc's People

Contributors

minzmann avatar unetworkingab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libvc's Issues

Memory Leaks

I've just browsed your code so far, but I've noticed a couple news without matching deletes, namely in vc.h in lines 99 and 189. Just a quick fix.

Out of line declaration

When I try to compile (using the makefile), I get this error:

src/commandbuffer.cpp:36:16: error: out-of-line declaration of a member must be a definition [-Wout-of-line-declaration]
CommandBuffer::CommandBuffer(Device &device, Program &program, Arguments &arguments);
~~~~~~~~~~~~~~~^

Crashes on Windows Nvidia driver..

I just downloaded a zipped copy of master branch a week ago and created Visual Studio project.. fixed link pointing to spv shader file but still crashes at:
" if (VK_SUCCESS != vkCreateComputePipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &pipeline)) {"
have you tested on Windows?
Specs:
GTX970 running Nv driver 364.47
Windows 10 Nov update TH1
VS 2015.1

Add real world example app

I have code that runs over large amoutns of data and does calculations, this should be made into the "poster boy" example of libvc to show real world usages. This will add both the algorithm itself, and also ensure you actually can build something real. I'm working on this and it should be ready some time soon if I get the time to finish it.

Improve performance

I have two versions of case1, a benchmark that aims to measure dispatch launch overhead in Vulkan vs OpenCL. Currently the OpenCL version is faster (~400ms vs ~700ms) on my GTX 980. This is being investigated by NVIDIA driver devs - I could have made some big mistake but it might also be a driver issue since things are pretty beta still.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.