File indexing completed on 2024-05-12 15:59:17

0001 /*
0002  * SPDX-FileCopyrightText: 2022 L. E. Segovia <amy@amyspark.me>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "xsimd_extensions/xsimd.hpp"
0008 
0009 #ifndef KIS_SUPPORTED_ARCHITECTURES_H
0010 #define KIS_SUPPORTED_ARCHITECTURES_H
0011 
0012 template<typename S>
0013 class KisSupportedArchitectures
0014 {
0015 public:
0016     static S currentArchitecture()
0017     {
0018         return xsimd::current_arch::name();
0019     }
0020 
0021     static S supportedInstructionSets()
0022     {
0023         S archs;
0024 #ifdef HAVE_XSIMD
0025         xsimd::all_architectures::for_each(is_supported_arch{archs});
0026 #endif
0027         return archs;
0028     }
0029 
0030 private:
0031     struct is_supported_arch
0032     {
0033         is_supported_arch(S &log)
0034             : l (log) {}
0035 
0036         template<typename A>
0037         void operator()(A) const
0038         {
0039 #ifdef HAVE_XSIMD
0040             if (A::version() <= xsimd::available_architectures().best) {
0041                 l.append(A::name()).append(" ");
0042             }
0043 #endif
0044         }
0045 
0046         S &l;
0047     };
0048 };
0049 
0050 #endif // KIS_SUPPORTED_ARCHITECTURES_H