Skip to content

Commit 78b3f6f

Browse files
Add IBM Z (s390x) support
1 parent 8d6d1f1 commit 78b3f6f

9 files changed

Lines changed: 909 additions & 2 deletions

File tree

include/xsimd/arch/xsimd_isa.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@
136136
#include "./xsimd_vsx.hpp"
137137
#endif
138138

139+
#if XSIMD_WITH_VXE
140+
#include "./xsimd_vxe.hpp"
141+
#endif
142+
143+
139144
// Must come last to have access to all conversion specializations.
140145
#include "./xsimd_common.hpp"
141146

include/xsimd/arch/xsimd_vxe.hpp

Lines changed: 797 additions & 0 deletions
Large diffs are not rendered by default.

include/xsimd/config/xsimd_arch.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ namespace xsimd
172172
using all_power_architectures = arch_list<vsx>;
173173
using all_riscv_architectures = all_rvv_architectures;
174174
using all_wasm_architectures = arch_list<wasm>;
175-
using all_architectures = typename detail::join<all_power_architectures, all_riscv_architectures, all_wasm_architectures, all_arm_architectures, all_x86_architectures>::type;
175+
using all_s390x_architectures = arch_list<vxe>;
176+
using all_architectures = typename detail::join<all_power_architectures, all_riscv_architectures, all_wasm_architectures, all_arm_architectures, all_x86_architectures, all_s390x_architectures>::type;
176177

177178
using supported_architectures = typename detail::supported<all_architectures>::type;
178179

include/xsimd/config/xsimd_config.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,18 @@
510510
#define XSIMD_WITH_VSX 0
511511
#endif
512512

513+
/**
514+
+ * @ingroup xsimd_config_macro
515+
+ *
516+
+ * Set to 1 if s390x VXE is available at compile-time, to 0 otherwise.
517+
+ * Float vectors have been introduced with VXE included with IBM z14.
518+
+ */
519+
#if defined(__VEC__) && __VEC__==10305 && __ARCH__ >= 12
520+
#define XSIMD_WITH_VXE 1
521+
#else
522+
#define XSIMD_WITH_VXE 0
523+
#endif
524+
513525
// Workaround for MSVC compiler
514526
#ifdef _MSC_VER
515527

@@ -568,7 +580,7 @@
568580

569581
#endif
570582

571-
#if !XSIMD_WITH_SSE2 && !XSIMD_WITH_SSE3 && !XSIMD_WITH_SSSE3 && !XSIMD_WITH_SSE4_1 && !XSIMD_WITH_SSE4_2 && !XSIMD_WITH_AVX && !XSIMD_WITH_AVX2 && !XSIMD_WITH_AVXVNNI && !XSIMD_WITH_FMA3_SSE && !XSIMD_WITH_FMA4 && !XSIMD_WITH_FMA3_AVX && !XSIMD_WITH_FMA3_AVX2 && !XSIMD_WITH_AVX512F && !XSIMD_WITH_AVX512CD && !XSIMD_WITH_AVX512DQ && !XSIMD_WITH_AVX512BW && !XSIMD_WITH_AVX512ER && !XSIMD_WITH_AVX512PF && !XSIMD_WITH_AVX512IFMA && !XSIMD_WITH_AVX512VBMI && !XSIMD_WITH_AVX512VBMI2 && !XSIMD_WITH_NEON && !XSIMD_WITH_NEON64 && !XSIMD_WITH_SVE && !XSIMD_WITH_RVV && !XSIMD_WITH_WASM && !XSIMD_WITH_VSX && !XSIMD_WITH_EMULATED
583+
#if !XSIMD_WITH_SSE2 && !XSIMD_WITH_SSE3 && !XSIMD_WITH_SSSE3 && !XSIMD_WITH_SSE4_1 && !XSIMD_WITH_SSE4_2 && !XSIMD_WITH_AVX && !XSIMD_WITH_AVX2 && !XSIMD_WITH_AVXVNNI && !XSIMD_WITH_FMA3_SSE && !XSIMD_WITH_FMA4 && !XSIMD_WITH_FMA3_AVX && !XSIMD_WITH_FMA3_AVX2 && !XSIMD_WITH_AVX512F && !XSIMD_WITH_AVX512CD && !XSIMD_WITH_AVX512DQ && !XSIMD_WITH_AVX512BW && !XSIMD_WITH_AVX512ER && !XSIMD_WITH_AVX512PF && !XSIMD_WITH_AVX512IFMA && !XSIMD_WITH_AVX512VBMI && !XSIMD_WITH_AVX512VBMI2 && !XSIMD_WITH_NEON && !XSIMD_WITH_NEON64 && !XSIMD_WITH_SVE && !XSIMD_WITH_RVV && !XSIMD_WITH_WASM && !XSIMD_WITH_VSX && !XSIMD_WITH_EMULATED && !XSIMD_WITH_VXE
572584
#define XSIMD_NO_SUPPORTED_ARCHITECTURE
573585
#endif
574586

include/xsimd/config/xsimd_cpuid.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace xsimd
7171
ARCH_FIELD_EX(detail::rvv<128>, rvv128)
7272
ARCH_FIELD(wasm)
7373
ARCH_FIELD(vsx)
74+
ARCH_FIELD(vxe)
7475

7576
#undef ARCH_FIELD
7677

include/xsimd/types/xsimd_all_registers.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050

5151
#include "xsimd_vsx_register.hpp"
5252

53+
#include "xsimd_vxe_register.hpp"
54+
5355
#if XSIMD_WITH_EMULATED
5456
#include "xsimd_emulated_register.hpp"
5557
#endif
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/***************************************************************************
2+
* Copyright (c) Andreas Krebbel *
3+
* Based on xsimd_vsx_register.hpp *
4+
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
5+
* Martin Renou *
6+
* Copyright (c) QuantStack *
7+
* Copyright (c) Serge Guelton *
8+
* *
9+
* Distributed under the terms of the BSD 3-Clause License. *
10+
* *
11+
* The full license is in the file LICENSE, distributed with this software. *
12+
****************************************************************************/
13+
14+
#ifndef XSIMD_VXE_REGISTER_HPP
15+
#define XSIMD_VXE_REGISTER_HPP
16+
17+
#include "./xsimd_common_arch.hpp"
18+
#include "./xsimd_register.hpp"
19+
20+
#if XSIMD_WITH_VXE
21+
#include <vecintrin.h>
22+
#endif
23+
24+
namespace xsimd
25+
{
26+
/**
27+
* @ingroup architectures
28+
*
29+
* VXE instructions
30+
*/
31+
struct vxe : common
32+
{
33+
static constexpr bool supported() noexcept { return XSIMD_WITH_VXE; }
34+
static constexpr bool available() noexcept { return true; }
35+
static constexpr bool requires_alignment() noexcept { return true; }
36+
static constexpr std::size_t alignment() noexcept { return 16; }
37+
static constexpr char const* name() noexcept { return "vxe"; }
38+
};
39+
40+
#if XSIMD_WITH_VXE
41+
namespace types
42+
{
43+
44+
#define XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(T, Tv, Tb) \
45+
template <> \
46+
struct get_bool_simd_register<T, vxe> \
47+
{ \
48+
struct type \
49+
{ \
50+
using register_type = __vector __bool Tb; \
51+
register_type data; \
52+
type() = default; \
53+
type(register_type r) \
54+
: data(r) \
55+
{ \
56+
} \
57+
operator register_type() const noexcept { return data; } \
58+
}; \
59+
}; \
60+
XSIMD_DECLARE_SIMD_REGISTER(T, vxe, __vector Tv)
61+
62+
// The VXE vector intrinsics do not support long, unsigned long,
63+
// and char data types. batches of these types are vectors of
64+
// equivalent types.
65+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(signed char, signed char, char);
66+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(unsigned char, unsigned char, char);
67+
#ifdef __CHAR_UNSIGNED__
68+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(char, unsigned char, char);
69+
#else
70+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(char, signed char, char);
71+
#endif
72+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(unsigned short, unsigned short, short);
73+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(short, short, short);
74+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(unsigned int, unsigned int, int);
75+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(int, int, int);
76+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(unsigned long, unsigned long long, long long);
77+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(long, long long, long long);
78+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(float, float, int);
79+
XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER(double, double, long long);
80+
81+
#undef XSIMD_DECLARE_SIMD_BOOL_VXE_REGISTER
82+
}
83+
#endif
84+
}
85+
86+
#endif

test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
108108
# Nothing specific
109109
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc")
110110
# Nothing specific
111+
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "s390x")
112+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mzvector")
111113
elseif(NOT WIN32 AND NOT EMSCRIPTEN)
112114
if(NOT CMAKE_CXX_FLAGS MATCHES "-march" AND NOT CMAKE_CXX_FLAGS MATCHES "-arch" AND NOT CMAKE_OSX_ARCHITECTURES)
113115
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${TARGET_ARCH}")

test/check_arch.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@ znver3
8787
znver4
8888
btver1
8989
btver2
90+
z14

0 commit comments

Comments
 (0)