Hermes
0.7.0
Linux game streaming host
Toggle main menu visibility
Loading...
Searching...
No Matches
rswrapper.c
Go to the documentation of this file.
1
5
6
// _FORTIY_SOURCE can cause some versions of GCC to try to inline
7
// memset() with incompatible target options when compiling rs.c
8
#ifdef _FORTIFY_SOURCE
9
#undef _FORTIFY_SOURCE
10
#endif
11
12
#define DECORATE_FUNC_I(a, b) a##b
13
#define DECORATE_FUNC(a, b) DECORATE_FUNC_I(a, b)
14
15
// Append an ISA suffix to the public RS API
16
#define reed_solomon_init DECORATE_FUNC(reed_solomon_init, ISA_SUFFIX)
17
#define reed_solomon_new DECORATE_FUNC(reed_solomon_new, ISA_SUFFIX)
18
#define reed_solomon_new_static DECORATE_FUNC(reed_solomon_new_static, ISA_SUFFIX)
19
#define reed_solomon_release DECORATE_FUNC(reed_solomon_release, ISA_SUFFIX)
20
#define reed_solomon_decode DECORATE_FUNC(reed_solomon_decode, ISA_SUFFIX)
21
#define reed_solomon_encode DECORATE_FUNC(reed_solomon_encode, ISA_SUFFIX)
22
23
// Append an ISA suffix to internal functions to prevent multiple definition errors
24
#define obl_axpy_ref DECORATE_FUNC(obl_axpy_ref, ISA_SUFFIX)
25
#define obl_scal_ref DECORATE_FUNC(obl_scal_ref, ISA_SUFFIX)
26
#define obl_axpyb32_ref DECORATE_FUNC(obl_axpyb32_ref, ISA_SUFFIX)
27
#define obl_axpy DECORATE_FUNC(obl_axpy, ISA_SUFFIX)
28
#define obl_scal DECORATE_FUNC(obl_scal, ISA_SUFFIX)
29
#define obl_swap DECORATE_FUNC(obl_swap, ISA_SUFFIX)
30
#define obl_axpyb32 DECORATE_FUNC(obl_axpyb32, ISA_SUFFIX)
31
#define axpy DECORATE_FUNC(axpy, ISA_SUFFIX)
32
#define scal DECORATE_FUNC(scal, ISA_SUFFIX)
33
#define gemm DECORATE_FUNC(gemm, ISA_SUFFIX)
34
#define invert_mat DECORATE_FUNC(invert_mat, ISA_SUFFIX)
35
36
#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(__amd64__)
37
38
// Compile a variant for SSSE3
39
#if defined(__clang__)
40
#pragma clang attribute push(__attribute__((target("ssse3"))), apply_to = function)
41
#else
42
#pragma GCC push_options
43
#pragma GCC target("ssse3")
44
#endif
45
#define ISA_SUFFIX _ssse3
46
#define OBLAS_SSE3
47
#include "../third-party/nanors/rs.c"
48
#undef OBLAS_SSE3
49
#undef ISA_SUFFIX
50
#if defined(__clang__)
51
#pragma clang attribute pop
52
#else
53
#pragma GCC pop_options
54
#endif
55
56
// Compile a variant for AVX2
57
#if defined(__clang__)
58
#pragma clang attribute push(__attribute__((target("avx2"))), apply_to = function)
59
#else
60
#pragma GCC push_options
61
#pragma GCC target("avx2")
62
#endif
63
#define ISA_SUFFIX _avx2
64
#define OBLAS_AVX2
65
#include "../third-party/nanors/rs.c"
66
#undef OBLAS_AVX2
67
#undef ISA_SUFFIX
68
#if defined(__clang__)
69
#pragma clang attribute pop
70
#else
71
#pragma GCC pop_options
72
#endif
73
74
// Compile a variant for AVX512BW
75
#if defined(__clang__)
76
#pragma clang attribute push(__attribute__((target("avx512f,avx512bw"))), apply_to = function)
77
#else
78
#pragma GCC push_options
79
#pragma GCC target("avx512f,avx512bw")
80
#endif
81
#define ISA_SUFFIX _avx512
82
#define OBLAS_AVX512
83
#include "../third-party/nanors/rs.c"
84
#undef OBLAS_AVX512
85
#undef ISA_SUFFIX
86
#if defined(__clang__)
87
#pragma clang attribute pop
88
#else
89
#pragma GCC pop_options
90
#endif
91
92
#endif
93
94
// Compile a default variant
95
#define ISA_SUFFIX _def
96
#include "../third-party/nanors/deps/obl/autoshim.h"
97
#include "../third-party/nanors/rs.c"
98
#undef ISA_SUFFIX
99
100
#undef reed_solomon_init
101
#undef reed_solomon_new
102
#undef reed_solomon_new_static
103
#undef reed_solomon_release
104
#undef reed_solomon_decode
105
#undef reed_solomon_encode
106
107
#include "
rswrapper.h
"
108
109
reed_solomon_new_t reed_solomon_new_fn;
110
reed_solomon_release_t reed_solomon_release_fn;
111
reed_solomon_encode_t reed_solomon_encode_fn;
112
reed_solomon_decode_t reed_solomon_decode_fn;
113
118
void
reed_solomon_init
(
void
) {
119
#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(__amd64__)
120
if
(__builtin_cpu_supports(
"avx512f"
) && __builtin_cpu_supports(
"avx512bw"
)) {
121
reed_solomon_new_fn = reed_solomon_new_avx512;
122
reed_solomon_release_fn = reed_solomon_release_avx512;
123
reed_solomon_encode_fn = reed_solomon_encode_avx512;
124
reed_solomon_decode_fn = reed_solomon_decode_avx512;
125
reed_solomon_init_avx512();
126
}
else
if
(__builtin_cpu_supports(
"avx2"
)) {
127
reed_solomon_new_fn = reed_solomon_new_avx2;
128
reed_solomon_release_fn = reed_solomon_release_avx2;
129
reed_solomon_encode_fn = reed_solomon_encode_avx2;
130
reed_solomon_decode_fn = reed_solomon_decode_avx2;
131
reed_solomon_init_avx2();
132
}
else
if
(__builtin_cpu_supports(
"ssse3"
)) {
133
reed_solomon_new_fn = reed_solomon_new_ssse3;
134
reed_solomon_release_fn = reed_solomon_release_ssse3;
135
reed_solomon_encode_fn = reed_solomon_encode_ssse3;
136
reed_solomon_decode_fn = reed_solomon_decode_ssse3;
137
reed_solomon_init_ssse3();
138
}
else
139
#endif
140
{
141
reed_solomon_new_fn = reed_solomon_new_def;
142
reed_solomon_release_fn = reed_solomon_release_def;
143
reed_solomon_encode_fn = reed_solomon_encode_def;
144
reed_solomon_decode_fn = reed_solomon_decode_def;
145
reed_solomon_init_def();
146
}
147
}
reed_solomon_init
#define reed_solomon_init
This initializes the RS function pointers to the best vectorized version available.
Definition
rswrapper.c:118
rswrapper.h
Wrappers for nanors vectorization.
src
rswrapper.c
Generated by
1.18.0