Merge pull request #262 from KomputeProject/axsaucedo-patch-3

Updating array_mutiplication example to work correctly
This commit is contained in:
Alejandro Saucedo 2022-01-30 10:42:13 +00:00 committed by GitHub
commit 05b31d9b3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 9 deletions

View file

@ -13,11 +13,15 @@ For users that are looking to quickly test the processors it is possible to use
.. code-block:: cpp
:linenos:
static std::vector<uint32_t>
static
std::vector<uint32_t>
compileSource(
const std::string& source)
{
if (system(std::string("glslangValidator --stdin -S comp -V -o tmp_kp_shader.comp.spv << END\n" + source + "\nEND").c_str()))
std::ofstream fileOut("tmp_kp_shader.comp");
fileOut << source;
fileOut.close();
if (system(std::string("glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv").c_str()))
throw std::runtime_error("Error running glslangValidator command");
std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary);
std::vector<char> buffer;
@ -25,6 +29,7 @@ For users that are looking to quickly test the processors it is possible to use
return {(uint32_t*)buffer.data(), (uint32_t*)(buffer.data() + buffer.size())};
}
Converting Shaders into C / C++ Header Files
----------------------------------

View file

@ -5,11 +5,15 @@
#include "kompute/Kompute.hpp"
static std::vector<uint32_t>
static
std::vector<uint32_t>
compileSource(
const std::string& source)
{
if (system(std::string("glslangValidator --stdin -S comp -V -o tmp_kp_shader.comp.spv << END\n" + source + "\nEND").c_str()))
std::ofstream fileOut("tmp_kp_shader.comp");
fileOut << source;
fileOut.close();
if (system(std::string("glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv").c_str()))
throw std::runtime_error("Error running glslangValidator command");
std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary);
std::vector<char> buffer;
@ -51,7 +55,7 @@ int main()
std::vector<std::shared_ptr<kp::Tensor>> params = { tensorInA, tensorInB, tensorOut };
std::shared_ptr<kp::Algorithm> algo = mgr.algorithm(params, kp_test_utils::compileSource(shader));
std::shared_ptr<kp::Algorithm> algo = mgr.algorithm(params, compileSource(shader));
mgr.sequence()
->record<kp::OpTensorSyncDevice>(params)

View file

@ -4,11 +4,15 @@
#include "KomputeSummatorNode.h"
static std::vector<uint32_t>
static
std::vector<uint32_t>
compileSource(
const std::string& source)
{
if (system(std::string("glslangValidator --stdin -S comp -V -o tmp_kp_shader.comp.spv << END\n" + source + "\nEND").c_str()))
std::ofstream fileOut("tmp_kp_shader.comp");
fileOut << source;
fileOut.close();
if (system(std::string("glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv").c_str()))
throw std::runtime_error("Error running glslangValidator command");
std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary);
std::vector<char> buffer;
@ -16,6 +20,7 @@ compileSource(
return {(uint32_t*)buffer.data(), (uint32_t*)(buffer.data() + buffer.size())};
}
KomputeSummatorNode::KomputeSummatorNode() {
this->_init();
}

View file

@ -5,11 +5,15 @@
#include "KomputeSummator.hpp"
static std::vector<uint32_t>
static
std::vector<uint32_t>
compileSource(
const std::string& source)
{
if (system(std::string("glslangValidator --stdin -S comp -V -o tmp_kp_shader.comp.spv << END\n" + source + "\nEND").c_str()))
std::ofstream fileOut("tmp_kp_shader.comp");
fileOut << source;
fileOut.close();
if (system(std::string("glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv").c_str()))
throw std::runtime_error("Error running glslangValidator command");
std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary);
std::vector<char> buffer;
@ -17,6 +21,7 @@ compileSource(
return {(uint32_t*)buffer.data(), (uint32_t*)(buffer.data() + buffer.size())};
}
namespace godot {
KomputeSummator::KomputeSummator() {