1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

NAMESPACE and formatting

This commit is contained in:
paboyle 2018-01-12 18:11:04 +00:00
parent bbb657da5c
commit 6ab744c720

View File

@ -1,4 +1,4 @@
/************************************************************************************* /*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
@ -24,8 +24,8 @@ Author: Antonin Portelli <antonin.portelli@me.com>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/ *************************************************************************************/
/* END LEGAL */ /* END LEGAL */
static_assert(GEN_SIMD_WIDTH % 16u == 0, "SIMD vector size is not an integer multiple of 16 bytes"); static_assert(GEN_SIMD_WIDTH % 16u == 0, "SIMD vector size is not an integer multiple of 16 bytes");
@ -34,52 +34,53 @@ static_assert(GEN_SIMD_WIDTH % 16u == 0, "SIMD vector size is not an integer mul
// playing with compiler pragmas // playing with compiler pragmas
#ifdef VECTOR_LOOPS #ifdef VECTOR_LOOPS
#ifdef __clang__ #ifdef __clang__
#define VECTOR_FOR(i, w, inc)\ #define VECTOR_FOR(i, w, inc) \
_Pragma("clang loop unroll(full) vectorize(enable) interleave(enable) vectorize_width(w)")\ _Pragma("clang loop unroll(full) vectorize(enable) interleave(enable) vectorize_width(w)") \
for (unsigned int i = 0; i < w; i += inc) for (unsigned int i = 0; i < w; i += inc)
#elif defined __INTEL_COMPILER #elif defined __INTEL_COMPILER
#define VECTOR_FOR(i, w, inc)\ #define VECTOR_FOR(i, w, inc) \
_Pragma("simd vectorlength(w*8)")\ _Pragma("simd vectorlength(w*8)") \
for (unsigned int i = 0; i < w; i += inc) for (unsigned int i = 0; i < w; i += inc)
#else #else
#define VECTOR_FOR(i, w, inc)\ #define VECTOR_FOR(i, w, inc) \
for (unsigned int i = 0; i < w; i += inc) for (unsigned int i = 0; i < w; i += inc)
#endif #endif
#else #else
#define VECTOR_FOR(i, w, inc)\ #define VECTOR_FOR(i, w, inc) \
for (unsigned int i = 0; i < w; i += inc) for (unsigned int i = 0; i < w; i += inc)
#endif #endif
namespace Grid { NAMESPACE_BEGIN(Grid);
namespace Optimization { NAMESPACE_BEGIN(Optimization);
// type traits giving the number of elements for each vector type // type traits giving the number of elements for each vector type
template <typename T> struct W; template <typename T> struct W;
template <> struct W<double> { template <> struct W<double> {
constexpr static unsigned int c = GEN_SIMD_WIDTH/16u; constexpr static unsigned int c = GEN_SIMD_WIDTH/16u;
constexpr static unsigned int r = GEN_SIMD_WIDTH/8u; constexpr static unsigned int r = GEN_SIMD_WIDTH/8u;
}; };
template <> struct W<float> { template <> struct W<float> {
constexpr static unsigned int c = GEN_SIMD_WIDTH/8u; constexpr static unsigned int c = GEN_SIMD_WIDTH/8u;
constexpr static unsigned int r = GEN_SIMD_WIDTH/4u; constexpr static unsigned int r = GEN_SIMD_WIDTH/4u;
}; };
template <> struct W<Integer> { template <> struct W<Integer> {
constexpr static unsigned int r = GEN_SIMD_WIDTH/4u; constexpr static unsigned int r = GEN_SIMD_WIDTH/4u;
}; };
template <> struct W<uint16_t> { template <> struct W<uint16_t> {
constexpr static unsigned int c = GEN_SIMD_WIDTH/4u; constexpr static unsigned int c = GEN_SIMD_WIDTH/4u;
constexpr static unsigned int r = GEN_SIMD_WIDTH/2u; constexpr static unsigned int r = GEN_SIMD_WIDTH/2u;
}; };
// SIMD vector types // SIMD vector types
template <typename T> template <typename T>
struct vec { struct vec {
alignas(GEN_SIMD_WIDTH) T v[W<T>::r]; alignas(GEN_SIMD_WIDTH) T v[W<T>::r];
}; };
typedef vec<float> vecf; typedef vec<float> vecf;
typedef vec<double> vecd; typedef vec<double> vecd;
typedef vec<uint16_t> vech; // half precision comms typedef vec<uint16_t> vech; // half precision comms
typedef vec<Integer> veci; typedef vec<Integer> veci;
}} NAMESPACE_END(Optimization);
NAMESPACE_END(Grid);