Bug 488116

Summary: krita doesn't detect xsimd 13 (and fails to build)
Product: [Applications] krita Reporter: Christophe Marin <christophe>
Component: GeneralAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: arojas, dimula73
Priority: NOR Keywords: release_blocker
Version: 5.2.3-beta1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Christophe Marin 2024-06-06 15:26:49 UTC
Observed with our master build but the 5.2.3 beta tag isn't different in that area:

CMake log:
[   74s] -- Could NOT find xsimd (Required is at least version &quot;8.1.0&quot;), checked the following files:
[   74s]     /usr/lib64/cmake/xsimd/xsimdConfig.cmake (version 13.0.0)
[   74s]     /lib64/cmake/xsimd/xsimdConfig.cmake (version 13.0.0)
[   74s] 
[   74s] -- Could NOT find xsimd (Required is at least version &quot;9&quot;), checked the following files:
[   74s]     /usr/lib64/cmake/xsimd/xsimdConfig.cmake (version 13.0.0)
[   74s]     /lib64/cmake/xsimd/xsimdConfig.cmake (version 13.0.0)
[   74s] 
[   74s] -- Could NOT find xsimd (Required is at least version &quot;10&quot;), checked the following files:
[   74s]     /usr/lib64/cmake/xsimd/xsimdConfig.cmake (version 13.0.0)
[   74s]     /lib64/cmake/xsimd/xsimdConfig.cmake (version 13.0.0)
[   74s] 
[   74s] -- Could NOT find xsimd (Required is at least version &quot;11&quot;), checked the following files:
[   74s]     /usr/lib64/cmake/xsimd/xsimdConfig.cmake (version 13.0.0)
[   74s]     /lib64/cmake/xsimd/xsimdConfig.cmake (version 13.0.0)
[   74s] 
[   74s] -- Could NOT find xsimd (Required is at least version &quot;12&quot;), checked the following files:
[   74s]     /usr/lib64/cmake/xsimd/xsimdConfig.cmake (version 13.0.0)
[   74s]     /lib64/cmake/xsimd/xsimdConfig.cmake (version 13.0.0)

and build fails later because the XSIMD defines are missing:
[  216s] In file included from /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240606T021953~0338882c3/libs/pigment/KoOptimizedPixelDataScalerU8ToU16FactoryImpl.cpp:11:
[  216s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240606T021953~0338882c3/libs/pigment/KoOptimizedPixelDataScalerU8ToU16.h:145:49: warning: &quot;XSIMD_WITH_NEON&quot; is not defined, evaluates to 0 [-Wundef]
[  216s]   145 | #elif defined(HAVE_XSIMD) &amp;&amp; XSIMD_WITH_SSE2 || XSIMD_WITH_NEON || XSIMD_WITH_NEON64
[  216s]       |                                                 ^~~~~~~~~~~~~~~
[  216s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240606T021953~0338882c3/libs/pigment/KoOptimizedPixelDataScalerU8ToU16.h:145:68: warning: &quot;XSIMD_WITH_NEON64&quot; is not defined, evaluates to 0 [-Wundef]
[  216s]   145 | #elif defined(HAVE_XSIMD) &amp;&amp; XSIMD_WITH_SSE2 || XSIMD_WITH_NEON || XSIMD_WITH_NEON64
[  216s]       |

[ cut ]

[  314s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240606T021953~0338882c3/libs/pigment/compositeops/KoStreamedMath.h:819:5: warning: &quot;XSIMD_VERSION_MAJOR&quot; is not defined, evaluates to 0 [-Wundef]
[  314s]   819 | #if XSIMD_VERSION_MAJOR < 10
[  314s]       |     ^~~~~~~~~~~~~~~~~~~
[  314s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240606T021953~0338882c3/libs/pigment/compositeops/KoRgbaInterleavers.h:27:55: error: ‘batch’ was not declared in this scope; did you mean ‘rpmatch’?
[  314s]    27 | using enable_sized_vector_t = typename std::enable_if<batch<T, A>::size == S, int>::type;
[  314s]       |                                                       ^~~~~
[  314s]       |                                                       rpmatch
[  314s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240606T021953~0338882c3/libs/pigment/compositeops/KoRgbaInterleavers.h:27:65: error: template argument 1 is invalid
[  314s]    27 | using enable_sized_vector_t = typename std::enable_if<batch<T, A>::size == S, int>::type;
[  314s]       |                                                                 ^
[  314s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240606T021953~0338882c3/libs/pigment/compositeops/KoRgbaInterleavers.h:27:66: error: expected identifier before ‘::’ token
[  314s]    27 | using enable_sized_vector_t = typename std::enable_if<batch<T, A>::size == S, int>::type;
[  314s]       |                                                                  ^~
[  314s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240606T021953~0338882c3/libs/pigment/compositeops/KoRgbaInterleavers.h:98:87: error: ‘enable_sized_vector_t’ has not been declared
[  314s]    98 |     template<bool aligned, typename T, typename A, enable_sized_integral_t<T, 4> = 0, enable_sized_vector_t<T, A, 4> = 0>
[  314s]       |                                                                                       ^~~~~~~~~~~~~~~~~~~~~
[  314s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240606T021953~0338882c3/libs/pigment/compositeops/KoRgbaInterleavers.h:98:108: error: expected ‘>’ before ‘<’ token
[  314s]    98 |     template<bool aligned, typename T, typename A, enable_sized_integral_t<T, 4> = 0, enable_sized_vector_t<T, A, 4> = 0>
[  314s]       |

[ lots of other related errors after]
Comment 1 Dmitry Kazakov 2024-06-07 11:13:23 UTC
Git commit 56a6c75fee8e7ac6e51c8479471222fed5a177fa by Dmitry Kazakov.
Committed on 07/06/2024 at 11:13.
Pushed by dkazakov into branch 'master'.

Enable building Krita with XSimd13

M  +1    -1    CMakeLists.txt

https://invent.kde.org/graphics/krita/-/commit/56a6c75fee8e7ac6e51c8479471222fed5a177fa
Comment 2 Dmitry Kazakov 2024-06-07 11:14:01 UTC
Git commit b31a0156e223d5d63aee9f077e90138f0000de81 by Dmitry Kazakov.
Committed on 07/06/2024 at 11:13.
Pushed by dkazakov into branch 'krita/5.2'.

Enable building Krita with XSimd13

M  +1    -1    CMakeLists.txt

https://invent.kde.org/graphics/krita/-/commit/b31a0156e223d5d63aee9f077e90138f0000de81
Comment 3 Antonio Rojas 2024-06-07 14:03:25 UTC
This doesn't work. xsimd 13 has major breaking changes and krita requires non-trivial porting. Version 13 shouldn't be accepted until krita can actually build with it.
Comment 4 Christophe Marin 2024-06-07 14:35:01 UTC
(In reply to Antonio Rojas from comment #3)
> This doesn't work. xsimd 13 has major breaking changes and krita requires
> non-trivial porting. Version 13 shouldn't be accepted until krita can
> actually build with it.

Yes, still fails:

[  108s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240607T131318~56a6c75fe/libs/multiarch/KisSupportedArchitectures.cpp: In static member function ‘static QString KisSupportedArchitectures::bestArchName()‘:
[  108s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240607T131318~56a6c75fe/libs/multiarch/KisSupportedArchitectures.cpp:39:69: error: ‘struct xsimd::detail::supported_arch‘ has no member named ‘best‘
[  108s]    39 |     const unsigned int best_arch = xsimd::available_architectures().best;
[  108s]       |                                                                     ^~~~
[  108s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240607T131318~56a6c75fe/libs/multiarch/KisSupportedArchitectures.cpp:55:25: error: ‘version‘ is not a member of ‘xsimd::avx‘
[  108s]    55 |         && (xsimd::avx::version() <= best_arch
[  108s]       |                         ^~~~~~~
[  108s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240607T131318~56a6c75fe/libs/multiarch/KisSupportedArchitectures.cpp:56:29: error: ‘version‘ is not a member of ‘xsimd::avx2‘
[  108s]    56 |             || xsimd::avx2::version() <= best_arch)) {
[  108s]       |                             ^~~~~~~
[  108s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240607T131318~56a6c75fe/libs/multiarch/KisSupportedArchitectures.cpp:66:38: error: ‘version‘ is not a member of ‘xsimd::fma3<xsimd::avx2>‘
[  108s]    66 |         && xsimd::fma3<xsimd::avx2>::version() <= best_arch) {
[  108s]       |                                      ^~~~~~~
[  108s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240607T131318~56a6c75fe/libs/multiarch/KisSupportedArchitectures.cpp:68:56: error: ‘version‘ is not a member of ‘xsimd::avx‘
[  108s]    68 |     } else if (!disableAVXOptimizations && xsimd::avx::version() <= best_arch) {
[  108s]       |                                                        ^~~~~~~
[  108s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240607T131318~56a6c75fe/libs/multiarch/KisSupportedArchitectures.cpp:70:31: error: ‘version‘ is not a member of ‘xsimd::sse4_1‘
[  108s]    70 |     } else if (xsimd::sse4_1::version() <= best_arch) {
[  108s]       |                               ^~~~~~~
[  108s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240607T131318~56a6c75fe/libs/multiarch/KisSupportedArchitectures.cpp:72:30: error: ‘version‘ is not a member of ‘xsimd::ssse3‘
[  108s]    72 |     } else if (xsimd::ssse3::version() <= best_arch) {
[  108s]       |                              ^~~~~~~
[  108s] /home/abuild/rpmbuild/BUILD/krita-5.2.40git.20240607T131318~56a6c75fe/libs/multiarch/KisSupportedArchitectures.cpp:74:29: error: ‘version‘ is not a member of ‘xsimd::sse2‘
[  108s]    74 |     } else if (xsimd::sse2::version() <= best_arch) {
[  108s]       |                             ^~~~~~~
Comment 5 Dmitry Kazakov 2024-06-14 08:27:17 UTC
Hi, Christophe Marin!

Is it possible to add two patches to XSIMD 13 in distributions? Given that they are accepted to xsimd-master?

I mean, I have ported Krita's code to xsimd-13, but xsimd-13 has a bug and makes Krita fail to compile (I'm going to post a PR for them). Is it possible to backport this PR to distributions packages?
Comment 6 Dmitry Kazakov 2024-06-14 10:22:55 UTC
Anyway, the fixes are now in both master and krita/5.2:

https://invent.kde.org/graphics/krita/-/commit/c325d25fb561364de0137a6fc66b42b17ed5ca97

Ideally, distributions should include the three patches (with 'xsimd13' prefix) into their builds to enable all the features that Krita uses:

https://invent.kde.org/dkazakov/krita-deps-management/-/tree/master/ext_xsimd?ref_type=heads

But Krita should also work withouth the patches, which minor limitations though.
Comment 7 Christophe Marin 2024-06-15 07:53:26 UTC
(In reply to Dmitry Kazakov from comment #5)
> Hi, Christophe Marin!
> 
> Is it possible to add two patches to XSIMD 13 in distributions? Given that
> they are accepted to xsimd-master?
> 
> I mean, I have ported Krita's code to xsimd-13, but xsimd-13 has a bug and
> makes Krita fail to compile (I'm going to post a PR for them). Is it
> possible to backport this PR to distributions packages?

Sure, send an email to distributions@kde.org when the changes are available in the xsimd repository
Comment 8 Dmitry Kazakov 2024-07-03 11:53:29 UTC
Okay, the patch was accepted by XSIMD maintainers. I have sent the mail to the distributions mailing list.