diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index 661824804..346764888 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -1753,7 +1753,8 @@ class Manager * @param totalQueues The total number of compute queues to create. */ Manager(uint32_t physicalDeviceIndex, - const std::vector& familyQueueIndices = {}); + const std::vector& familyQueueIndices = {}, + const std::vector& desiredExtensions = {}); /** * Manager constructor which allows your own vulkan application to integrate @@ -1839,7 +1840,8 @@ class Manager // Create functions void createInstance(); void createDevice(const std::vector& familyQueueIndices = {}, - uint32_t hysicalDeviceIndex = 0); + uint32_t hysicalDeviceIndex = 0, + const std::vector& desiredExtensions = {}); }; } // End namespace kp diff --git a/test/TestMultipleAlgoExecutions.cpp b/test/TestMultipleAlgoExecutions.cpp index 7e772fc80..b94591308 100644 --- a/test/TestMultipleAlgoExecutions.cpp +++ b/test/TestMultipleAlgoExecutions.cpp @@ -16,8 +16,6 @@ TEST(TestMultipleAlgoExecutions, TestEndToEndFunctionality) std::string shader = (R"( #version 450 - #extension GL_EXT_shader_atomic_float: enable - layout (local_size_x = 1) in; // The input tensors bind index is relative to index in parameter passed @@ -36,8 +34,8 @@ TEST(TestMultipleAlgoExecutions, TestEndToEndFunctionality) void main() { uint index = gl_GlobalInvocationID.x; - atomicAdd(out_a[index], in_a[index] * in_b[index]); - atomicAdd(out_b[index], const_one * push_const.val); + out_a[index] += in_a[index] * in_b[index]; + out_b[index] += const_one * push_const.val; } )"); @@ -57,6 +55,7 @@ TEST(TestMultipleAlgoExecutions, TestEndToEndFunctionality) mgr.sequence() ->record(params) ->record(algorithm) + ->eval() ->record(algorithm, pushConstsB) ->eval(); diff --git a/test/TestPushConstant.cpp b/test/TestPushConstant.cpp index 184a3f66b..f51f8cc42 100644 --- a/test/TestPushConstant.cpp +++ b/test/TestPushConstant.cpp @@ -9,7 +9,6 @@ TEST(TestPushConstants, TestConstantsAlgoDispatchOverride) { std::string shader(R"( #version 450 - #extension GL_EXT_shader_atomic_float: enable layout(push_constant) uniform PushConstants { float x; float y; @@ -18,9 +17,9 @@ TEST(TestPushConstants, TestConstantsAlgoDispatchOverride) layout (local_size_x = 1) in; layout(set = 0, binding = 0) buffer a { float pa[]; }; void main() { - atomicAdd(pa[0], pcs.x); - atomicAdd(pa[1], pcs.y); - atomicAdd(pa[2], pcs.z); + pa[0] += pcs.x; + pa[1] += pcs.y; + pa[2] += pcs.z; })"); std::vector spirv = kp::Shader::compile_source(shader); @@ -28,21 +27,20 @@ TEST(TestPushConstants, TestConstantsAlgoDispatchOverride) std::shared_ptr sq = nullptr; { - kp::Manager mgr(0, {}, { "VK_EXT_shader_atomic_float", "SPV_EXT_shader_atomic_float_add" }); + kp::Manager mgr; std::shared_ptr tensor = mgr.tensor({ 0, 0, 0 }); std::shared_ptr algo = mgr.algorithm({ tensor }, spirv, kp::Workgroup({ 1 }), {}, { 0.0, 0.0, 0.0 }); - sq = mgr.sequence() - ->record({ tensor }) - ->record(algo, - kp::Constants{ 0.1, 0.2, 0.3 }) - ->record(algo, - kp::Constants{ 0.3, 0.2, 0.1 }) - ->record({ tensor }) - ->eval(); + sq = mgr.sequence()->eval({ tensor }); + + // We need to run this in sequence to avoid race condition + // We can't use atomicAdd as swiftshader doesn't support it for float + sq->eval(algo, kp::Constants{ 0.1, 0.2, 0.3 }); + sq->eval(algo, kp::Constants{ 0.3, 0.2, 0.1 }); + sq->eval({ tensor }); EXPECT_EQ(tensor->data(), kp::Constants({ 0.4, 0.4, 0.4 })); } @@ -54,7 +52,6 @@ TEST(TestPushConstants, TestConstantsAlgoDispatchNoOverride) { std::string shader(R"( #version 450 - #extension GL_EXT_shader_atomic_float: enable layout(push_constant) uniform PushConstants { float x; float y; @@ -63,9 +60,9 @@ TEST(TestPushConstants, TestConstantsAlgoDispatchNoOverride) layout (local_size_x = 1) in; layout(set = 0, binding = 0) buffer a { float pa[]; }; void main() { - atomicAdd(pa[0], pcs.x); - atomicAdd(pa[1], pcs.y); - atomicAdd(pa[2], pcs.z); + pa[0] += pcs.x; + pa[1] += pcs.y; + pa[2] += pcs.z; })"); std::vector spirv = kp::Shader::compile_source(shader); @@ -73,20 +70,20 @@ TEST(TestPushConstants, TestConstantsAlgoDispatchNoOverride) std::shared_ptr sq = nullptr; { - kp::Manager mgr(0, {}, { "VK_EXT_shader_atomic_float", "SPV_EXT_shader_atomic_float_add" }); + kp::Manager mgr; std::shared_ptr tensor = mgr.tensor({ 0, 0, 0 }); std::shared_ptr algo = mgr.algorithm({ tensor }, spirv, kp::Workgroup({ 1 }), {}, { 0.1, 0.2, 0.3 }); - sq = mgr.sequence() - ->record({ tensor }) - ->record(algo) - ->record(algo, - kp::Constants{ 0.3, 0.2, 0.1 }) - ->record({ tensor }) - ->eval(); + sq = mgr.sequence()->eval({ tensor }); + + // We need to run this in sequence to avoid race condition + // We can't use atomicAdd as swiftshader doesn't support it for float + sq->eval(algo); + sq->eval(algo, kp::Constants{ 0.3, 0.2, 0.1 }); + sq->eval({ tensor }); EXPECT_EQ(tensor->data(), kp::Constants({ 0.4, 0.4, 0.4 })); } @@ -98,7 +95,6 @@ TEST(TestPushConstants, TestConstantsWrongSize) { std::string shader(R"( #version 450 - #extension GL_EXT_shader_atomic_float: enable layout(push_constant) uniform PushConstants { float x; float y; @@ -107,9 +103,9 @@ TEST(TestPushConstants, TestConstantsWrongSize) layout (local_size_x = 1) in; layout(set = 0, binding = 0) buffer a { float pa[]; }; void main() { - atomicAdd(pa[0], pcs.x); - atomicAdd(pa[1], pcs.y); - atomicAdd(pa[2], pcs.z); + pa[0] += pcs.x; + pa[1] += pcs.y; + pa[2] += pcs.z; })"); std::vector spirv = kp::Shader::compile_source(shader); @@ -117,7 +113,7 @@ TEST(TestPushConstants, TestConstantsWrongSize) std::shared_ptr sq = nullptr; { - kp::Manager mgr(0, {}, { "VK_EXT_shader_atomic_float", "SPV_EXT_shader_atomic_float_add" }); + kp::Manager mgr; std::shared_ptr tensor = mgr.tensor({ 0, 0, 0 });