Permalink
Browse files

updated LibFlatArray

  • Loading branch information...
gentryx committed Jun 27, 2018
1 parent 11ecd46 commit a82ad7e7381a366a6c1216a32654635a09cecaf6
Showing with 787 additions and 261 deletions.
  1. +5 −0 lib/libflatarray/CMakeLists.txt
  2. +54 −13 lib/libflatarray/examples/performance_tests/main.cpp
  3. +3 −2 lib/libflatarray/include/libflatarray/aligned_allocator.hpp
  4. +11 −0 lib/libflatarray/include/libflatarray/api_traits.hpp
  5. +1 −1 lib/libflatarray/include/libflatarray/detail/dual_callback_helper.hpp
  6. +9 −0 lib/libflatarray/include/libflatarray/detail/load_functor.hpp
  7. +15 −0 lib/libflatarray/include/libflatarray/detail/macros.hpp
  8. +11 −1 lib/libflatarray/include/libflatarray/detail/offset.hpp
  9. +9 −0 lib/libflatarray/include/libflatarray/detail/save_functor.hpp
  10. +11 −0 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_double_1.hpp
  11. +49 −29 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_double_16.hpp
  12. +11 −0 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_double_2.hpp
  13. +49 −29 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_double_32.hpp
  14. +10 −0 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_double_4.hpp
  15. +10 −0 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_double_8.hpp
  16. +10 −0 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_float_1.hpp
  17. +49 −29 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_float_16.hpp
  18. +11 −0 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_float_2.hpp
  19. +49 −29 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_float_32.hpp
  20. +10 −0 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_float_4.hpp
  21. +13 −1 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_float_8.hpp
  22. +11 −0 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_int_1.hpp
  23. +18 −6 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_int_16.hpp
  24. +11 −0 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_int_2.hpp
  25. +41 −21 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_int_32.hpp
  26. +10 −0 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_int_4.hpp
  27. +41 −21 lib/libflatarray/include/libflatarray/detail/short_vec_scalar_int_8.hpp
  28. +11 −2 lib/libflatarray/include/libflatarray/detail/soa_array_member_copy_helper.hpp
  29. +36 −0 lib/libflatarray/include/libflatarray/loop_peeler.hpp
  30. +25 −2 lib/libflatarray/include/libflatarray/macros.hpp
  31. +13 −14 lib/libflatarray/include/libflatarray/short_vec.hpp
  32. +3 −2 lib/libflatarray/include/libflatarray/soa_array.hpp
  33. +23 −0 lib/libflatarray/include/libflatarray/soa_grid.hpp
  34. +2 −2 lib/libflatarray/include/libflatarray/soa_vector.hpp
  35. +8 −3 lib/libflatarray/include/libflatarray/streaming_short_vec.hpp
  36. +3 −4 lib/libflatarray/include/libflatarray/testbed/benchmark.hpp
  37. +7 −7 lib/libflatarray/include/libflatarray/testbed/cpu_benchmark.hpp
  38. +13 −4 lib/libflatarray/include/libflatarray/testbed/evaluate.hpp
  39. +1 −0 lib/libflatarray/test/estimate_optimum_short_vec_type_test.cpp
  40. +2 −0 lib/libflatarray/test/loop_peeler_test.cpp
  41. +0 −1 lib/libflatarray/test/short_vec_additional_test.cpp
  42. +13 −11 lib/libflatarray/test/short_vec_test.cpp
  43. +8 −4 lib/libflatarray/test/soa_grid_test.cpp
  44. +80 −20 lib/libflatarray/test/streaming_short_vec_test.cpp
  45. +7 −3 lib/libflatarray/test/test.hpp
@@ -120,11 +120,16 @@ lfa_add_config_option(WITH_CPP14 "Enable C++ 14 features of LibFlatArray" ${SUPP
lfa_add_config_option(WITH_FORCED_CPP11 "Some C++11-compatible compilers support sufficient features of C++14 to allow LibFlatArray to enable C++14 mode. Use this setting in conjunction with WITH_CPP14" false true)
lfa_add_config_option(WITH_INCREASED_PRECISION "Some architectures (*cough*ARM*cough*) yield poor accuracy when using fast estimates. This option enforces mitigates that flaw at the expense of a few extra cycles." false true)
lfa_add_config_option(WITH_SILO "Enable code examples that require LLNL's Silo library." ${Silo_FOUND} true)
lfa_add_config_option(WITH_AVX_FORCED_OFF "Explicitly disable AVX via compiler flags. Currently only useful for weirdly set up nodes on Travis. " false false)
if(WITH_CUDA AND NOT CUDA_FOUND)
message(FATAL_ERROR "WITH_CUDA selected, but could not find the NVIDIA CUDA toolkit.")
endif()
if(WITH_AVX_FORCED_OFF)
set(LFA_ADDITIONAL_COMPILE_FLAGS "${LFA_ADDITIONAL_COMPILE_FLAGS} -mno-avx")
endif()
if(NOT MSVC)
if(WITH_CPP14)
# At the moment, CUDA doesn't support C++14, so we limt ourselves to
@@ -1,32 +1,24 @@
/**
* Copyright 2014-2017 Andreas Schäfer
* Copyright 2018 Google
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <libflatarray/flat_array.hpp>
#include <libflatarray/short_vec.hpp>
#include <libflatarray/testbed/cpu_benchmark.hpp>
#include <libflatarray/testbed/evaluate.hpp>
// globally disable some warnings with MSVC, that are issued not for a
// specific header, but rather for the interaction of system headers
// and LibFlatArray source. Also disable overly eager sign conversion
// and overflow warnings:
#ifdef _MSC_BUILD
#pragma warning( disable : 4244 4305 4307 4365 4456 4514 4710 )
#endif
namespace LibFlatArray {}
// disable certain warnings from system headers when compiling with
// Microsoft Visual Studio:
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4514 )
#pragma warning( disable : 4514 4710 )
#endif
#include <iostream>
#include <list>
#include <sstream>
#ifdef __SSE__
#include <xmmintrin.h>
#endif
@@ -39,6 +31,19 @@
#pragma warning( pop )
#endif
#include <libflatarray/flat_array.hpp>
#include <libflatarray/short_vec.hpp>
#include <libflatarray/testbed/cpu_benchmark.hpp>
#include <libflatarray/testbed/evaluate.hpp>
// globally disable some warnings with MSVC, that are issued not for a
// specific header, but rather for the interaction of system headers
// and LibFlatArray source. Also disable overly eager sign conversion
// and overflow warnings:
#ifdef _MSC_BUILD
#pragma warning( disable : 4244 4305 4307 4365 4456 4514 )
#endif
#define WEIGHT_S 0.11
#define WEIGHT_T 0.12
#define WEIGHT_W 0.13
@@ -709,6 +714,12 @@ class JacobiD3Q7Gold : public JacobiD3Q7
dim_z(dim_z)
{}
// not inlining is ok:
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4710 )
#endif
template<typename accessor_type1, typename accessor_type2>
void operator()(accessor_type1& accessor_old,
accessor_type2& accessor_new) const
@@ -783,6 +794,11 @@ class JacobiD3Q7Gold : public JacobiD3Q7
#endif
}
#ifdef _MSC_BUILD
#pragma warning( pop )
#endif
private:
long dim_x;
long dim_y;
@@ -885,6 +901,12 @@ class Particle
float charge;
};
// not inlining is ok:
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4710 )
#endif
LIBFLATARRAY_REGISTER_SOA(Particle,
((float)(posX))
((float)(posY))
@@ -894,6 +916,11 @@ LIBFLATARRAY_REGISTER_SOA(Particle,
((float)(velZ))
((float)(charge)))
#ifdef _MSC_BUILD
#pragma warning( pop )
#endif
class ArrayParticle
{
public:
@@ -2336,6 +2363,12 @@ class ConditionalUpdater
counter(counter)
{}
// not inlining is ok:
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4710 )
#endif
template<typename ACCESSOR>
void operator()(ACCESSOR& particle) {
for (int t = 0; t < repeats; ++t) {
@@ -2346,6 +2379,10 @@ class ConditionalUpdater
}
}
#ifdef _MSC_BUILD
#pragma warning( pop )
#endif
template<typename Float, typename ACCESSOR>
void update(long& /* unused_counter */, long end, ACCESSOR& i)
{
@@ -2580,3 +2617,7 @@ int main(int argc, char **argv)
return 0;
}
#ifdef _MSC_BUILD
#pragma warning( disable : 4710 )
#endif
@@ -1,6 +1,7 @@
/**
* Copyright 2012-2017 Andreas Schäfer
* Copyright 2015 Kurt Kanzenbach
* Copyright 2018 Google
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -13,7 +14,7 @@
// Microsoft Visual Studio:
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4514 )
#pragma warning( disable : 4514 4710 )
#endif
#include <memory>
@@ -125,7 +126,7 @@ class aligned_allocator
return !(*this == other);
}
bool operator==(const aligned_allocator& other) const
bool operator==(const aligned_allocator& /* other*/) const
{
return true;
}
@@ -55,6 +55,11 @@ class api_traits
* might allocate excessive amounts of memory.
*/
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4710 )
#endif
/**
* Means that the code will be used with 1D grids only -- makes
* sense mostly for use with unstructured grids.
@@ -251,6 +256,10 @@ class api_traits
}
};
#ifdef _MSC_BUILD
#pragma warning( pop )
#endif
/**
* select_asymmetric_dual_callback:
*
@@ -261,6 +270,8 @@ class api_traits
* (makes sense if you need to do some sorts of reductions or run
* a multi-grid code).
*
* The default is to assume no asymmetric callback.
*
* WARNING: if soa_accessor is instantiated for n sizes, then
* has_asymmetric_dual_callback will increase this to n * n.
*/
@@ -92,7 +92,7 @@ class dual_callback_helper_symmetric
// an assignment operator missing -- which is clearly there:
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4626 )
#pragma warning( disable : 4626 4710 )
#endif
template<typename GRID_TYPE, typename FUNCTOR>
@@ -17,6 +17,11 @@ namespace detail {
namespace flat_array {
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4626 4710 5027 )
#endif
/**
* The purpose of this functor is to load a row of cells which are
* already prepackaged (in SoA form) in a raw data segment (i.e. all
@@ -65,6 +70,10 @@ class load_functor
std::size_t count;
};
#ifdef _MSC_BUILD
#pragma warning( pop )
#endif
#ifdef LIBFLATARRAY_WITH_CUDA
#ifdef __CUDACC__
@@ -1,5 +1,6 @@
/**
* Copyright 2014-2016 Andreas Schäfer
* Copyright 2018 Google
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -12,6 +13,20 @@
#include <libflatarray/detail/soa_array_member_copy_helper.hpp>
#include <libflatarray/preprocessor.hpp>
#ifdef __CUDACC__
# define LIBFLATARRAY_INLINE inline
#else
# ifdef _MSC_BUILD
# define LIBFLATARRAY_INLINE __forceinline
# else
# ifdef __GNUC__
# define LIBFLATARRAY_INLINE inline __attribute__ ((__always_inline__))
# else
# define LIBFLATARRAY_INLINE inline
# endif
# endif
#endif
#define LIBFLATARRAY_INDEX(X, Y, Z, DIM_X, DIM_Y, DIM_Z, INDEX) \
(INDEX + Z * (DIM_X * DIM_Y) + Y * DIM_X + X)
@@ -1,5 +1,6 @@
/**
* Copyright 2014-2017 Andreas Schäfer
* Copyright 2018 Google
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -12,7 +13,7 @@
// Microsoft Visual Studio:
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4514 )
#pragma warning( disable : 4514 4548 4626 4710 4711 4820 4996 5027 )
#endif
#include <stdexcept>
@@ -21,6 +22,11 @@
#pragma warning( pop )
#endif
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4710 4711 )
#endif
namespace LibFlatArray {
namespace detail {
@@ -49,4 +55,8 @@ class offset<CELL, 0>
}
#ifdef _MSC_BUILD
#pragma warning( pop )
#endif
#endif
@@ -15,6 +15,11 @@ namespace detail {
namespace flat_array {
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4626 4710 5027 )
#endif
/**
* Same as load_functor, but the other way around.
*/
@@ -60,6 +65,10 @@ class save_functor
std::size_t count;
};
#ifdef _MSC_BUILD
#pragma warning( pop )
#endif
#ifdef LIBFLATARRAY_WITH_CUDA
#ifdef __CUDACC__
@@ -252,7 +252,14 @@ short_vec<double, 1> sqrt(const short_vec<double, 1>& vec)
return vec.sqrt();
}
// not inlining is ok, as is inlining:
#ifdef _MSC_BUILD
#pragma warning( push )
#pragma warning( disable : 4710 4711 )
#endif
template<typename _CharT, typename _Traits>
inline
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const short_vec<double, 1>& vec)
@@ -261,6 +268,10 @@ operator<<(std::basic_ostream<_CharT, _Traits>& __os,
return __os;
}
#ifdef _MSC_BUILD
#pragma warning( pop )
#endif
}
#ifdef _MSC_BUILD
Oops, something went wrong.

0 comments on commit a82ad7e

Please sign in to comment.