Closed hungrymonkey closed 1 year ago
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
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
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)
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
@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?
I've reproduced and merged - thanks for the update
@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.
I don't understand what you mean, what do you mean by build and release issue? Or what do you mean by handling it?
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.
I will write a separate bug report.
@hungrymonkey got it, thanks for the context, I'll have a look at adding an option to allow this built from local repo
Build fails on opensuse tumbleweed