ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
vector.h
Go to the documentation of this file.
1#include <stdint.h>
2#include <string.h>
4#define JOIN_(a, b) a##b
5#define JOIN(a, b) JOIN_(a, b)
6#define FN(name) JOIN(name, SIMD_CELL_ISA)
7#if defined(SIMD_CELL_SVE)
8#include <arm_sve.h>
9typedef svint32_t vec_t;
10#define LANES svcntw()
11#define SET(n) svdup_s32(n)
12#define ADD(a, b) svadd_s32_x(pg, a, b)
13#define SUB(a, b) svsub_s32_x(pg, a, b)
14#define MUL(a, b) svmul_s32_x(pg, a, b)
15#define DIV(a, n) svdiv_n_s32_x(pg, a, n)
16#define SHL(a, n) svlsl_n_s32_x(pg, a, n)
17#define SHR(a, n) svasr_n_s32_x(pg, a, n)
18#define AND(a, b) svand_s32_x(pg, a, b)
19#define OR(a, b) svorr_s32_x(pg, a, b)
20#define LT(a, b) svcmplt_s32(pg, a, b)
21#define EQ(a, b) svcmpeq_s32(pg, a, b)
22#define BOTH(a, b) svand_b_z(pg, a, b)
23#define SELECT(mask, a, b) svsel_s32(mask, a, b)
24#define LOAD(p) svld1_s32(pg, (const int32_t *)(p))
25#define STORE(p, v) svst1_s32(pg, (int32_t *)(p), v)
26#define BEGIN_BLOCK \
27 size_t active = count - i < LANES ? count - i : LANES; \
28 svbool_t pg = svwhilelt_b32((uint64_t)i, (uint64_t)count)
29#define HAS_BLOCK (i < count)
30#else
31#if defined(SIMD_CELL_AVX2)
32#include <immintrin.h>
33#define LANES 8
34#else
35#define LANES 4
36#if defined(SIMD_CELL_NEON)
37#include <arm_neon.h>
38#else
39#include <immintrin.h>
40#endif
41#endif
42typedef int32_t vec_t __attribute__((vector_size(LANES * 4)));
43static inline vec_t broadcast(int32_t n) {
44 vec_t v = {0};
45 for (unsigned j = 0; j < LANES; ++j)
46 v[j] = n;
47 return v;
48}
49static inline vec_t load_vec(const void *p) {
50 vec_t v;
51 memcpy(&v, p, sizeof(v));
52 return v;
53}
54static inline void store_vec(void *p, vec_t v) {
55 memcpy(p, &v, sizeof(v));
56}
57#define SET(n) broadcast(n)
58#define ADD(a, b) ((a) + (b))
59#define SUB(a, b) ((a) - (b))
60#define MUL(a, b) ((a) * (b))
61#define DIV(a, n) ((a) / SET(n))
62#define SHL(a, n) ((a) << (n))
63#define SHR(a, n) ((a) >> (n))
64#define AND(a, b) ((a) & (b))
65#define OR(a, b) ((a) | (b))
66#define LT(a, b) ((a) < (b))
67#define EQ(a, b) ((a) == (b))
68#define BOTH(a, b) ((a) & (b))
69#define SELECT(mask, a, b) (((mask) & (a)) | (~(mask) & (b)))
70#define LOAD(p) load_vec(p)
71#define STORE(p, v) store_vec(p, v)
72#define BEGIN_BLOCK size_t active = LANES
73#define HAS_BLOCK (count - i >= LANES)
74#endif
75#define ABS(v) SELECT(LT(v, SET(0)), SUB(SET(0), v), v)
76#define SQUARE(v) MUL(v, v)
int32_t vec_t __attribute__((vector_size(4 *4)))
SESSION_CREATED (PACKET_TYPE_ACIP_SESSION_CREATED) - Session created response.
Definition vector.h:42
🔤 String Manipulation and Shell Escaping Utilities
#define LANES
Definition vector.h:35