29 return std::min(
sizeof(
void*),
sizeof(
typename Vec::EntryType)) - 1;
40 unsigned long mask = alignmentMask<Vec>();
41 for (i = 0; i < 10; ++i) {
42 VERIFY((reinterpret_cast<size_t>(&a[i]) & mask) == 0) <<
"a = " << a <<
", mask = " << mask;
44 const char *data =
reinterpret_cast<const char *
>(&a[0]);
45 for (i = 0; i < 10; ++i) {
46 VERIFY(&data[i * Vec::Size *
sizeof(
typename Vec::EntryType)] == reinterpret_cast<const char *>(&a[i]));
54 typedef typename Vec::EntryType
T;
59 unsigned long mask = alignmentMask<Vec>();
60 for (
int i = 0; i < 10; ++i) {
61 VERIFY((reinterpret_cast<size_t>(&b[i * Vec::Size]) & mask) == 0) <<
"b = " << b <<
", mask = " << mask;
67 typedef typename Vec::EntryType
T;
68 typedef typename Vec::IndexType
I;
70 enum loadArrayEnum { count = 256 * 1024 /
sizeof(
T) };
72 for (
int i = 0; i < count; ++i) {
78 const Vec offsets(indexesFromZero);
79 for (
int i = 0; i < count; i +=
Vec::Size) {
80 const T *
const addr = &array[i];
99 typedef typename Vec::EntryType
T;
108 const T *
const addr = &array[i];
123 typedef typename Vec::EntryType
T;
128 data[i] = data[i - 1];
133 for (
int i = 0; i < streamingLoadCount -
Vec::Size; ++i, ++ref) {
135 if (0 == i % Vec::Size) {
147 template<
typename T>
struct TypeInfo;
148 template<>
struct TypeInfo<
double > {
static const char *string() {
return "double"; } };
149 template<>
struct TypeInfo<float > {
static const char *string() {
return "float"; } };
150 template<>
struct TypeInfo<int > {
static const char *string() {
return "int"; } };
151 template<>
struct TypeInfo<unsigned int > {
static const char *string() {
return "uint"; } };
152 template<>
struct TypeInfo<short > {
static const char *string() {
return "short"; } };
153 template<>
struct TypeInfo<unsigned short> {
static const char *string() {
return "ushort"; } };
154 template<>
struct TypeInfo<signed char > {
static const char *string() {
return "schar"; } };
155 template<>
struct TypeInfo<unsigned char > {
static const char *string() {
return "uchar"; } };
156 template<>
struct TypeInfo<
double_v > {
static const char *string() {
return "double_v"; } };
157 template<>
struct TypeInfo<
float_v > {
static const char *string() {
return "float_v"; } };
158 template<>
struct TypeInfo<
sfloat_v > {
static const char *string() {
return "sfloat_v"; } };
159 template<>
struct TypeInfo<
int_v > {
static const char *string() {
return "int_v"; } };
160 template<>
struct TypeInfo<
uint_v > {
static const char *string() {
return "uint_v"; } };
161 template<>
struct TypeInfo<
short_v > {
static const char *string() {
return "short_v"; } };
162 template<>
struct TypeInfo<
ushort_v > {
static const char *string() {
return "ushort_v"; } };
164 template<
typename T,
typename Current =
void>
struct SupportedConversions {
typedef void Next; };
165 template<>
struct SupportedConversions<float,
void> {
typedef double Next; };
166 template<>
struct SupportedConversions<float,
double> {
typedef int Next; };
167 template<>
struct SupportedConversions<float, int> {
typedef unsigned int Next; };
168 template<>
struct SupportedConversions<float, unsigned int> {
typedef short Next; };
169 template<>
struct SupportedConversions<float, short> {
typedef unsigned short Next; };
170 template<>
struct SupportedConversions<float, unsigned short> {
typedef signed char Next; };
171 template<>
struct SupportedConversions<float, signed char> {
typedef unsigned char Next; };
172 template<>
struct SupportedConversions<float, unsigned char> {
typedef void Next; };
173 template<>
struct SupportedConversions<int ,
void > {
typedef unsigned int Next; };
174 template<>
struct SupportedConversions<int , unsigned int > {
typedef short Next; };
175 template<>
struct SupportedConversions<int , short > {
typedef unsigned short Next; };
176 template<>
struct SupportedConversions<int , unsigned short> {
typedef signed char Next; };
177 template<>
struct SupportedConversions<int , signed char > {
typedef unsigned char Next; };
178 template<>
struct SupportedConversions<int , unsigned char > {
typedef void Next; };
179 template<>
struct SupportedConversions<unsigned int,
void > {
typedef unsigned short Next; };
180 template<>
struct SupportedConversions<unsigned int, unsigned short> {
typedef unsigned char Next; };
181 template<>
struct SupportedConversions<unsigned int, unsigned char > {
typedef void Next; };
182 template<>
struct SupportedConversions<unsigned short,
void > {
typedef unsigned char Next; };
183 template<>
struct SupportedConversions<unsigned short, unsigned char > {
typedef void Next; };
184 template<>
struct SupportedConversions< short,
void > {
typedef unsigned char Next; };
185 template<>
struct SupportedConversions< short, unsigned char > {
typedef signed char Next; };
186 template<>
struct SupportedConversions< short, signed char > {
typedef void Next; };
188 template<
typename Vec,
typename MemT>
struct LoadCvt {
190 typedef typename Vec::EntryType VecT;
191 MemT *data = Vc::malloc<MemT, Vc::AlignOnCacheline>(128);
192 for (
size_t i = 0; i < 128; ++i) {
193 data[i] =
static_cast<MemT
>(i - 64);
196 for (
size_t i = 0; i < 128 - Vec::Size + 1; ++i) {
198 if (i % (2 * Vec::Size) == 0) {
200 }
else if (i % Vec::Size == 0) {
206 COMPARE(v[j], static_cast<VecT>(data[i + j])) <<
" " << TypeInfo<MemT>::string();
209 for (
size_t i = 0; i < 128 - Vec::Size + 1; ++i) {
211 if (i % (2 * Vec::Size) == 0) {
213 }
else if (i % Vec::Size == 0) {
219 COMPARE(v[j], static_cast<VecT>(data[i + j])) <<
" " << TypeInfo<MemT>::string();
222 for (
size_t i = 0; i < 128 - Vec::Size + 1; ++i) {
224 if (i % (2 * Vec::Size) == 0) {
226 }
else if (i % Vec::Size == 0) {
232 COMPARE(v[j], static_cast<VecT>(data[i + j])) <<
" " << TypeInfo<MemT>::string();
236 ADD_PASS() <<
"loadCvt: load " << TypeInfo<MemT>::string() <<
"* as " << TypeInfo<Vec>::string();
237 LoadCvt<Vec, typename SupportedConversions<VecT, MemT>::Next>::test();
240 template<
typename Vec>
struct LoadCvt<Vec,
void> {
static void test() {} };
244 typedef typename Vec::EntryType
T;
245 LoadCvt<Vec, typename SupportedConversions<T>::Next>::test();
250 runTest(checkAlignment<int_v>);
251 runTest(checkAlignment<uint_v>);
252 runTest(checkAlignment<float_v>);
253 runTest(checkAlignment<double_v>);
254 runTest(checkAlignment<short_v>);
255 runTest(checkAlignment<ushort_v>);
256 runTest(checkAlignment<sfloat_v>);
263 runTest(loadArrayShort<short_v>);
264 runTest(loadArrayShort<ushort_v>);
VECTOR_NAMESPACE::uint_v uint_v
VECTOR_NAMESPACE::sfloat_v sfloat_v
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
VECTOR_NAMESPACE::short_v short_v
VECTOR_NAMESPACE::ushort_v ushort_v
#define testAllTypes(name)
VECTOR_NAMESPACE::int_v int_v
VECTOR_NAMESPACE::double_v double_v
A helper class for fixed-size two-dimensional arrays.
void checkMemoryAlignment()
VECTOR_NAMESPACE::float_v float_v
Vc_ALWAYS_INLINE Vc_PURE VectorPointerHelper< V, AlignedFlag > firstVector()
typedef void((*Func_t)())
void * hack_to_put_b_on_the_stack
unsigned long alignmentMask()