1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-14 22:07:05 +01:00

Emulated integer vector type for QPX and generic SIMD instruction sets.

This commit is contained in:
Lanny91
2017-02-22 12:01:36 +00:00
parent cc773ae70c
commit 0796696733
4 changed files with 219 additions and 93 deletions

View File

@ -5,8 +5,10 @@
Source file: ./lib/simd/Grid_qpx.h
Copyright (C) 2016
Copyright (C) 2017
Author: Antonin Portelli <antonin.portelli@me.com>
Andrew Lawson <andrew.lawson1991@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -25,6 +27,11 @@
See the full license in the file "LICENSE" in the top level distribution directory
******************************************************************************/
#ifndef GEN_SIMD_WIDTH
#define GEN_SIMD_WIDTH 64u
#endif
#include "Grid_generic_types.h" // Definitions for simulated integer SIMD.
namespace Grid {
namespace Optimization {
typedef struct
@ -62,8 +69,15 @@ namespace Optimization {
return (vector4double){a, a, a, a};
}
//Integer
inline int operator()(Integer a){
return a;
inline veci operator()(Integer a){
veci out;
VECTOR_FOR(i, W<int>::r, 1)
{
out.v[i] = a;
}
return out;
}
};
@ -88,9 +102,10 @@ namespace Optimization {
inline void operator()(vector4double a, double *d){
vec_st(a, 0, d);
}
//Integer
inline void operator()(int a, Integer *i){
i[0] = a;
inline void operator()(veci a, Integer *i){
*((veci *)i) = a;
}
};
@ -142,11 +157,13 @@ namespace Optimization {
return vec_ld(0, a);
}
// Integer
inline int operator()(Integer *a){
return a[0];
}
inline veci operator()(Integer *a){
veci out;
out = *((veci *)a);
return out;
}
};
template <typename Out_type, typename In_type>
@ -200,8 +217,15 @@ namespace Optimization {
FLOAT_WRAP_2(operator(), inline)
//Integer
inline int operator()(int a, int b){
return a + b;
inline veci operator()(veci a, veci b){
veci out;
VECTOR_FOR(i, W<int>::r, 1)
{
out.v[i] = a.v[i] + b.v[i];
}
return out;
}
};
@ -215,8 +239,15 @@ namespace Optimization {
FLOAT_WRAP_2(operator(), inline)
//Integer
inline int operator()(int a, int b){
return a - b;
inline veci operator()(veci a, veci b){
veci out;
VECTOR_FOR(i, W<int>::r, 1)
{
out.v[i] = a.v[i] - b.v[i];
}
return out;
}
};
@ -248,8 +279,15 @@ namespace Optimization {
FLOAT_WRAP_2(operator(), inline)
// Integer
inline int operator()(int a, int b){
return a*b;
inline veci operator()(veci a, veci b){
veci out;
VECTOR_FOR(i, W<int>::r, 1)
{
out.v[i] = a.v[i]*b.v[i];
}
return out;
}
};
@ -263,8 +301,15 @@ namespace Optimization {
FLOAT_WRAP_2(operator(), inline)
// Integer
inline int operator()(int a, int b){
return a/b;
inline veci operator()(veci a, veci b){
veci out;
VECTOR_FOR(i, W<int>::r, 1)
{
out.v[i] = a.v[i]/b.v[i];
}
return out;
}
};
@ -418,7 +463,7 @@ namespace Optimization {
// Here assign types
typedef Optimization::vector4float SIMD_Ftype; // Single precision type
typedef vector4double SIMD_Dtype; // Double precision type
typedef int SIMD_Itype; // Integer type
typedef Optimization::veci SIMD_Itype; // Integer type
// prefetch utilities
inline void v_prefetch0(int size, const char *ptr){};