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

gcc12 build fails because std:shared_ptr requires explicit declation of <memory> #310

Closed
hungrymonkey opened this issue Nov 26, 2022 · 12 comments

Comments

@hungrymonkey
Copy link

Build fails on opensuse tumbleweed

Steps to reproduce
    ##Tested on commit 6b8b6e864a35a43ee71fe652fc95013aacf6904f
    $git clone https://github.com/KomputeProject/kompute.git
    $cmake -Bbuild
    $cd build
    $make
    
    $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.
    
     $lsb_release -a
    LSB Version:    n/a
    Distributor ID: openSUSE
    Description:    openSUSE Tumbleweed
    Release:        20221124
    Codename:       n/a
    
   Error log
gitrepo/kompute/build> make
[ 16%] Built target fmt
[ 27%] Built target kp_shader
[ 38%] Built target kp_logger
[ 44%] Building CXX object src/CMakeFiles/kompute.dir/OpTensorCopy.cpp.o
    In file included from /home/doof/gitrepo/kompute/src/include/kompute/operations/OpTensorCopy.hpp:6,
                     from /home/doof/gitrepo/kompute/src/OpTensorCopy.cpp:3:
    /home/doof/gitrepo/kompute/src/include/kompute/Tensor.hpp:55:27: error: expected ‘)’ before ‘<’ token
       55 |     Tensor(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
          |           ~               ^
          |                           )
    /home/doof/gitrepo/kompute/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/src/include/kompute/Tensor.hpp:108:40: error: expected ‘,’ or ‘...’ before ‘<’ token
      108 |                         std::shared_ptr<Tensor> copyFromTensor);
          |                                        ^
    /home/doof/gitrepo/kompute/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/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/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/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/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;
hungrymonkey pushed a commit to hungrymonkey/kompute that referenced this issue Nov 26, 2022
Steps to reproduce

$git clone https://github.com/KomputeProject/kompute.git
$cmake -Bbuild
$cd build
$make

$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.

 $lsb_release -a
LSB Version:    n/a
Distributor ID: openSUSE
Description:    openSUSE Tumbleweed
Release:        20221124
Codename:       n/a

Error log
In file included from /home/doof/gitrepo/kompute/src/include/kompute/operations/OpTensorCopy.hpp:6,
                 from /home/doof/gitrepo/kompute/src/OpTensorCopy.cpp:3:
/home/doof/gitrepo/kompute/src/include/kompute/Tensor.hpp:55:27: error: expected ‘)’ before ‘<’ token
   55 |     Tensor(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
      |           ~               ^
      |                           )
/home/doof/gitrepo/kompute/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/src/include/kompute/Tensor.hpp:108:40: error: expected ‘,’ or ‘...’ before ‘<’ token
  108 |                         std::shared_ptr<Tensor> copyFromTensor);
      |                                        ^
/home/doof/gitrepo/kompute/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/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/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/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/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/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/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;

Final result

$make
[ 16%] Built target fmt
[ 27%] Built target kp_shader
[ 38%] Built target kp_logger
[ 44%] Building CXX object src/CMakeFiles/kompute.dir/Algorithm.cpp.o
[ 50%] Building CXX object src/CMakeFiles/kompute.dir/Manager.cpp.o
[ 55%] Building CXX object src/CMakeFiles/kompute.dir/OpAlgoDispatch.cpp.o
[ 61%] Building CXX object src/CMakeFiles/kompute.dir/OpMemoryBarrier.cpp.o
[ 66%] Building CXX object src/CMakeFiles/kompute.dir/OpTensorCopy.cpp.o
[ 72%] Building CXX object src/CMakeFiles/kompute.dir/OpTensorSyncDevice.cpp.o
[ 77%] Building CXX object src/CMakeFiles/kompute.dir/OpTensorSyncLocal.cpp.o
[ 83%] Building CXX object src/CMakeFiles/kompute.dir/Sequence.cpp.o
[ 88%] Building CXX object src/CMakeFiles/kompute.dir/Tensor.cpp.o
[ 94%] Building CXX object src/CMakeFiles/kompute.dir/Core.cpp.o
[100%] Linking CXX static library ../lib/libkompute.a
[100%] Built target kompute

Fixes Issue KomputeProject#310
hungrymonkey pushed a commit to hungrymonkey/kompute that referenced this issue Nov 26, 2022
Steps to reproduce

$git clone https://github.com/KomputeProject/kompute.git
$cmake -Bbuild
$cd build
$make

$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.

 $lsb_release -a
LSB Version:    n/a
Distributor ID: openSUSE
Description:    openSUSE Tumbleweed
Release:        20221124
Codename:       n/a

Error log
In file included from /home/doof/gitrepo/kompute/src/include/kompute/operations/OpTensorCopy.hpp:6,
                 from /home/doof/gitrepo/kompute/src/OpTensorCopy.cpp:3:
/home/doof/gitrepo/kompute/src/include/kompute/Tensor.hpp:55:27: error: expected ‘)’ before ‘<’ token
   55 |     Tensor(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
      |           ~               ^
      |                           )
/home/doof/gitrepo/kompute/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/src/include/kompute/Tensor.hpp:108:40: error: expected ‘,’ or ‘...’ before ‘<’ token
  108 |                         std::shared_ptr<Tensor> copyFromTensor);
      |                                        ^
/home/doof/gitrepo/kompute/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/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/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/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/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/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/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;

Final result

$make
[ 16%] Built target fmt
[ 27%] Built target kp_shader
[ 38%] Built target kp_logger
[ 44%] Building CXX object src/CMakeFiles/kompute.dir/Algorithm.cpp.o
[ 50%] Building CXX object src/CMakeFiles/kompute.dir/Manager.cpp.o
[ 55%] Building CXX object src/CMakeFiles/kompute.dir/OpAlgoDispatch.cpp.o
[ 61%] Building CXX object src/CMakeFiles/kompute.dir/OpMemoryBarrier.cpp.o
[ 66%] Building CXX object src/CMakeFiles/kompute.dir/OpTensorCopy.cpp.o
[ 72%] Building CXX object src/CMakeFiles/kompute.dir/OpTensorSyncDevice.cpp.o
[ 77%] Building CXX object src/CMakeFiles/kompute.dir/OpTensorSyncLocal.cpp.o
[ 83%] Building CXX object src/CMakeFiles/kompute.dir/Sequence.cpp.o
[ 88%] Building CXX object src/CMakeFiles/kompute.dir/Tensor.cpp.o
[ 94%] Building CXX object src/CMakeFiles/kompute.dir/Core.cpp.o
[100%] Linking CXX static library ../lib/libkompute.a
[100%] Built target kompute

Fixes Issue KomputeProject#310

Signed-off-by: hungrymonkey <tedchang2010@gmail.com>
@hungrymonkey
Copy link
Author

https://gcc.gnu.org/gcc-12/porting_to.html

There may be more issues related to gcc 12

Porting to GCC 12

The GCC 12 release series differs from previous GCC releases in a number of ways. Some of these are a result of bug fixing, and some old behaviors have been intentionally changed to support new standards, or relaxed in standards-conforming ways to facilitate compilation or run-time performance.

Some of these changes are user visible and can cause grief when porting to GCC 12. This document is an effort to identify common issues and provide solutions. Let us know if you have suggestions for improvements!
C language issues
Computed goto now requires a pointer type

In GCC 12, a computed goto requires a pointer type. An example which was accepted before:

void f(void)
{
goto *10;
}

is no longer accepted and you need to add a cast to it like:

void f(void)
{
goto (void)10;
}

C++ language issues
Header dependency changes

Some C++ Standard Library headers have been changed to no longer include other headers that were being used internally by the library. As such, C++ programs that used standard library components without including the right headers will no longer compile.

The following headers are used less widely in libstdc++ and may need to be included explicitly when compiled with GCC 12:

<memory> (for std::shared_ptr, std::unique_ptr etc.)
<iterator> (for std::begin, std::end, std::size, std::istream_iterator, std::istreambuf_iterator)
<algorithm> (for std::for_each, std::copy etc.)
<utility> (for std::pair)
<array> (for std::array)
<atomic> (for std::atomic)
<ctime> (for std::time, std::mktime etc.)
<pthread.h> (for pthread_create, pthread_mutex_t etc.)

C++ Standard Library deprecations

Warnings have been added for use of C++ standard library features that are deprecated (or no longer present at all) in recent C++ standards. Where possible, the warning suggests a modern replacement for the deprecated feature.

The std::iterator base class can usually be replaced by defining the same necessary typedefs directly in your iterator class. The std::unary_function and std::binary_function base classes can often be completely removed, or the typedefs for result_type and argument types can be defined directly in your class.
Fortran language issues
Argument name for CO_REDUCE

GCC 12 now uses OPERATION as the name of the function to the CO_REDUCE intrinsic for the pairwise reduction, thus conforming to the Fortran 2018 standard. Previous versions used OPERATOR, which conformed to TS 18508

@hungrymonkey hungrymonkey changed the title Build fails on Opensuse tumbleweed gcc12 build fails because std:shared_ptr requires explicit declation of <memory> Nov 26, 2022
@hungrymonkey
Copy link
Author

My commit may be incomplete

cmake -Bbuild
-- General purpose GPU compute framework built on Vulkan
-- =======================================================
-- KOMPUTE_OPT_BUILD_TESTS: OFF
-- KOMPUTE_OPT_CODE_COVERAGE: OFF
-- KOMPUTE_OPT_BUILD_DOCS: OFF
-- KOMPUTE_OPT_INSTALL: OFF
-- KOMPUTE_OPT_BUILD_PYTHON: OFF
-- KOMPUTE_OPT_LOG_LEVEL: Default
-- KOMPUTE_OPT_USE_SPDLOG: OFF
-- KOMPUTE_OPT_ANDROID_BUILD: OFF
-- KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS: OFF
-- KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK: OFF
-- KOMPUTE_OPT_BUILD_SHADERS: OFF
-- KOMPUTE_OPT_USE_BUILT_IN_SPDLOG: ON
-- KOMPUTE_OPT_USE_BUILT_IN_FMT: ON
-- KOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST: ON
-- KOMPUTE_OPT_USE_BUILT_IN_PYBIND11: ON
-- KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER: OFF
-- KOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG: v1.2.203
-- =======================================================
-- Ensuring the currently installed driver supports the Vulkan version requested by the Vulkan Header.
-- Found Vulkan Header version: 1.2.231
-- Running vulkaninfo was successful. Parsing the output...
-- GPU0 supports Vulkan API version '1.3.224'.
Valid GPU (GPU0) for Vulkan header version 1.2.231 found. GPU0 supports up to Vulkan 1.3.224.
-- Module support is disabled.
-- Version: 8.1.1
-- Build type: Release
-- CXX_STANDARD: 14
-- Required features: cxx_variadic_templates
-- Setting KOMPUTE_OPT_LOG_LEVEL to according to the build type
-- Configuring done
-- Generating done
-- Build files have been written to: /home/doof/gitrepo/kompute/examples/array_multiplication/build

I could not build the example code

make
[ 13%] Built target fmt
[ 22%] Built target kp_shader
[ 31%] Built target kp_logger
[ 36%] 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

@hungrymonkey
Copy link
Author

ahh, Cmake fetches the old version

I made a quick and dirty change and it compiles. I guess I will not include this change in my commit and let the maintainer deal with Cmake.

diff --git a/examples/array_multiplication/CMakeLists.txt b/examples/array_multiplication/CMakeLists.txt
index 6e0c907..b17cb65 100644
--- a/examples/array_multiplication/CMakeLists.txt
+++ b/examples/array_multiplication/CMakeLists.txt
@@ -25,8 +25,8 @@ if(WIN32) # Install dlls in the same directory as the executable on Windows
 endif()
 
 include(FetchContent)
-FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/KomputeProject/kompute.git
-    GIT_TAG 1344ece4ac278f9b3be3b4555ffaace7a032b91f) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases
+FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/hungrymonkey/kompute.git
+    GIT_TAG 9eac80f048fb24594ef7d0f2005aed2bf4c6f897) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases
 FetchContent_MakeAvailable(kompute)
 include_directories(${kompute_SOURCE_DIR}/src/include)

@hungrymonkey
Copy link
Author

src> ls
CMakeFiles  cmake_install.cmake  kompute_array_mult  Makefile
doof@steamdeck:~/gitrepo/kompute/examples/array_multiplication/build/src> ./kompute_array_mult 
[Nov 25 2022 20:15:14] [info] [/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/Manager.cpp:339] Using physical device index 0 found AMD Custom GPU 0405 (RADV VANGOGH)
[Nov 25 2022 20:15:39] [info] [/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/include/kompute/Algorithm.hpp:50] Kompute Algorithm initialising with tensor size: 3 and spirv size: 319
[Nov 25 2022 20:15:11] [info] [/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/Algorithm.cpp:371] Kompute OpAlgoCreate setting dispatch size
[Nov 25 2022 20:15:11] [info] [/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/Algorithm.cpp:385] Kompute OpAlgoCreate set dispatch size X: 3, Y: 1, Z: 1
[Nov 25 2022 20:15:30] [info] [/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/Sequence.cpp:51] Kompute Sequence command now started recording
[Nov 25 2022 20:15:30] [info] [/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/Sequence.cpp:77] Kompute Sequence command recording END
[Nov 25 2022 20:15:30] [info] [/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/Sequence.cpp:218] Freeing CommandBuffer
[Nov 25 2022 20:15:30] [info] [/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/Sequence.cpp:234] Destroying CommandPool
[Nov 25 2022 20:15:30] [info] [/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/Sequence.cpp:251] Kompute Sequence clearing operations buffer
Output: {  0  4  12  }
[Nov 25 2022 20:15:14] [info] [/home/doof/gitrepo/kompute/examples/array_multiplication/build/_deps/kompute-src/src/Manager.cpp:123] Destroying device

@axsaucedo
Copy link
Member

@hungrymonkey not sure I understand your last few comments - are you saying that you managed to get it to work with the fixes in the PR or without the fixes in the PR?

@axsaucedo
Copy link
Member

axsaucedo commented Nov 26, 2022

I've reproduced and merged - thanks for the update

@hungrymonkey
Copy link
Author

@axsaucedo

I am saying there are two separate issues. The way you manage cmake seems like a build and release issue, so I will not handle it.

@axsaucedo
Copy link
Member

I don't understand what you mean, what do you mean by build and release issue? Or what do you mean by handling it?

@hungrymonkey
Copy link
Author

GIT_TAG 1344ece4ac278f9b3be3b4555ffaace7a032b91f) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases

cmake_minimum_required(VERSION 3.20)
project(kompute_array_mult)

set(CMAKE_CXX_STANDARD 14)

# Set a default build type if none was specified
# Based on: https://github.com/openchemistry/tomviz/blob/master/cmake/BuildType.cmake
set(DEFAULT_BUILD_TYPE "Release")

if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
    set(DEFAULT_BUILD_TYPE "Debug")
endif()

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
    message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
    set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)

    # Set the possible values of build type for cmake-gui
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

if(WIN32) # Install dlls in the same directory as the executable on Windows
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif()

include(FetchContent)
FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/KomputeProject/kompute.git
    GIT_TAG 1344ece4ac278f9b3be3b4555ffaace7a032b91f) # The commit hash for a dev version before v0.9.0. Replace with the latest from: 
## This commit needs to be changed to be compatible with gcc12
https://github.com/KomputeProject/kompute/releases
FetchContent_MakeAvailable(kompute)
include_directories(${kompute_SOURCE_DIR}/src/include)

# Add to the list, so CMake can later find the code to compile shaders to header files
list(APPEND CMAKE_PREFIX_PATH "${kompute_SOURCE_DIR}/cmake")

add_subdirectory(shader)
add_subdirectory(src)

The array_multiplication example code will fail to compile because the cmake fetches an old version of kompute on github instead of my local machine.

@hungrymonkey
Copy link
Author

I will write a separate bug report.

@hungrymonkey
Copy link
Author

#313

@axsaucedo
Copy link
Member

@hungrymonkey got it, thanks for the context, I'll have a look at adding an option to allow this built from local repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants