Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

push_constant not working in my case? #168

Closed
unexploredtest opened this issue Feb 28, 2021 · 28 comments · Fixed by #174
Closed

push_constant not working in my case? #168

unexploredtest opened this issue Feb 28, 2021 · 28 comments · Fixed by #174
Labels
bug Something isn't working c++

Comments

@unexploredtest
Copy link
Contributor

unexploredtest commented Feb 28, 2021

I tried both codes from README and the test (TestPushConstant.cpp), but apparently push_constant values all get zero value for some reasons?
Here is the result for TestPushConstant.cpp):

[alipmpaint@archlinux test]$ ./test_kompute
Running main() from /home/alipmpaint/Documents/github/vulkan-kompute/external/googletest/googletest/src/gtest_main.cc
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from TestPushConstants
[ RUN      ] TestPushConstants.TestTwoConstants
[2021-02-28 23:28:54.779] [info] [Shader.cpp:68] Kompute Shader Information: 


WARNING: radv is not a conformant vulkan implementation, testing use only.
[2021-02-28 23:28:54.940] [info] [Manager.cpp:269] Using physical device index 1 found AMD RADV VERDE (ACO)
[2021-02-28 23:28:54.947] [info] [Algorithm.cpp:18] Kompute Algorithm initialising with tensor size: 1 and spirv size: 292
[2021-02-28 23:28:54.947] [info] [Algorithm.cpp:395] Kompute OpAlgoCreate setting dispatch size
[2021-02-28 23:28:54.947] [info] [Algorithm.cpp:409] Kompute OpAlgoCreate set dispatch size X: 1, Y: 1, Z: 1
[2021-02-28 23:28:54.947] [info] [Sequence.cpp:44] Kompute Sequence command now started recording
[2021-02-28 23:28:54.947] [info] [Sequence.cpp:58] Kompute Sequence command recording END
/home/alipmpaint/Documents/github/vulkan-kompute/test/TestPushConstant.cpp:46: Failure
Expected equality of these values:
  tensor->data()
    Which is: { 0, 0, 0 }
  kp::Constants({ 0.4, 0.4, 0.4 })
    Which is: { 0.4, 0.4, 0.4 }
[2021-02-28 23:28:54.947] [info] [Sequence.cpp:186] Freeing CommandBuffer
[2021-02-28 23:28:54.947] [info] [Sequence.cpp:202] Destroying CommandPool
[2021-02-28 23:28:54.947] [info] [Sequence.cpp:219] Kompute Sequence clearing operations buffer
[2021-02-28 23:28:54.947] [info] [Manager.cpp:102] Destroying device
[2021-02-28 23:28:54.949] [warning] [Sequence.cpp:180] Kompute Sequence destroy called with null Device pointer
[  FAILED  ] TestPushConstants.TestTwoConstants (269 ms)
[----------] 1 test from TestPushConstants (269 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (269 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] TestPushConstants.TestTwoConstants

 1 FAILED TEST

(specConsts work fine btw)

I don't know where the problem exactly is... Since the tests have passed in Github actions and I have clones the same code, I guess it's local. I have two vulkan drivers, one is AMDVLK and the second one AMD RADV VERDE from mesa.
What I just described happens with AMD RADV VERDE . In AMDVLK, I get a segfault(I still haven't investigated whether it's the push_constant or not since I'm running out of time) in both codes. So, I guess it has something to do with my Vulkan drivers?

@axsaucedo
Copy link
Member

Thank you for reporting this @aliPMPAINT - could you try running the specific tests for the C++ push constants? Also can you give me a bit more info on your current AMD card + drivers? I'll be able to see whether it's actually an issue on the drivers.

@axsaucedo
Copy link
Member

Ah just realised the logs are from the tests, not from the readme - ok that's strange, did you clear your cmake build directory and rebuilt from scratch for this?

@axsaucedo
Copy link
Member

Also can you compile it with debug logs and post the logs here? That will show us whether the push consts are being set.

@axsaucedo
Copy link
Member

I just had a quick look and it seems that push constants are always available in drivers, but that it's important to see what are the memory limits for the push constants. It sounds like it should be supported so it may be something to do with the build process

@unexploredtest
Copy link
Contributor Author

Thanks for the response!

Also can you give me a bit more info on your current AMD card + drivers?

I'm using AMD Radeon HD 7770(in Linux), and I have two vulkan driver's, AMDVLK and mesa's Vulkan(RADV).
AMDVLK gives me a segfault(will check what's the reason) and RADV gives the push constants vlaue 0.

@unexploredtest
Copy link
Contributor Author

Ah just realised the logs are from the tests, not from the readme - ok that's strange, did you clear your cmake build directory and rebuilt from scratch for this?

Yeah... Will completely uninstall it and try again

@unexploredtest
Copy link
Contributor Author

Also can you compile it with debug logs and post the logs here? That will show us whether the push consts are being set.

The tests? Ok

@unexploredtest
Copy link
Contributor Author

unexploredtest commented Mar 1, 2021

So I completely uninstalled Vulkan Kompute, then recloned the whole repository(master branch) and built it from source with these CMake options:

cmake -Bbuild -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 -DKOMPUTE_OPT_INSTALL=1 -DKOMPUTE_OPT_ENABLE_SPDLOG=1 -DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=1 -DDEBUG=1 -DKOMPUTE_OPT_BUILD_TESTS=1

The tests with spdlog set to SPDLOG_LEVEL_TRACE:
With mesa's vulkan:

[2021-03-02 15:36:51.763] [debug] [Manager.cpp:137] Kompute Manager creating instance
[2021-03-02 15:36:51.763] [debug] [Manager.cpp:162] Kompute Manager adding debug validation layers
[2021-03-02 15:36:51.907] [debug] [Manager.cpp:195] Kompute Manager Instance Created
[2021-03-02 15:36:51.907] [debug] [Manager.cpp:199] Kompute Manager adding debug callbacks
[2021-03-02 15:36:51.907] [debug] [Manager.cpp:246] Kompute Manager creating Device
WARNING: radv is not a conformant vulkan implementation, testing use only.
[2021-03-02 15:36:51.909] [info] [Manager.cpp:269] Using physical device index 1 found AMD RADV VERDE (ACO)
[2021-03-02 15:36:51.911] [debug] [Manager.cpp:328] Kompute Manager device created
[2021-03-02 15:36:51.911] [debug] [Manager.cpp:342] Kompute Manager compute queue obtained
[2021-03-02 15:36:51.911] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 16, flags: { DeviceLocal }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 1, size 16, flags: { HostVisible }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 15:36:51.911] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 16, flags: { DeviceLocal }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 1, size 16, flags: { HostVisible }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 15:36:51.911] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 16, flags: { DeviceLocal }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 1, size 16, flags: { HostVisible }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 15:36:51.911] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 16, flags: { DeviceLocal }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 1, size 16, flags: { HostVisible }
[2021-03-02 15:36:51.911] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 15:36:52.369] [info] [Shader.cpp:68] Kompute Shader Information: 


[2021-03-02 15:36:52.372] [debug] [Shader.cpp:85] Kompute Shader all result messages: 



[2021-03-02 15:36:52.379] [debug] [Manager.cpp:367] Kompute Manager algorithm creation triggered
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:13] Kompute Algorithm Constructor with device
[2021-03-02 15:36:52.379] [info] [Algorithm.cpp:18] Kompute Algorithm initialising with tensor size: 4 and spirv size: 480
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:42] Kompute Algorithm rebuild started
[2021-03-02 15:36:52.379] [info] [Algorithm.cpp:395] Kompute OpAlgoCreate setting dispatch size
[2021-03-02 15:36:52.379] [info] [Algorithm.cpp:409] Kompute OpAlgoCreate set dispatch size X: 3, Y: 1, Z: 1
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:169] Kompute Algorithm createParameters started
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:184] Kompute Algorithm creating descriptor pool
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:205] Kompute Algorithm creating descriptor set layout
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:216] Kompute Algorithm allocating descriptor sets
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:222] Kompute Algorithm updating descriptor sets
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:242] Kompue Algorithm successfully run init
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:248] Kompute Algorithm createShaderModule started
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:255] Kompute Algorithm Creating shader module. ShaderFileSize: 480
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:263] Kompute Algorithm create shader module success
[2021-03-02 15:36:52.379] [debug] [Algorithm.cpp:269] Kompute Algorithm calling create Pipeline
[2021-03-02 15:36:52.382] [debug] [Algorithm.cpp:345] Kompute Algorithm Create Pipeline Success
[2021-03-02 15:36:52.382] [debug] [Manager.cpp:382] Kompute Manager sequence() with queueIndex: 0
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:11] Kompute Sequence Constructor with existing device & queue
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:270] Kompute Sequence creating command pool
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:286] Kompute Sequence Command Pool Created
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:292] Kompute Sequence creating command buffer
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:308] Kompute Sequence Command Buffer Created
[2021-03-02 15:36:52.382] [debug] [OpTensorSyncDevice.cpp:9] Kompute OpTensorSyncDevice constructor with params
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:253] Kompute Sequence record function started
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:32] Kompute sequence called BEGIN
[2021-03-02 15:36:52.382] [info] [Sequence.cpp:44] Kompute Sequence command now started recording
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:257] Kompute Sequence running record on OpBase derived class instance
[2021-03-02 15:36:52.382] [debug] [OpTensorSyncDevice.cpp:29] Kompute OpTensorSyncDevice record called
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:120] Kompute Tensor copying data size 12.
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:120] Kompute Tensor copying data size 12.
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:120] Kompute Tensor copying data size 12.
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:120] Kompute Tensor copying data size 12.
[2021-03-02 15:36:52.382] [debug] [OpAlgoDispatch.cpp:10] Kompute OpAlgoDispatch constructor
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:253] Kompute Sequence record function started
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:32] Kompute sequence called BEGIN
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:35] Kompute Sequence begin called when already recording
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:257] Kompute Sequence running record on OpBase derived class instance
[2021-03-02 15:36:52.382] [debug] [OpAlgoDispatch.cpp:24] Kompute OpAlgoDispatch record called
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.382] [debug] [Algorithm.cpp:351] Kompute Algorithm binding pipeline
[2021-03-02 15:36:52.382] [debug] [Algorithm.cpp:356] Kompute Algorithm binding descriptor sets
[2021-03-02 15:36:52.382] [debug] [Algorithm.cpp:371] Kompute Algorithm binding push constants size: 1
[2021-03-02 15:36:52.382] [debug] [Algorithm.cpp:385] Kompute Algorithm recording dispatch
[2021-03-02 15:36:52.382] [debug] [OpAlgoDispatch.cpp:10] Kompute OpAlgoDispatch constructor
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:253] Kompute Sequence record function started
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:32] Kompute sequence called BEGIN
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:35] Kompute Sequence begin called when already recording
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:257] Kompute Sequence running record on OpBase derived class instance
[2021-03-02 15:36:52.382] [debug] [OpAlgoDispatch.cpp:24] Kompute OpAlgoDispatch record called
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.382] [debug] [Algorithm.cpp:351] Kompute Algorithm binding pipeline
[2021-03-02 15:36:52.382] [debug] [Algorithm.cpp:356] Kompute Algorithm binding descriptor sets
[2021-03-02 15:36:52.382] [debug] [Algorithm.cpp:371] Kompute Algorithm binding push constants size: 1
[2021-03-02 15:36:52.382] [debug] [Algorithm.cpp:385] Kompute Algorithm recording dispatch
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:79] Kompute sequence EVAL BEGIN
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:52] Kompute Sequence calling END
[2021-03-02 15:36:52.382] [info] [Sequence.cpp:63] Kompute Sequence command recording END
[2021-03-02 15:36:52.382] [debug] [OpTensorSyncDevice.cpp:42] Kompute OpTensorSyncDevice preEval called
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:234] Kompute Tensor local mapping tensor data to host buffer
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:234] Kompute Tensor local mapping tensor data to host buffer
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:234] Kompute Tensor local mapping tensor data to host buffer
[2021-03-02 15:36:52.382] [debug] [Tensor.cpp:234] Kompute Tensor local mapping tensor data to host buffer
[2021-03-02 15:36:52.382] [debug] [OpAlgoDispatch.cpp:45] Kompute OpAlgoDispatch preEval called
[2021-03-02 15:36:52.382] [debug] [OpAlgoDispatch.cpp:45] Kompute OpAlgoDispatch preEval called
[2021-03-02 15:36:52.382] [debug] [Sequence.cpp:115] Kompute sequence submitting command buffer into compute queue
[2021-03-02 15:36:52.383] [debug] [OpTensorSyncDevice.cpp:55] Kompute OpTensorSyncDevice postEval called
[2021-03-02 15:36:52.383] [debug] [OpAlgoDispatch.cpp:51] Kompute OpAlgoDispatch postSubmit called
[2021-03-02 15:36:52.383] [debug] [OpAlgoDispatch.cpp:51] Kompute OpAlgoDispatch postSubmit called
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:24] Kompute Sequence Destructor started
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:193] Kompute Sequence destroy called
[2021-03-02 15:36:52.383] [info] [Sequence.cpp:202] Freeing CommandBuffer
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:214] Kompute Sequence Freed CommandBuffer
[2021-03-02 15:36:52.383] [info] [Sequence.cpp:218] Destroying CommandPool
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:231] Kompute Sequence Destroyed CommandPool
[2021-03-02 15:36:52.383] [info] [Sequence.cpp:235] Kompute Sequence clearing operations buffer
[2021-03-02 15:36:52.383] [debug] [OpTensorSyncDevice.cpp:21] Kompute OpTensorSyncDevice destructor started
[2021-03-02 15:36:52.383] [debug] [OpBase.hpp:28] Kompute OpBase destructor started
[2021-03-02 15:36:52.383] [debug] [OpAlgoDispatch.cpp:18] Kompute OpAlgoDispatch destructor started
[2021-03-02 15:36:52.383] [debug] [OpBase.hpp:28] Kompute OpBase destructor started
[2021-03-02 15:36:52.383] [debug] [OpAlgoDispatch.cpp:18] Kompute OpAlgoDispatch destructor started
[2021-03-02 15:36:52.383] [debug] [OpBase.hpp:28] Kompute OpBase destructor started
[2021-03-02 15:36:52.383] [debug] [Manager.cpp:382] Kompute Manager sequence() with queueIndex: 0
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:11] Kompute Sequence Constructor with existing device & queue
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:270] Kompute Sequence creating command pool
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:286] Kompute Sequence Command Pool Created
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:292] Kompute Sequence creating command buffer
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:308] Kompute Sequence Command Buffer Created
[2021-03-02 15:36:52.383] [debug] [OpTensorSyncLocal.cpp:11] Kompute OpTensorSyncLocal constructor with params
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:72] Kompute Sequence calling clear
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:52] Kompute Sequence calling END
[2021-03-02 15:36:52.383] [warning] [Sequence.cpp:60] Kompute Sequence end called when not recording
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:253] Kompute Sequence record function started
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:32] Kompute sequence called BEGIN
[2021-03-02 15:36:52.383] [info] [Sequence.cpp:44] Kompute Sequence command now started recording
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:257] Kompute Sequence running record on OpBase derived class instance
[2021-03-02 15:36:52.383] [debug] [OpTensorSyncLocal.cpp:29] Kompute OpTensorSyncLocal record called
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:137] Kompute Tensor copying data size 12.
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:137] Kompute Tensor copying data size 12.
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:137] Kompute Tensor copying data size 12.
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:137] Kompute Tensor copying data size 12.
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:52] Kompute Sequence calling END
[2021-03-02 15:36:52.383] [info] [Sequence.cpp:63] Kompute Sequence command recording END
[2021-03-02 15:36:52.383] [debug] [OpTensorSyncLocal.cpp:42] Kompute OpTensorSyncLocal preEval called
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:115] Kompute sequence submitting command buffer into compute queue
[2021-03-02 15:36:52.383] [debug] [OpTensorSyncLocal.cpp:48] Kompute OpTensorSyncLocal postEval called
[2021-03-02 15:36:52.383] [debug] [OpTensorSyncLocal.cpp:50] Kompute OpTensorSyncLocal mapping data into tensor local
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:207] Kompute Tensor mapping data from host buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:207] Kompute Tensor mapping data from host buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:207] Kompute Tensor mapping data from host buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:207] Kompute Tensor mapping data from host buffer
2  4  6  4.6694e-38  4.6694e-38  4.6694e-38  [2021-03-02 15:36:52.383] [debug] [Sequence.cpp:24] Kompute Sequence Destructor started
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:193] Kompute Sequence destroy called
[2021-03-02 15:36:52.383] [info] [Sequence.cpp:202] Freeing CommandBuffer
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:214] Kompute Sequence Freed CommandBuffer
[2021-03-02 15:36:52.383] [info] [Sequence.cpp:218] Destroying CommandPool
[2021-03-02 15:36:52.383] [debug] [Sequence.cpp:231] Kompute Sequence Destroyed CommandPool
[2021-03-02 15:36:52.383] [info] [Sequence.cpp:235] Kompute Sequence clearing operations buffer
[2021-03-02 15:36:52.383] [debug] [OpTensorSyncLocal.cpp:23] Kompute OpTensorSyncLocal destructor started
[2021-03-02 15:36:52.383] [debug] [OpBase.hpp:28] Kompute OpBase destructor started
[2021-03-02 15:36:52.383] [debug] [Algorithm.cpp:31] Kompute Algorithm Destructor started
[2021-03-02 15:36:52.383] [debug] [Algorithm.cpp:80] Kompute Algorithm Destroying pipeline
[2021-03-02 15:36:52.383] [debug] [Algorithm.cpp:92] Kompute Algorithm Destroying pipeline cache
[2021-03-02 15:36:52.383] [debug] [Algorithm.cpp:104] Kompute Algorithm Destroying pipeline layout
[2021-03-02 15:36:52.383] [debug] [Algorithm.cpp:116] Kompute Algorithm Destroying shader module
[2021-03-02 15:36:52.383] [debug] [Algorithm.cpp:142] Kompute Algorithm Destroying Descriptor Set Layout
[2021-03-02 15:36:52.383] [debug] [Algorithm.cpp:154] Kompute Algorithm Destroying Descriptor Pool
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:23] Kompute Tensor destructor started. Type: 0
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:436] Kompute Tensor started destroy()
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:449] Kompose Tensor destroying primary buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:463] Kompose Tensor destroying staging buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:477] Kompose Tensor freeing primary memory
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:491] Kompose Tensor freeing staging memory
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:504] Kompute Tensor successful destroy()
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:28] Kompute Tensor destructor success
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:23] Kompute Tensor destructor started. Type: 0
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:436] Kompute Tensor started destroy()
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:449] Kompose Tensor destroying primary buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:463] Kompose Tensor destroying staging buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:477] Kompose Tensor freeing primary memory
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:491] Kompose Tensor freeing staging memory
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:504] Kompute Tensor successful destroy()
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:28] Kompute Tensor destructor success
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:23] Kompute Tensor destructor started. Type: 0
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:436] Kompute Tensor started destroy()
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:449] Kompose Tensor destroying primary buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:463] Kompose Tensor destroying staging buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:477] Kompose Tensor freeing primary memory
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:491] Kompose Tensor freeing staging memory
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:504] Kompute Tensor successful destroy()
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:28] Kompute Tensor destructor success
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:23] Kompute Tensor destructor started. Type: 0
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:436] Kompute Tensor started destroy()
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:449] Kompose Tensor destroying primary buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:463] Kompose Tensor destroying staging buffer
[2021-03-02 15:36:52.383] [debug] [Tensor.cpp:477] Kompose Tensor freeing primary memory
[2021-03-02 15:36:52.384] [debug] [Tensor.cpp:491] Kompose Tensor freeing staging memory
[2021-03-02 15:36:52.384] [debug] [Tensor.cpp:504] Kompute Tensor successful destroy()
[2021-03-02 15:36:52.384] [debug] [Tensor.cpp:28] Kompute Tensor destructor success
[2021-03-02 15:36:52.384] [debug] [Manager.cpp:53] Kompute Manager Destructor started
[2021-03-02 15:36:52.384] [debug] [Manager.cpp:61] Kompute Manager destroy() started
[2021-03-02 15:36:52.384] [debug] [Manager.cpp:70] Kompute Manager explicitly running destructor for managed sequences
[2021-03-02 15:36:52.384] [debug] [Manager.cpp:81] Kompute Manager explicitly freeing algorithms
[2021-03-02 15:36:52.384] [debug] [Manager.cpp:92] Kompute Manager explicitly freeing tensors
[2021-03-02 15:36:52.384] [info] [Manager.cpp:102] Destroying device
[2021-03-02 15:36:52.384] [debug] [Manager.cpp:106] Kompute Manager Destroyed Device
[2021-03-02 15:36:52.386] [debug] [Manager.cpp:129] Kompute Manager Destroyed Instance

With AMDVLK:

[2021-03-02 15:35:35.065] [debug] [Manager.cpp:137] Kompute Manager creating instance
[2021-03-02 15:35:35.065] [debug] [Manager.cpp:162] Kompute Manager adding debug validation layers
[2021-03-02 15:35:35.226] [debug] [Manager.cpp:195] Kompute Manager Instance Created
[2021-03-02 15:35:35.226] [debug] [Manager.cpp:199] Kompute Manager adding debug callbacks
[2021-03-02 15:35:35.226] [debug] [Manager.cpp:246] Kompute Manager creating Device
WARNING: radv is not a conformant vulkan implementation, testing use only.
[2021-03-02 15:35:35.227] [info] [Manager.cpp:269] Using physical device index 0 found AMD Radeon HD 7700 Series
[2021-03-02 15:35:35.229] [debug] [Manager.cpp:328] Kompute Manager device created
[2021-03-02 15:35:35.229] [debug] [Manager.cpp:342] Kompute Manager compute queue obtained
[2021-03-02 15:35:35.229] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { DeviceLocal }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 1, size 12, flags: { HostVisible }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 15:35:35.229] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { DeviceLocal }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 1, size 12, flags: { HostVisible }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 15:35:35.229] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { DeviceLocal }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 1, size 12, flags: { HostVisible }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 15:35:35.229] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { DeviceLocal }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 1, size 12, flags: { HostVisible }
[2021-03-02 15:35:35.229] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 15:35:35.684] [info] [Shader.cpp:68] Kompute Shader Information: 


[2021-03-02 15:35:35.686] [debug] [Shader.cpp:85] Kompute Shader all result messages: 



[2021-03-02 15:35:35.692] [debug] [Manager.cpp:367] Kompute Manager algorithm creation triggered
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:13] Kompute Algorithm Constructor with device
[2021-03-02 15:35:35.693] [info] [Algorithm.cpp:18] Kompute Algorithm initialising with tensor size: 4 and spirv size: 480
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:42] Kompute Algorithm rebuild started
[2021-03-02 15:35:35.693] [info] [Algorithm.cpp:395] Kompute OpAlgoCreate setting dispatch size
[2021-03-02 15:35:35.693] [info] [Algorithm.cpp:409] Kompute OpAlgoCreate set dispatch size X: 3, Y: 1, Z: 1
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:169] Kompute Algorithm createParameters started
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:184] Kompute Algorithm creating descriptor pool
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:205] Kompute Algorithm creating descriptor set layout
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:216] Kompute Algorithm allocating descriptor sets
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:222] Kompute Algorithm updating descriptor sets
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:242] Kompue Algorithm successfully run init
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:248] Kompute Algorithm createShaderModule started
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:255] Kompute Algorithm Creating shader module. ShaderFileSize: 480
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:263] Kompute Algorithm create shader module success
[2021-03-02 15:35:35.693] [debug] [Algorithm.cpp:269] Kompute Algorithm calling create Pipeline
Segmentation fault (core dumped)

@unexploredtest
Copy link
Contributor Author

unexploredtest commented Mar 1, 2021

When removed traces of push_constant, AMDVLK's segfault error also disappeared and the code worked fine.
I'll also test it with Windows

@axsaucedo
Copy link
Member

@aliPMPAINT thank you for diving deeper - not sure I understand the issue/solution tho. What do you mean by removing traces of push_cosnstant?

@unexploredtest
Copy link
Contributor Author

unexploredtest commented Mar 1, 2021

When I removed the push_constant section from the code(below):

int main() {

    spdlog::set_level(
      static_cast<spdlog::level::level_enum>(SPDLOG_LEVEL_TRACE));
    
    // 1. Create Kompute Manager with default settings (device 0 and first compute compatible queue)
    kp::Manager mgr(0); 

    // 2. Create and initialise Kompute Tensors through manager
    auto tensorInA = mgr.tensor({ 2., 2., 2. });
    auto tensorInB = mgr.tensor({ 1., 2., 3. });
    auto tensorOutA = mgr.tensor({ 0., 0., 0. });
    auto tensorOutB = mgr.tensor({ 0., 0., 0. });


    
    std::vector<std::shared_ptr<kp::Tensor>> params = {tensorInA, tensorInB, tensorOutA, tensorOutB};

    // 3. Create algorithm based on shader (supports buffers & push/spec constants)
    std::string shader = (R"(
        #version 450

        layout (local_size_x = 1) in;

        // The input tensors bind index is relative to index in parameter passed
        layout(set = 0, binding = 0) buffer buf_in_a { float in_a[]; };
        layout(set = 0, binding = 1) buffer buf_in_b { float in_b[]; };
        layout(set = 0, binding = 2) buffer buf_out_a { float out_a[]; };
        layout(set = 0, binding = 3) buffer buf_out_b { float out_b[]; };

        // Kompute supports push constants updated on dispatch
        
        // Kompute also supports spec constants on initalization
        layout(constant_id = 0) const float const_one = 0;

        void main() {
            uint index = gl_GlobalInvocationID.x;
            out_a[index] += in_a[index] * in_b[index];
            out_b[index] += const_one;
        }
    )");

    kp::Workgroup workgroup({3, 1, 1});
    kp::Constants specConsts({ 2 });

    auto algorithm = mgr.algorithm(params, kp::Shader::compile_source(shader), workgroup, specConsts);


    // 4. Run operation synchronously using sequence
    mgr.sequence()
        ->record<kp::OpTensorSyncDevice>(params)
        ->record<kp::OpAlgoDispatch>(algorithm)
        ->record<kp::OpAlgoDispatch>(algorithm)
        ->eval();

    // 5. Sync results from the GPU asynchronously
    auto sq = mgr.sequence();
    sq->evalAsync<kp::OpTensorSyncLocal>(params);

    // ... Do other work asynchronously whilst GPU finishes

    sq->evalAwait();

    // Prints the first output which is: { 4, 8, 12 }
    for (const float& elem : tensorOutA->data()) std::cout << elem << "  ";
    // Prints the second output which is: { 10, 10, 10 }
    for (const float& elem : tensorOutB->data()) std::cout << elem << "  ";
}

The segfault error disappeared(with AMDVLK's driver) and worked fine.
EDIT: It's not a solution it's just experimenting and investigating what the issue is

@axsaucedo
Copy link
Member

Ah ok I see what you mean now, ok interesting so it actually is the step that adds the push_const into the command buffer that seems to cause the issue... I have just tried this locally with the nvidia card and it seems like there wasn't any issue. Would you be able to try again with a different push const value and share the code here?

@axsaucedo
Copy link
Member

Also if you can share the version of your Vulkan SDK that should give us the full picture, basically run vulkaninfo

@unexploredtest
Copy link
Contributor Author

Would you be able to try again with a different push const value and share the code here?
I tried different float and int values, one is:

int main() {

    // 1. Create Kompute Manager with default settings (device 0 and first compute compatible queue)
    kp::Manager mgr(1);  // 0 for AMDVLK and 1 for Mesa's vulkan

    // 2. Create and initialise Kompute Tensors through manager
    auto tensorInA = mgr.tensor({ 2., 2., 2. });
    auto tensorInB = mgr.tensor({ 1., 2., 3. });
    auto tensorOutA = mgr.tensor({ 0., 0., 0. });
    auto tensorOutB = mgr.tensor({ 0., 0., 0. });

    std::vector<std::shared_ptr<kp::Tensor>> params = {tensorInA, tensorInB, tensorOutA, tensorOutB};

    // 3. Create algorithm based on shader (supports buffers & push/spec constants)
    std::string shader = (R"(
        #version 450

        layout (local_size_x = 1) in;

        // The input tensors bind index is relative to index in parameter passed
        layout(set = 0, binding = 0) buffer buf_in_a { float in_a[]; };
        layout(set = 0, binding = 1) buffer buf_in_b { float in_b[]; };
        layout(set = 0, binding = 2) buffer buf_out_a { float out_a[]; };
        layout(set = 0, binding = 3) buffer buf_out_b { float out_b[]; };

        // Kompute supports push constants updated on dispatch
        layout(push_constant) uniform PushConstants {
            float val;
        } push_const;

        // Kompute also supports spec constants on initalization
        layout(constant_id = 0) const float const_one = 0;

        void main() {
            uint index = gl_GlobalInvocationID.x;
            out_a[index] += in_a[index] * in_b[index];
            out_b[index] += const_one * push_const.val;
        }
    )");

    kp::Workgroup workgroup({3, 1, 1});
    kp::Constants specConsts({ 2 });

    auto algorithm = mgr.algorithm(params, kp::Shader::compile_source(shader), workgroup, specConsts);

    kp::Constants pushConstsA({ 10.1 });
    kp::Constants pushConstsB({ 11.4 });

    // 4. Run operation synchronously using sequence
    mgr.sequence()
        ->record<kp::OpTensorSyncDevice>(params)
        ->record<kp::OpAlgoDispatch>(algorithm, pushConstsA)
        ->record<kp::OpAlgoDispatch>(algorithm, pushConstsB)
        ->eval();

    // 5. Sync results from the GPU asynchronously
    auto sq = mgr.sequence();
    sq->evalAsync<kp::OpTensorSyncLocal>(params);

    // ... Do other work asynchronously whilst GPU finishes

    sq->evalAwait();

    // Prints the first output which is: { 4, 8, 12 }
    for (const float& elem : tensorOutA->data()) std::cout << elem << "  ";
    // Prints the second output which is: { 10, 10, 10 }
    for (const float& elem : tensorOutB->data()) std::cout << elem << "  ";
}

Which the results were similar to the previous one:
Mesa's vulkan:

ARNING: radv is not a conformant vulkan implementation, testing use only.
[2021-03-01 17:15:52.193] [info] [Manager.cpp:269] Using physical device index 1 found AMD RADV VERDE (ACO)
[2021-03-01 17:15:52.292] [info] [Shader.cpp:68] Kompute Shader Information: 


[2021-03-01 17:15:52.294] [info] [Algorithm.cpp:18] Kompute Algorithm initialising with tensor size: 4 and spirv size: 480
[2021-03-01 17:15:52.294] [info] [Algorithm.cpp:395] Kompute OpAlgoCreate setting dispatch size
[2021-03-01 17:15:52.294] [info] [Algorithm.cpp:409] Kompute OpAlgoCreate set dispatch size X: 3, Y: 1, Z: 1
[2021-03-01 17:15:52.294] [info] [Sequence.cpp:44] Kompute Sequence command now started recording
[2021-03-01 17:15:52.294] [info] [Sequence.cpp:58] Kompute Sequence command recording END
[2021-03-01 17:15:52.295] [info] [Sequence.cpp:186] Freeing CommandBuffer
[2021-03-01 17:15:52.295] [info] [Sequence.cpp:202] Destroying CommandPool
[2021-03-01 17:15:52.295] [info] [Sequence.cpp:219] Kompute Sequence clearing operations buffer
[2021-03-01 17:15:52.295] [warning] [Sequence.cpp:55] Kompute Sequence end called when not recording
[2021-03-01 17:15:52.295] [info] [Sequence.cpp:44] Kompute Sequence command now started recording
[2021-03-01 17:15:52.295] [info] [Sequence.cpp:58] Kompute Sequence command recording END
2  4  6  0  0  0  [2021-03-01 17:15:52.295] [info] [Sequence.cpp:186] Freeing CommandBuffer
[2021-03-01 17:15:52.295] [info] [Sequence.cpp:202] Destroying CommandPool
[2021-03-01 17:15:52.295] [info] [Sequence.cpp:219] Kompute Sequence clearing operations buffer
[2021-03-01 17:15:52.295] [info] [Manager.cpp:102] Destroying device

AMDVLK:

[2021-03-01 17:18:47.473] [info] [Manager.cpp:269] Using physical device index 0 found AMD Radeon HD 7700 Series
[2021-03-01 17:18:47.565] [info] [Shader.cpp:68] Kompute Shader Information: 


[2021-03-01 17:18:47.567] [info] [Algorithm.cpp:18] Kompute Algorithm initialising with tensor size: 4 and spirv size: 480
[2021-03-01 17:18:47.567] [info] [Algorithm.cpp:395] Kompute OpAlgoCreate setting dispatch size
[2021-03-01 17:18:47.567] [info] [Algorithm.cpp:409] Kompute OpAlgoCreate set dispatch size X: 3, Y: 1, Z: 1
Segmentation fault (core dumped)

@unexploredtest
Copy link
Contributor Author

Also if you can share the version of your Vulkan SDK that should give us the full picture, basically run vulkaninfo

welp.txt

@unexploredtest
Copy link
Contributor Author

unexploredtest commented Mar 1, 2021

I ran kp python in Windows and git ErrorOutOfHostMemory error:

Traceback (most recent call last):
  File "welp.py", line 46, in <module>
    algo = mgr.algorithm(params, kp.Shader.compile_source(shader), workgroup, spec_consts)
RuntimeError: vk::Device::createComputePipeline: ErrorOutOfHostMemory
WARNING:kp:Kompute Tensor destructor reached with null Device pointer
WARNING:kp:Kompute Tensor destructor reached with null Device pointer
WARNING:kp:Kompute Tensor destructor reached with null Device pointer
WARNING:kp:Kompute Tensor destructor reached with null Device pointer

@unexploredtest
Copy link
Contributor Author

unexploredtest commented Mar 1, 2021

So, I connected my monitor to onboard GPU and then got a really interesting result(with mesa's driver):

[alipmpaint@archlinux build]$ ./kompute_array_mult
WARNING: radv is not a conformant vulkan implementation, testing use only.
[2021-03-01 18:49:27.707] [info] [Manager.cpp:269] Using physical device index 1 found AMD RADV VERDE (ACO)
[2021-03-01 18:49:27.804] [info] [Shader.cpp:68] Kompute Shader Information: 


[2021-03-01 18:49:27.806] [info] [Algorithm.cpp:18] Kompute Algorithm initialising with tensor size: 4 and spirv size: 480
[2021-03-01 18:49:27.806] [info] [Algorithm.cpp:395] Kompute OpAlgoCreate setting dispatch size
[2021-03-01 18:49:27.806] [info] [Algorithm.cpp:409] Kompute OpAlgoCreate set dispatch size X: 3, Y: 1, Z: 1
[2021-03-01 18:49:27.807] [info] [Sequence.cpp:44] Kompute Sequence command now started recording
[2021-03-01 18:49:27.807] [info] [Sequence.cpp:58] Kompute Sequence command recording END
[2021-03-01 18:49:27.807] [info] [Sequence.cpp:186] Freeing CommandBuffer
[2021-03-01 18:49:27.807] [info] [Sequence.cpp:202] Destroying CommandPool
[2021-03-01 18:49:27.807] [info] [Sequence.cpp:219] Kompute Sequence clearing operations buffer
[2021-03-01 18:49:27.807] [warning] [Sequence.cpp:55] Kompute Sequence end called when not recording
[2021-03-01 18:49:27.807] [info] [Sequence.cpp:44] Kompute Sequence command now started recording
[2021-03-01 18:49:27.807] [info] [Sequence.cpp:58] Kompute Sequence command recording END
2  4  6  9.48375e+27  9.48375e+27  9.48375e+27  [2021-03-01 18:49:27.808] [info] [Sequence.cpp:186] Freeing CommandBuffer
[2021-03-01 18:49:27.808] [info] [Sequence.cpp:202] Destroying CommandPool
[2021-03-01 18:49:27.808] [info] [Sequence.cpp:219] Kompute Sequence clearing operations buffer
[2021-03-01 18:49:27.808] [info] [Manager.cpp:102] Destroying device

No matter what value push_constants hold, I get these huge number as a result: 9.48375e+27 9.48375e+27 9.48375e+27

@unexploredtest
Copy link
Contributor Author

unexploredtest commented Mar 1, 2021

Ummm I got a funny news, my 8 year old onboard Graphics card(Intel HD 2500), which somehow supports Vulkan, yields the expected results and works perfectly:

[2021-03-02 16:44:21.412] [debug] [Manager.cpp:137] Kompute Manager creating instance
[2021-03-02 16:44:21.412] [debug] [Manager.cpp:162] Kompute Manager adding debug validation layers
[2021-03-02 16:44:21.897] [debug] [Manager.cpp:195] Kompute Manager Instance Created
[2021-03-02 16:44:21.897] [debug] [Manager.cpp:199] Kompute Manager adding debug callbacks
[2021-03-02 16:44:21.897] [debug] [Manager.cpp:246] Kompute Manager creating Device
MESA-INTEL: warning: Ivy Bridge Vulkan support is incomplete
WARNING: radv is not a conformant vulkan implementation, testing use only.
[2021-03-02 16:44:21.910] [info] [Manager.cpp:269] Using physical device index 0 found Intel(R) HD Graphics 2500 (IVB GT1)
[2021-03-02 16:44:21.914] [debug] [Manager.cpp:328] Kompute Manager device created
[2021-03-02 16:44:21.914] [debug] [Manager.cpp:342] Kompute Manager compute queue obtained
[2021-03-02 16:44:21.914] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { DeviceLocal }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { HostVisible }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 16:44:21.914] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { DeviceLocal }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { HostVisible }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 16:44:21.914] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { DeviceLocal }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { HostVisible }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 16:44:21.914] [debug] [Manager.cpp:348] Kompute Manager tensor creation triggered
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:11] Kompute Tensor constructor data length: 3, and type: 0
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:34] Kompute Tensor rebuilding with size 3
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:326] Kompute Tensor creating buffer
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:335] Kompute Tensor creating primary buffer and memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst | StorageBuffer }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { DeviceLocal }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:348] Kompute Tensor creating staging buffer and memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:376] Kompute Tensor creating buffer with memory size: 12, and usage flags: { TransferSrc | TransferDst }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:396] Kompute Tensor allocating and binding memory
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:419] Kompute Tensor allocating memory index: 0, size 12, flags: { HostVisible }
[2021-03-02 16:44:21.914] [debug] [Tensor.cpp:361] Kompute Tensor buffer & memory creation successful
[2021-03-02 16:44:22.332] [info] [Shader.cpp:68] Kompute Shader Information: 


[2021-03-02 16:44:22.337] [debug] [Shader.cpp:85] Kompute Shader all result messages: 



[2021-03-02 16:44:22.343] [debug] [Manager.cpp:367] Kompute Manager algorithm creation triggered
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:13] Kompute Algorithm Constructor with device
[2021-03-02 16:44:22.343] [info] [Algorithm.cpp:18] Kompute Algorithm initialising with tensor size: 4 and spirv size: 480
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:42] Kompute Algorithm rebuild started
[2021-03-02 16:44:22.343] [info] [Algorithm.cpp:404] Kompute OpAlgoCreate setting dispatch size
[2021-03-02 16:44:22.343] [info] [Algorithm.cpp:418] Kompute OpAlgoCreate set dispatch size X: 3, Y: 1, Z: 1
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:169] Kompute Algorithm createParameters started
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:184] Kompute Algorithm creating descriptor pool
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:205] Kompute Algorithm creating descriptor set layout
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:216] Kompute Algorithm allocating descriptor sets
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:222] Kompute Algorithm updating descriptor sets
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:242] Kompue Algorithm successfully run init
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:248] Kompute Algorithm createShaderModule started
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:255] Kompute Algorithm Creating shader module. ShaderFileSize: 480
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:263] Kompute Algorithm create shader module success
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:269] Kompute Algorithm calling create Pipeline
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:276] KA1
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:283] KA2
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:296] KA3
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:313] KA4
[2021-03-02 16:44:22.343] [debug] [Algorithm.cpp:328] KA5
[2021-03-02 16:44:22.347] [debug] [Algorithm.cpp:354] Kompute Algorithm Create Pipeline Success
[2021-03-02 16:44:22.347] [debug] [Manager.cpp:382] Kompute Manager sequence() with queueIndex: 0
[2021-03-02 16:44:22.347] [debug] [Sequence.cpp:11] Kompute Sequence Constructor with existing device & queue
[2021-03-02 16:44:22.347] [debug] [Sequence.cpp:270] Kompute Sequence creating command pool
[2021-03-02 16:44:22.347] [debug] [Sequence.cpp:286] Kompute Sequence Command Pool Created
[2021-03-02 16:44:22.347] [debug] [Sequence.cpp:292] Kompute Sequence creating command buffer
[2021-03-02 16:44:22.347] [debug] [Sequence.cpp:308] Kompute Sequence Command Buffer Created
[2021-03-02 16:44:22.347] [debug] [OpTensorSyncDevice.cpp:9] Kompute OpTensorSyncDevice constructor with params
[2021-03-02 16:44:22.347] [debug] [Sequence.cpp:253] Kompute Sequence record function started
[2021-03-02 16:44:22.347] [debug] [Sequence.cpp:32] Kompute sequence called BEGIN
[2021-03-02 16:44:22.347] [info] [Sequence.cpp:44] Kompute Sequence command now started recording
[2021-03-02 16:44:22.347] [debug] [Sequence.cpp:257] Kompute Sequence running record on OpBase derived class instance
[2021-03-02 16:44:22.347] [debug] [OpTensorSyncDevice.cpp:29] Kompute OpTensorSyncDevice record called
[2021-03-02 16:44:22.347] [debug] [Tensor.cpp:120] Kompute Tensor copying data size 12.
[2021-03-02 16:44:22.357] [debug] [Tensor.cpp:120] Kompute Tensor copying data size 12.
[2021-03-02 16:44:22.357] [debug] [Tensor.cpp:120] Kompute Tensor copying data size 12.
[2021-03-02 16:44:22.357] [debug] [Tensor.cpp:120] Kompute Tensor copying data size 12.
[2021-03-02 16:44:22.358] [debug] [OpAlgoDispatch.cpp:10] Kompute OpAlgoDispatch constructor
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:253] Kompute Sequence record function started
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:32] Kompute sequence called BEGIN
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:35] Kompute Sequence begin called when already recording
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:257] Kompute Sequence running record on OpBase derived class instance
[2021-03-02 16:44:22.358] [debug] [OpAlgoDispatch.cpp:24] Kompute OpAlgoDispatch record called
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.358] [debug] [Algorithm.cpp:360] Kompute Algorithm binding pipeline
[2021-03-02 16:44:22.358] [debug] [Algorithm.cpp:365] Kompute Algorithm binding descriptor sets
[2021-03-02 16:44:22.358] [debug] [Algorithm.cpp:380] Kompute Algorithm binding push constants size: 1
[2021-03-02 16:44:22.358] [debug] [Algorithm.cpp:394] Kompute Algorithm recording dispatch
[2021-03-02 16:44:22.358] [debug] [OpAlgoDispatch.cpp:10] Kompute OpAlgoDispatch constructor
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:253] Kompute Sequence record function started
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:32] Kompute sequence called BEGIN
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:35] Kompute Sequence begin called when already recording
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:257] Kompute Sequence running record on OpBase derived class instance
[2021-03-02 16:44:22.358] [debug] [OpAlgoDispatch.cpp:24] Kompute OpAlgoDispatch record called
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.358] [debug] [Algorithm.cpp:360] Kompute Algorithm binding pipeline
[2021-03-02 16:44:22.358] [debug] [Algorithm.cpp:365] Kompute Algorithm binding descriptor sets
[2021-03-02 16:44:22.358] [debug] [Algorithm.cpp:380] Kompute Algorithm binding push constants size: 1
[2021-03-02 16:44:22.358] [debug] [Algorithm.cpp:394] Kompute Algorithm recording dispatch
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:79] Kompute sequence EVAL BEGIN
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:52] Kompute Sequence calling END
[2021-03-02 16:44:22.358] [info] [Sequence.cpp:63] Kompute Sequence command recording END
[2021-03-02 16:44:22.358] [debug] [OpTensorSyncDevice.cpp:42] Kompute OpTensorSyncDevice preEval called
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:234] Kompute Tensor local mapping tensor data to host buffer
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:234] Kompute Tensor local mapping tensor data to host buffer
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:234] Kompute Tensor local mapping tensor data to host buffer
[2021-03-02 16:44:22.358] [debug] [Tensor.cpp:234] Kompute Tensor local mapping tensor data to host buffer
[2021-03-02 16:44:22.358] [debug] [OpAlgoDispatch.cpp:45] Kompute OpAlgoDispatch preEval called
[2021-03-02 16:44:22.358] [debug] [OpAlgoDispatch.cpp:45] Kompute OpAlgoDispatch preEval called
[2021-03-02 16:44:22.358] [debug] [Sequence.cpp:115] Kompute sequence submitting command buffer into compute queue
[2021-03-02 16:44:22.359] [debug] [OpTensorSyncDevice.cpp:55] Kompute OpTensorSyncDevice postEval called
[2021-03-02 16:44:22.359] [debug] [OpAlgoDispatch.cpp:51] Kompute OpAlgoDispatch postSubmit called
[2021-03-02 16:44:22.359] [debug] [OpAlgoDispatch.cpp:51] Kompute OpAlgoDispatch postSubmit called
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:24] Kompute Sequence Destructor started
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:193] Kompute Sequence destroy called
[2021-03-02 16:44:22.359] [info] [Sequence.cpp:202] Freeing CommandBuffer
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:214] Kompute Sequence Freed CommandBuffer
[2021-03-02 16:44:22.359] [info] [Sequence.cpp:218] Destroying CommandPool
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:231] Kompute Sequence Destroyed CommandPool
[2021-03-02 16:44:22.359] [info] [Sequence.cpp:235] Kompute Sequence clearing operations buffer
[2021-03-02 16:44:22.359] [debug] [OpTensorSyncDevice.cpp:21] Kompute OpTensorSyncDevice destructor started
[2021-03-02 16:44:22.359] [debug] [OpBase.hpp:28] Kompute OpBase destructor started
[2021-03-02 16:44:22.359] [debug] [OpAlgoDispatch.cpp:18] Kompute OpAlgoDispatch destructor started
[2021-03-02 16:44:22.359] [debug] [OpBase.hpp:28] Kompute OpBase destructor started
[2021-03-02 16:44:22.359] [debug] [OpAlgoDispatch.cpp:18] Kompute OpAlgoDispatch destructor started
[2021-03-02 16:44:22.359] [debug] [OpBase.hpp:28] Kompute OpBase destructor started
[2021-03-02 16:44:22.359] [debug] [Manager.cpp:382] Kompute Manager sequence() with queueIndex: 0
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:11] Kompute Sequence Constructor with existing device & queue
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:270] Kompute Sequence creating command pool
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:286] Kompute Sequence Command Pool Created
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:292] Kompute Sequence creating command buffer
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:308] Kompute Sequence Command Buffer Created
[2021-03-02 16:44:22.359] [debug] [OpTensorSyncLocal.cpp:11] Kompute OpTensorSyncLocal constructor with params
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:72] Kompute Sequence calling clear
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:52] Kompute Sequence calling END
[2021-03-02 16:44:22.359] [warning] [Sequence.cpp:60] Kompute Sequence end called when not recording
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:253] Kompute Sequence record function started
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:32] Kompute sequence called BEGIN
[2021-03-02 16:44:22.359] [info] [Sequence.cpp:44] Kompute Sequence command now started recording
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:257] Kompute Sequence running record on OpBase derived class instance
[2021-03-02 16:44:22.359] [debug] [OpTensorSyncLocal.cpp:29] Kompute OpTensorSyncLocal record called
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:137] Kompute Tensor copying data size 12.
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:137] Kompute Tensor copying data size 12.
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:137] Kompute Tensor copying data size 12.
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:137] Kompute Tensor copying data size 12.
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:175] Kompute Tensor recording buffer memory barrier
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:52] Kompute Sequence calling END
[2021-03-02 16:44:22.359] [info] [Sequence.cpp:63] Kompute Sequence command recording END
[2021-03-02 16:44:22.359] [debug] [OpTensorSyncLocal.cpp:42] Kompute OpTensorSyncLocal preEval called
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:115] Kompute sequence submitting command buffer into compute queue
[2021-03-02 16:44:22.359] [debug] [OpTensorSyncLocal.cpp:48] Kompute OpTensorSyncLocal postEval called
[2021-03-02 16:44:22.359] [debug] [OpTensorSyncLocal.cpp:50] Kompute OpTensorSyncLocal mapping data into tensor local
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:207] Kompute Tensor mapping data from host buffer
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:207] Kompute Tensor mapping data from host buffer
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:207] Kompute Tensor mapping data from host buffer
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:207] Kompute Tensor mapping data from host buffer
4  8  12  10  10  10  [2021-03-02 16:44:22.359] [debug] [Sequence.cpp:24] Kompute Sequence Destructor started
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:193] Kompute Sequence destroy called
[2021-03-02 16:44:22.359] [info] [Sequence.cpp:202] Freeing CommandBuffer
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:214] Kompute Sequence Freed CommandBuffer
[2021-03-02 16:44:22.359] [info] [Sequence.cpp:218] Destroying CommandPool
[2021-03-02 16:44:22.359] [debug] [Sequence.cpp:231] Kompute Sequence Destroyed CommandPool
[2021-03-02 16:44:22.359] [info] [Sequence.cpp:235] Kompute Sequence clearing operations buffer
[2021-03-02 16:44:22.359] [debug] [OpTensorSyncLocal.cpp:23] Kompute OpTensorSyncLocal destructor started
[2021-03-02 16:44:22.359] [debug] [OpBase.hpp:28] Kompute OpBase destructor started
[2021-03-02 16:44:22.359] [debug] [Algorithm.cpp:31] Kompute Algorithm Destructor started
[2021-03-02 16:44:22.359] [debug] [Algorithm.cpp:80] Kompute Algorithm Destroying pipeline
[2021-03-02 16:44:22.359] [debug] [Algorithm.cpp:92] Kompute Algorithm Destroying pipeline cache
[2021-03-02 16:44:22.359] [debug] [Algorithm.cpp:104] Kompute Algorithm Destroying pipeline layout
[2021-03-02 16:44:22.359] [debug] [Algorithm.cpp:116] Kompute Algorithm Destroying shader module
[2021-03-02 16:44:22.359] [debug] [Algorithm.cpp:142] Kompute Algorithm Destroying Descriptor Set Layout
[2021-03-02 16:44:22.359] [debug] [Algorithm.cpp:154] Kompute Algorithm Destroying Descriptor Pool
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:23] Kompute Tensor destructor started. Type: 0
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:436] Kompute Tensor started destroy()
[2021-03-02 16:44:22.359] [debug] [Tensor.cpp:449] Kompose Tensor destroying primary buffer
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:463] Kompose Tensor destroying staging buffer
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:477] Kompose Tensor freeing primary memory
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:491] Kompose Tensor freeing staging memory
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:504] Kompute Tensor successful destroy()
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:28] Kompute Tensor destructor success
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:23] Kompute Tensor destructor started. Type: 0
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:436] Kompute Tensor started destroy()
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:449] Kompose Tensor destroying primary buffer
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:463] Kompose Tensor destroying staging buffer
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:477] Kompose Tensor freeing primary memory
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:491] Kompose Tensor freeing staging memory
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:504] Kompute Tensor successful destroy()
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:28] Kompute Tensor destructor success
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:23] Kompute Tensor destructor started. Type: 0
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:436] Kompute Tensor started destroy()
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:449] Kompose Tensor destroying primary buffer
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:463] Kompose Tensor destroying staging buffer
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:477] Kompose Tensor freeing primary memory
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:491] Kompose Tensor freeing staging memory
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:504] Kompute Tensor successful destroy()
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:28] Kompute Tensor destructor success
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:23] Kompute Tensor destructor started. Type: 0
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:436] Kompute Tensor started destroy()
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:449] Kompose Tensor destroying primary buffer
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:463] Kompose Tensor destroying staging buffer
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:477] Kompose Tensor freeing primary memory
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:491] Kompose Tensor freeing staging memory
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:504] Kompute Tensor successful destroy()
[2021-03-02 16:44:22.360] [debug] [Tensor.cpp:28] Kompute Tensor destructor success
[2021-03-02 16:44:22.360] [debug] [Manager.cpp:53] Kompute Manager Destructor started
[2021-03-02 16:44:22.360] [debug] [Manager.cpp:61] Kompute Manager destroy() started
[2021-03-02 16:44:22.360] [debug] [Manager.cpp:70] Kompute Manager explicitly running destructor for managed sequences
[2021-03-02 16:44:22.360] [debug] [Manager.cpp:81] Kompute Manager explicitly freeing algorithms
[2021-03-02 16:44:22.360] [debug] [Manager.cpp:92] Kompute Manager explicitly freeing tensors
[2021-03-02 16:44:22.360] [info] [Manager.cpp:102] Destroying device
[2021-03-02 16:44:22.360] [debug] [Manager.cpp:106] Kompute Manager Destroyed Device
[2021-03-02 16:44:22.372] [debug] [Manager.cpp:129] Kompute Manager Destroyed Instance

So, I guess the problem is with the GPU/Vulkan drivers.

@unexploredtest
Copy link
Contributor Author

I think it's with the GPU, here is something similar:
https://www.reddit.com/r/vulkan/comments/54pfub/nothing_is_drawn_from_push_constant_vertices/

@axsaucedo
Copy link
Member

@aliPMPAINT this is so strange - I think probably best to raise an issue for this, not sure if best is in the Vulkan forums... This definitely looks like some strange / obscure issue with the driver... I am looking at the vkPhysicalDeviceLimits and it says that the maxPushConstantsSize is 128bytes so definitely the provided variables wouldn't be an issue. One thing to consider is that by default it uses float32 as push constants - if you get those numbers I wonder if there may be a different size block that is being passed into the GPU. Although if it works on an older GPU I'm not sure why it would fail in the AMD one - it does sound like it may be a bug with the driver.

@unexploredtest
Copy link
Contributor Author

unexploredtest commented Mar 2, 2021

@axsaucedo I've got a bad news. I tested the code with my laptop, which has an AMD intergrated GPU and an AMD dedicated GPU, and the same behavior was observed. Mesa's vulkan yielded zeros, with AMDVLK segfault, and with Windows, with kp python bindings(coudn't figure out how to compile and build the pure C++ version on Windows), I got the same error:

Traceback (most recent call last):
  File "welp.py", line 46, in <module>
    algo = mgr.algorithm(params, kp.Shader.compile_source(shader), workgroup, spec_consts)
RuntimeError: vk::Device::createComputePipeline: Uknownerror
WARNING:kp:Kompute Tensor destructor reached with null Device pointer
WARNING:kp:Kompute Tensor destructor reached with null Device pointer
WARNING:kp:Kompute Tensor destructor reached with null Device pointer
WARNING:kp:Kompute Tensor destructor reached with null Device pointer

Now I find it unlikely that the issue is just about the drivers, as I tested different driver implemantations with 3 AMD GPUs.
Is it possible that this issue affects a section/all of AMD GPUs? Does anybody else own an AMD GPU?
My CPU: AMD Ryzen 7 4800H with Radeon Graphics
My dedicated GPU: Radeon RX 5500M

@axsaucedo
Copy link
Member

This is really strange... I am not sure what would be the best way to verify this, but would you be able to try out the SachaWilliems examples, particularly the one about push constants? It may be that potentially some type of push constants could be supported but not others (although I find it not completely likely) - if this is the case thos we could have a better understanding on what the issue is and proceed to add the fix accordingly

@unexploredtest
Copy link
Contributor Author

Actually I've tested it before, it works

@axsaucedo
Copy link
Member

axsaucedo commented Mar 4, 2021

Hmm ok, looking at the sachawilliems example on pushconstants.cpp, I can see that the push constant data is using glm::vec4 types, as push constants:

	// Color and position data for each sphere is uploaded using push constants
	struct SpherePushConstantData {
		glm::vec4 color;
		glm::vec4 position;
	};

From what I can see in the glm package, the vec4 values can be of type float32 or float64 (when high precision is enabled). I guess what I can suspect is that perhaps your GPU may only accept high precision? Is there a way you could try this and re-run the sachawilliams example on push constant with high precision and non-high precision enabled?

If this is the issue, then the solution may be at looking towards supporting multiple types of constants, but looking at the code, I can't see much that is different, namely the pushconstants.cpp adds the push constant as:

				vkCmdPushConstants(
				    drawCmdBuffers[i],
				    pipelineLayout,
				    VK_SHADER_STAGE_VERTEX_BIT,
				    0,
				    sizeof(SpherePushConstantData),
				    &spheres[j]);

Whereas in kompute we add it as:

        commandBuffer.pushConstants(*this->mPipelineLayout,
                                    vk::ShaderStageFlagBits::eCompute,
                                    0,
                                    pushConstants.size() * sizeof(float),
                                    pushConstants.data());

Which is pretty much the same, only using the vulkan C++ interface instead - I can't really see anything different except the potential type of float64 that could be as part of the type...

@axsaucedo
Copy link
Member

Actually, I am just looking at the pushConstant example from SachaWilliems and I actually can see there is something different - it seems in their example the push constants are described in the PipelineLayout, whereas Kompute doesn't have this, so this actually may be a bug that for some reason doesn't come up in NVIDIA cards! Let me open a quick PR so we can test it, but it seems that it's an actual bug in Kompute - good shout on diving into it further

@axsaucedo axsaucedo added this to To do in 0.7.0 via automation Mar 4, 2021
@axsaucedo axsaucedo added this to To do in 0.6.1 via automation Mar 4, 2021
@axsaucedo axsaucedo added bug Something isn't working c++ labels Mar 4, 2021
@unexploredtest
Copy link
Contributor Author

Thank you for checking out! Regarding the first concern, I've actually tested changing the constants type but got the same results anyways:
https://github.com/aliPMPAINT/vulkan-kompute/tree/vec2
I'd be happy to help and test the up-coming PR!

@axsaucedo
Copy link
Member

@aliPMPAINT thank you for the update, I have just added #174 - could you test out that PR to see if that fixes your issue? Basically running the tests in TestPushConstants.*

@unexploredtest
Copy link
Contributor Author

Yeah sure, will do after I get back home

0.7.0 automation moved this from To do to Done Mar 6, 2021
axsaucedo added a commit that referenced this issue Mar 6, 2021
Adds push const ranges in pipelinelayout to fix #168
0.6.1 automation moved this from To do to Done Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working c++
Projects
0.6.1
Done
0.7.0
Done
Development

Successfully merging a pull request may close this issue.

2 participants