Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/Clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [16, 17, 20]
version: [16, 17, 20, 23]

runs-on: ubuntu-latest

Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [14, 15, 17, 20]
version: [15, 17, 20, 23]

runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/GCC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [9, 10, 11, 12, 13, 14, 15]
version: [10, 11, 12, 13, 14, 15, 16]

runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
# SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception
# Copyright © 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
# Matthias Kretz <m.kretz@gsi.de>
# Copyright © 2023 Álvaro Fernández Sánchez
Expand Down
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,22 @@ whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.


LGPL-3.0-linking-exception

As a special exception to the GNU Lesser General Public License
version 3 ("LGPL3"), the copyright holders of this Library give you
permission to convey to a third party a Combined Work that links statically
or dynamically to this Library without providing any Minimal Corresponding
Source or Minimal Application Code as set out in section 4d or providing the
installation information set out in section 4e, provided that you comply with
the other provisions of LGPL3 and provided that you meet, for the Application
the terms and conditions of the license(s) which apply to the Application.

Except as stated in this special exception, the provisions of LGPL3 will
continue to comply in full to this Library. If you modify this Library, you
may apply this exception to your version of this Library, but you are not
obliged to do so. If you do not wish to do so, delete this exception statement
from your version. This exception does not (and cannot) modify any license
terms which apply to the Application, with which you must still comply.
16 changes: 16 additions & 0 deletions LICENSES/LGPL-3.0-linking-exception.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
As a special exception to the GNU Lesser General Public License version 3
("LGPL3"), the copyright holders of this Library give you permission to
convey to a third party a Combined Work that links statically or dynamically
to this Library without providing any Minimal Corresponding Source or
Minimal Application Code as set out in 4d or providing the installation
information set out in section 4e, provided that you comply with the other
provisions of LGPL3 and provided that you meet, for the Application the
terms and conditions of the license(s) which apply to the Application.

Except as stated in this special exception, the provisions of LGPL3 will
continue to comply in full to this Library. If you modify this Library, you
may apply this exception to your version of this Library, but you are not
obliged to do so. If you do not wish to do so, delete this exception
statement from your version. This exception does not (and cannot) modify any
license terms which apply to the Application, with which you must still
comply.
2 changes: 1 addition & 1 deletion latest_std_flag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright © 2023–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
# Matthias Kretz <m.kretz@gsi.de>

for std in gnu++23 gnu++2b c++23 c++2b gnu++20 gnu++2a c++20 c++2a gnu++17 c++17; do
for std in gnu++26 c++26 gnu++23 gnu++2b c++23 c++2b gnu++20 gnu++2a c++20 c++2a gnu++17 c++17; do
if $CXX -x c++ -c -std=$std /dev/null 2>/dev/null; then
echo $std
exit
Expand Down
2 changes: 1 addition & 1 deletion stdlibtest.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2025 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/constexpr_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2023-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/detail.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2022–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2022–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_benchmarking.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2019–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_bit.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2022–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_bitset.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2022–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_cast.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2022–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_concepts.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2023–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_cvt.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2023–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_execution.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2023–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_float_ops.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2022–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_iota.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2023–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
98 changes: 96 additions & 2 deletions vir/simd_permute.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2023–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down Expand Up @@ -185,7 +185,7 @@ namespace vir

#if defined __GNUC__
if (not std::is_constant_evaluated())
if constexpr (std::has_single_bit(sizeof(V)) and V::size() <= stdx::native_simd<T>::size())
if constexpr (std::has_single_bit(sizeof(V)))// and V::size() <= stdx::native_simd<T>::size())
{
#if defined __AVX2__
using v4df [[gnu::vector_size(32)]] = double;
Expand Down Expand Up @@ -330,6 +330,100 @@ namespace vir
return a[w + j];
});
}

template <vir::any_simd_or_mask V0, std::same_as<V0>... Vs>
VIR_ALWAYS_INLINE constexpr stdx::resize_simd_t<V0::size() * (1 + sizeof...(Vs)), V0>
simd_interleave(V0 const& v0, Vs const&... vs) noexcept
{
using T = typename V0::value_type;
constexpr unsigned Bytes = sizeof(T) * std::bit_ceil(unsigned(V0::size()));
using VBuiltin [[gnu::vector_size(Bytes)]] = T;
if constexpr (V0::size() == 4 and sizeof...(Vs) == 1 and std::is_trivially_copyable_v<V0>)
{
return [](VBuiltin r0, VBuiltin r1) {
#if defined __SSE__ and defined __GNUC__
return stdx::concat(V0(__builtin_ia32_unpcklps (r0, r1)),
V0(__builtin_ia32_unpckhps (r0, r1)));
#else
return stdx::concat(
std::bit_cast<V0>(__builtin_shufflevector(r0, r1, 0, 4, 1, 5)),
std::bit_cast<V0>(__builtin_shufflevector(r0, r1, 2, 6, 3, 7)));
#endif
}(std::bit_cast<VBuiltin>(v0), std::bit_cast<VBuiltin>(vs)...);
}
#if defined __SSE__ and defined __GNUC__
else if constexpr (std::is_floating_point_v<T> and sizeof(T) == sizeof(float)
and V0::size() == 4 and sizeof...(Vs) == 3)
{
return [](VBuiltin r0, VBuiltin r1, VBuiltin r2, VBuiltin r3) {
VBuiltin t0 = __builtin_ia32_unpcklps(r0, r1);
VBuiltin t1 = __builtin_ia32_unpcklps(r2, r3);
VBuiltin t2 = __builtin_ia32_unpckhps(r0, r1);
VBuiltin t3 = __builtin_ia32_unpckhps(r2, r3);
return stdx::concat(std::bit_cast<V0>(__builtin_ia32_movlhps(t0, t1)),
std::bit_cast<V0>(__builtin_ia32_movhlps(t1, t0)),
std::bit_cast<V0>(__builtin_ia32_movlhps(t2, t3)),
std::bit_cast<V0>(__builtin_ia32_movhlps(t3, t2)));
}(std::bit_cast<VBuiltin>(v0), std::bit_cast<VBuiltin>(vs)...);
}
#endif
#if defined __SSE2__ and defined __GNUC__ and __has_builtin(__builtin_ia32_punpckldq128)
else if constexpr (std::is_integral_v<T> and sizeof(T) == sizeof(int)
and V0::size() == 4 and sizeof...(Vs) == 3)
{
using VInt [[gnu::vector_size(16)]] = int;
return [](VInt r0, VInt r1, VInt r2, VInt r3) {
VInt t0 = __builtin_ia32_punpckldq128(r0, r2);
VInt t1 = __builtin_ia32_punpckldq128(r1, r3);
VInt t2 = __builtin_ia32_punpckhdq128(r0, r2);
VInt t3 = __builtin_ia32_punpckhdq128(r1, r3);
return stdx::concat(std::bit_cast<V0>(__builtin_ia32_punpckldq128(t0, t1)),
std::bit_cast<V0>(__builtin_ia32_punpckhdq128(t0, t1)),
std::bit_cast<V0>(__builtin_ia32_punpckldq128(t2, t3)),
std::bit_cast<V0>(__builtin_ia32_punpckhdq128(t2, t3)));
}(std::bit_cast<VInt>(v0), std::bit_cast<VInt>(vs)...);
}
#endif
else if constexpr (std::is_floating_point_v<T> and sizeof(T) == sizeof(double)
and V0::size() == 4 and sizeof...(Vs) == 3)
{
#if defined __AVX__ and defined __GNUC__
return [](VBuiltin a, VBuiltin b, VBuiltin c, VBuiltin d) {
VBuiltin t0 = __builtin_ia32_unpcklpd256(a, b); // a0 b0 a2 b2
VBuiltin t1 = __builtin_ia32_unpcklpd256(c, d); // c0 d0 c2 d2
VBuiltin t2 = __builtin_ia32_unpckhpd256(a, b); // a1 b1 a3 b3
VBuiltin t3 = __builtin_ia32_unpckhpd256(c, d); // c1 d1 c3 d3
return stdx::concat(std::bit_cast<V0>(__builtin_ia32_vperm2f128_pd256(t0, t1, 0x20)),
std::bit_cast<V0>(__builtin_ia32_vperm2f128_pd256(t2, t3, 0x20)),
std::bit_cast<V0>(__builtin_ia32_vperm2f128_pd256(t0, t1, 0x31)),
std::bit_cast<V0>(__builtin_ia32_vperm2f128_pd256(t3, t2, 0x31)));
}(std::bit_cast<VBuiltin>(v0), std::bit_cast<VBuiltin>(vs)...);
#elif defined __SSE2__ and defined __GNUC__ and __has_builtin(__builtin_ia32_unpcklpd)
using v2df [[gnu::vector_size(16)]] = double;
using v4df = v2df[2];
return [](auto a0, auto b0, auto c0, auto d0) {
v4df a, b, c, d;
std::memcpy(&a, &a0, sizeof(v4df));
std::memcpy(&b, &b0, sizeof(v4df));
std::memcpy(&c, &c0, sizeof(v4df));
std::memcpy(&d, &d0, sizeof(v4df));
stdx::fixed_size_simd<T, 16> ret;
v2df tmp[8] = {
__builtin_ia32_unpcklpd(a[0], b[0]), __builtin_ia32_unpcklpd(c[0], d[0]),
__builtin_ia32_unpckhpd(a[0], b[0]), __builtin_ia32_unpckhpd(c[0], d[0]),
__builtin_ia32_unpcklpd(a[1], b[1]), __builtin_ia32_unpcklpd(c[1], d[1]),
__builtin_ia32_unpckhpd(a[1], b[1]), __builtin_ia32_unpckhpd(c[1], d[1])
};
std::memcpy(&detail::internal_data_hack(ret, 0), tmp, sizeof(tmp));
return ret;
}(detail::internal_data_hack(v0, 0), detail::internal_data_hack(vs, 0)...);
#endif
}
return simd_permute(stdx::concat(v0, vs...), [](int i) {
constexpr int N = 1 + sizeof...(vs);
return (i % N) * V0::size() + (i / N);
});
}
}

#endif // has concepts
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_resize.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2022–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simd_version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2024–2025 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
2 changes: 1 addition & 1 deletion vir/simdize.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2023–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
17 changes: 16 additions & 1 deletion vir/struct_reflect.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2018–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down Expand Up @@ -27,6 +27,19 @@ namespace vir
using std::size_t;

// struct_size implementation
#if __cpp_structured_bindings >= 202411L

template <typename T>
requires requires { T{}; }
consteval size_t
struct_size()
{
[[maybe_unused]] auto [...pack] = T{};
return sizeof...(pack);
}

#else

template <typename Struct>
struct anything_but_base_of
{
Expand Down Expand Up @@ -117,6 +130,8 @@ namespace vir
}
}

#endif

// struct_get implementation
template <size_t Total>
struct struct_get;
Expand Down
22 changes: 12 additions & 10 deletions vir/test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2023–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down Expand Up @@ -209,7 +209,7 @@ namespace test_struct_reflect
static_assert(vir::reflectable_struct<std::array<int, 0>>);
static_assert(vir::reflectable_struct<std::array<int, 2>>);
static_assert(vir::reflectable_struct<std::pair<int, short>>);
static_assert(not vir::reflectable_struct<std::complex<float>>);
static_assert(vir::reflectable_struct<std::complex<float>>);

template <typename T>
struct A
Expand Down Expand Up @@ -248,10 +248,14 @@ static_assert(std::same_as<vir::simdize<void>, void>);

static_assert(std::same_as<vir::simdize<std::tuple<>>, std::tuple<>>);

static_assert(std::same_as<vir::simdize<std::complex<float>>, std::complex<float>>);
static_assert(std::same_as<vir::simdize<std::complex<float>>,
vir::vectorized_struct<std::complex<float>, V<float>::size()>>);

static_assert(std::is_base_of_v<std::complex<V<float>>, vir::simdize<std::complex<float>>>);

static_assert(std::same_as<vir::simdize<std::tuple<std::complex<float>>>,
std::tuple<std::complex<float>>>);
vir::vectorized_struct<std::tuple<std::complex<float>>,
V<float>::size()>>);

static_assert(std::same_as<vir::simdize<std::tuple<int, double>>,
vir::vectorized_struct<std::tuple<int, double>, V<int>::size()>>);
Expand Down Expand Up @@ -388,12 +392,10 @@ static_assert(vir::simdize_size_v<vir::simdize<Point>> == stdx::native_simd<floa
static_assert(std::same_as<typename vir::simdize<Point>::mask_type,
typename V<float>::mask_type>);

static_assert(not vir::vectorizable_struct<std::complex<float>>);
static_assert(not vir::vectorizable_struct<std::tuple<std::complex<float>>>);
static_assert(not vir::vectorizable_struct<std::tuple<std::complex<float>,
std::complex<double>>>);
static_assert(not vir::vectorizable_struct<std::tuple<int, float, double,
std::complex<double>>>);
static_assert(vir::vectorizable_struct<std::complex<float>>);
static_assert(vir::vectorizable_struct<std::tuple<std::complex<float>>>);
static_assert(vir::vectorizable_struct<std::tuple<std::complex<float>, std::complex<double>>>);
static_assert(vir::vectorizable_struct<std::tuple<int, float, double, std::complex<double>>>);

void f(typename vir::detail::simdize_template_arguments<Point, 0>::type);
static_assert(vir::vectorizable_struct_template<Point>);
Expand Down
2 changes: 1 addition & 1 deletion vir/test_constexpr_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/* SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception */
/* Copyright © 2023–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
* Matthias Kretz <m.kretz@gsi.de>
*/
Expand Down
Loading