KomputeProject / kompute

General purpose GPU compute framework built on Vulkan to support 1000s of cross vendor graphics cards (AMD, Qualcomm, NVIDIA & friends). Blazing fast, mobile-enabled, asynchronous and optimized for advanced GPU data processing usecases. Backed by the Linux Foundation.
http://kompute.cc/
Apache License 2.0
1.94k stars 146 forks source link

Array multiplication example code needs to be updated everytime kompute have a build issue. #313

Closed hungrymonkey closed 1 year ago

hungrymonkey commented 1 year ago

https://github.com/KomputeProject/kompute/blob/637bfb1bc044d5e9a639a5ef975ae4ce4b82a71c/examples/array_multiplication/CMakeLists.txt#L29

As it stands, array_multiplication fetches a hash on github. This example code will need continuous maintenance or else the fails to compile whenever somebody tries to build the example and a build issue is fixed upstream.

Steps to reproduce

  1. git clone https://github.com/KomputeProject/kompute.git
  2. cd examples/array_multiplication
  3. cmake -Bbuild
  4. cd build
  5. make
$make
[ 13%] Built target fmt
[ 22%] Built target kp_shader
[ 27%] Building CXX object _deps/kompute-build/src/logger/CMakeFiles/kp_logger.dir/Logger.cpp.o
[ 31%] Linking CXX static library libkp_logger.a
[ 31%] Built target kp_logger
[ 36%] Building CXX object _deps/kompute-build/src/CMakeFiles/kompute.dir/Algorithm.cpp.o
[ 40%] Building CXX object _deps/kompute-build/src/CMakeFiles/kompute.dir/Manager.cpp.o
[ 45%] Building CXX object _deps/kompute-build/src/CMakeFiles/kompute.dir/OpAlgoDispatch.cpp.o
[ 50%] Building CXX object _deps/kompute-build/src/CMakeFiles/kompute.dir/OpMemoryBarrier.cpp.o
[ 54%] Building CXX object _deps/kompute-build/src/CMakeFiles/kompute.dir/OpTensorCopy.cpp.o
In file included from /home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/operations/OpTensorCopy.hpp:6,
                 from /home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/OpTensorCopy.cpp:3:
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:55:27: error: expected ‘)’ before ‘<’ token
   55 |     Tensor(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
      |           ~               ^
      |                           )
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:108:30: error: ‘std::shared_ptr’ has not been declared
  108 |                         std::shared_ptr<Tensor> copyFromTensor);
      |                              ^~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:108:40: error: expected ‘,’ or ‘...’ before ‘<’ token
  108 |                         std::shared_ptr<Tensor> copyFromTensor);
      |                                        ^
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:256:10: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type
  256 |     std::shared_ptr<vk::PhysicalDevice> mPhysicalDevice;
      |          ^~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:6:1: note: ‘std::shared_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
    5 | #include "logger/Logger.hpp"
  +++ |+#include <memory>
    6 | #include <string>
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:257:10: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type
  257 |     std::shared_ptr<vk::Device> mDevice;
      |          ^~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:257:5: note: ‘std::shared_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
  257 |     std::shared_ptr<vk::Device> mDevice;
      |     ^~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:260:10: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type
  260 |     std::shared_ptr<vk::Buffer> mPrimaryBuffer;
      |          ^~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:260:5: note: ‘std::shared_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
  260 |     std::shared_ptr<vk::Buffer> mPrimaryBuffer;
      |     ^~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:262:10: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type
  262 |     std::shared_ptr<vk::Buffer> mStagingBuffer;
      |          ^~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:262:5: note: ‘std::shared_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
  262 |     std::shared_ptr<vk::Buffer> mStagingBuffer;
      |     ^~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:264:10: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type
  264 |     std::shared_ptr<vk::DeviceMemory> mPrimaryMemory;
      |          ^~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:264:5: note: ‘std::shared_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
  264 |     std::shared_ptr<vk::DeviceMemory> mPrimaryMemory;
      |     ^~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:266:10: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type
  266 |     std::shared_ptr<vk::DeviceMemory> mStagingMemory;
      |          ^~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:266:5: note: ‘std::shared_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
  266 |     std::shared_ptr<vk::DeviceMemory> mStagingMemory;
      |     ^~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:270:28: error: ‘std::shared_ptr’ has not been declared
  270 |     void createBuffer(std::shared_ptr<vk::Buffer> buffer,
      |                            ^~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:270:38: error: expected ‘,’ or ‘...’ before ‘<’ token
  270 |     void createBuffer(std::shared_ptr<vk::Buffer> buffer,
      |                                      ^
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:272:34: error: ‘std::shared_ptr’ has not been declared
  272 |     void allocateBindMemory(std::shared_ptr<vk::Buffer> buffer,
      |                                  ^~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:272:44: error: expected ‘,’ or ‘...’ before ‘<’ token
  272 |     void allocateBindMemory(std::shared_ptr<vk::Buffer> buffer,
      |                                            ^
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:276:32: error: ‘std::shared_ptr’ has not been declared
  276 |                           std::shared_ptr<vk::Buffer> bufferFrom,
      |                                ^~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:276:42: error: expected ‘,’ or ‘...’ before ‘<’ token
  276 |                           std::shared_ptr<vk::Buffer> bufferFrom,
      |                                          ^
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:302:28: error: expected ‘)’ before ‘<’ token
  302 |     TensorT(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
      |            ~               ^
      |                            )
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/OpTensorCopy.cpp: In member function ‘virtual void kp::OpTensorCopy::record(const vk::CommandBuffer&)’:
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/OpTensorCopy.cpp:49:42: error: cannot convert ‘__gnu_cxx::__alloc_traits<std::allocator<std::shared_ptr<kp::Tensor> >, std::shared_ptr<kp::Tensor> >::value_type’ {aka ‘std::shared_ptr<kp::Tensor>’} to ‘int’
   49 |         this->mTensors[i]->recordCopyFrom(commandBuffer, this->mTensors[0]);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Tensor.hpp:108:25: note:   initializing argument 2 of ‘void kp::Tensor::recordCopyFrom(const vk::CommandBuffer&, int)’
  108 |                         std::shared_ptr<Tensor> copyFromTensor);
      |                         ^~~~~~~~~~~~~~~
make[2]: *** [_deps/kompute-build/src/CMakeFiles/kompute.dir/build.make:132: _deps/kompute-build/src/CMakeFiles/kompute.dir/OpTensorCopy.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:263: _deps/kompute-build/src/CMakeFiles/kompute.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

As you can see here, we recently fix a gcc12 error. The example code does not build because cmake fetches an old unpatch version of kompute since hashes are hard coded.

hungrymonkey commented 1 year ago

git log --oneline

637bfb1 (HEAD -> master, origin/master, origin/HEAD) Merge pull request #312 from KomputeProject/axsaucedo-patch-5 0cd2d7a Updating default headers to Vulkan v1.3.231 a40adf8 Merge pull request #311 from hungrymonkey/fixbuilderror 9eac80f (origin/fixbuilderror) Fixed build error on gcc 12 6b8b6e8 Merge pull request #309 from KomputeProject/1_3_vulkan_upgrade b23e925 (origin/1_3_vulkan_upgrade) Removed parallel as caused issues in build 06e5c15 Updating cmake build from fork

hungrymonkey commented 1 year ago

gcc --version gcc (SUSE Linux) 12.2.1 20221020 [revision 0aaef83351473e8f4eb774f8f999bbe87a4866d7] Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

axsaucedo commented 1 year ago

Added #314 which allows for build against source or different commit - also now runs as part of CI