Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2382 from gentryx/datapar_zip_iterator
add LibFlatArray-based backend for datapar
- Loading branch information
Showing
11 changed files
with
334 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (c) 2016 Hartmut Kaiser | ||
# Copyright (c) 2016 Andreas Schaefer | ||
# | ||
# Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
# Locate LibFlatArray ( http://libgeodecomp.org/libflatarray.html ) | ||
# | ||
find_package(libflatarray NO_MODULE) | ||
if(NOT libflatarray_FOUND) | ||
hpx_error("LibFlatArray was not found while datapar support was requested. Set LIBFLATARRAY_ROOT to the installation path of LibFlatArray") | ||
endif() | ||
|
||
if(libflatarray_FOUND) | ||
include_directories(SYSTEM ${libflatarray_INCLUDE_DIRS}) | ||
|
||
hpx_add_config_define(HPX_HAVE_DATAPAR) | ||
hpx_add_config_define(HPX_HAVE_DATAPAR_LIBFLATARRAY) | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2016 Andreas Schaefer | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#if !defined(HPX_PARALLEL_TRAITS_LIBFLATARRAY_FAKE_ACCESSOR) | ||
#define HPX_PARALLEL_TRAITS_LIBFLATARRAY_FAKE_ACCESSOR | ||
|
||
#include <hpx/config.hpp> | ||
|
||
#if defined(HPX_HAVE_DATAPAR_LIBFLATARRAY) | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
namespace hpx { namespace parallel { namespace traits | ||
{ | ||
/////////////////////////////////////////////////////////////////////////// | ||
struct fake_accessor | ||
{ | ||
public: | ||
static const int DIM_PROD = 1; | ||
typedef char element_type; | ||
}; | ||
}}} | ||
|
||
#endif | ||
#endif | ||
|
116 changes: 116 additions & 0 deletions
116
hpx/parallel/traits/detail/libflatarray/vector_pack_alignment_size.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// Copyright (c) 2016 Hartmut Kaiser | ||
// Copyright (c) 2016 Andreas Schaefer | ||
//// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#if !defined(HPX_PARALLEL_TRAITS_VECTOR_PACK_ALIGNMENT_SIZE_LIBFLATARRAY_SEP_29_2016_0905PM) | ||
#define HPX_PARALLEL_TRAITS_VECTOR_PACK_ALIGNMENT_SIZE_LIBFLATARRAY_SEP_29_2016_0905PM | ||
|
||
#include <hpx/config.hpp> | ||
|
||
#if defined(HPX_HAVE_DATAPAR_LIBFLATARRAY) | ||
#include <hpx/parallel/traits/detail/libflatarray/fake_accessor.hpp> | ||
#include <hpx/util/detail/pack.hpp> | ||
#include <hpx/util/tuple.hpp> | ||
|
||
#include <cstddef> | ||
#include <type_traits> | ||
|
||
#include <libflatarray/flat_array.hpp> | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
namespace hpx { namespace parallel { namespace traits | ||
{ | ||
/////////////////////////////////////////////////////////////////////////// | ||
template <typename T, std::size_t N> | ||
struct is_vector_pack<LibFlatArray::short_vec<T, N> > | ||
: std::true_type | ||
{}; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
template <typename T, std::size_t N> | ||
struct is_scalar_vector_pack<LibFlatArray::short_vec<T, N> > | ||
: std::false_type | ||
{}; | ||
|
||
template <typename T> | ||
struct is_scalar_vector_pack<LibFlatArray::short_vec<T, 1> > | ||
: std::true_type | ||
{}; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
template <typename T, std::size_t N> | ||
struct is_non_scalar_vector_pack<LibFlatArray::short_vec<T, N> > | ||
: std::true_type | ||
{}; | ||
|
||
template <typename T> | ||
struct is_non_scalar_vector_pack<LibFlatArray::short_vec<T, 1> > | ||
: std::false_type | ||
{}; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
template <typename T, typename Enable> | ||
struct vector_pack_alignment | ||
{ | ||
typedef typename LibFlatArray::estimate_optimum_short_vec_type<T, fake_accessor>::VALUE shortvec; | ||
typedef typename shortvec::strategy strategy; | ||
typedef typename strategy::alignment foo; | ||
|
||
static std::size_t const value = foo::ALIGNMENT; | ||
}; | ||
|
||
template <typename T, std::size_t N> | ||
struct vector_pack_alignment<LibFlatArray::short_vec<T, N> > | ||
{ | ||
typedef typename LibFlatArray::short_vec<T, N> shortvec; | ||
|
||
static std::size_t const value = shortvec::strategy::alignment::ALIGNMENT; | ||
}; | ||
|
||
template <typename ... Vector> | ||
struct vector_pack_alignment<hpx::util::tuple<Vector...>, | ||
typename std::enable_if< | ||
hpx::util::detail::all_of<is_vector_pack<Vector>...>::value | ||
>::type> | ||
{ | ||
typedef typename hpx::util::tuple_element< | ||
0, hpx::util::tuple<Vector...> | ||
>::type pack_type; | ||
|
||
static std::size_t const value = pack_type::alignment; | ||
}; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
template <typename T, typename Enable> | ||
struct vector_pack_size | ||
{ | ||
typedef typename LibFlatArray::estimate_optimum_short_vec_type<T, fake_accessor>::VALUE shortvec; | ||
|
||
static std::size_t const value = shortvec::ARITY; | ||
}; | ||
|
||
template <typename T, std::size_t N> | ||
struct vector_pack_size<LibFlatArray::short_vec<T, N> > | ||
{ | ||
static std::size_t const value = LibFlatArray::short_vec<T, N>::ARITY; | ||
}; | ||
|
||
template <typename ... Vector> | ||
struct vector_pack_size<hpx::util::tuple<Vector...>, | ||
typename std::enable_if< | ||
hpx::util::detail::all_of<is_vector_pack<Vector>...>::value | ||
>::type> | ||
{ | ||
typedef typename hpx::util::tuple_element< | ||
0, hpx::util::tuple<Vector...> | ||
>::type pack_type; | ||
|
||
static std::size_t const value = pack_type::alignment; | ||
}; | ||
}}} | ||
|
||
#endif | ||
#endif | ||
|
30 changes: 30 additions & 0 deletions
30
hpx/parallel/traits/detail/libflatarray/vector_pack_count_bits.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) 2007-2016 Hartmut Kaiser | ||
// Copyright (c) 2016 Andreas Schaefer | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#if !defined(HPX_PARALLEL_DATAPAR_LIBFLATARRAY_COUNT_BITS_SEP_22_2016_0220PM) | ||
#define HPX_PARALLEL_DATAPAR_LIBFLATARRAY_COUNT_BITS_SEP_22_2016_0220PM | ||
|
||
#include <hpx/config.hpp> | ||
|
||
#if defined(HPX_HAVE_DATAPAR_LIBFLATARRAY) | ||
#include <cstddef> | ||
|
||
#include <libflatarray/flat_array.hpp> | ||
|
||
namespace hpx { namespace parallel { namespace traits | ||
{ | ||
/////////////////////////////////////////////////////////////////////////// | ||
template <typename T, std::size_t N> | ||
HPX_HOST_DEVICE HPX_FORCEINLINE std::size_t | ||
count_bits(LibFlatArray::short_vec<T, N>::mask_type const& mask) | ||
{ | ||
return LibFlatArray::count_mask<T, N>(mask); | ||
} | ||
}}} | ||
|
||
#endif | ||
#endif | ||
|
91 changes: 91 additions & 0 deletions
91
hpx/parallel/traits/detail/libflatarray/vector_pack_load_store.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright (c) 2016 Hartmut Kaiser | ||
// Copyright (c) 2016 Andreas Schaefer | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#if !defined(HPX_PARALLEL_TRAITS_VECTOR_PACK_LOAD_STORE_LIBFLATARRAY) | ||
#define HPX_PARALLEL_TRAITS_VECTOR_PACK_LOAD_STORE_LIBFLATARRAY | ||
|
||
#include <hpx/parallel/traits/detail/libflatarray/fake_accessor.hpp> | ||
|
||
#if defined(HPX_HAVE_DATAPAR_LIBFLATARRAY) | ||
#include <hpx/util/tuple.hpp> | ||
#include <hpx/util/tuple.hpp> | ||
|
||
#include <cstddef> | ||
#include <iterator> | ||
#include <memory> | ||
|
||
#include <libflatarray/flat_array.hpp> | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
namespace hpx { namespace parallel { namespace traits | ||
{ | ||
/////////////////////////////////////////////////////////////////////////// | ||
template <typename T, typename NewT> | ||
struct rebind_pack | ||
{ | ||
typedef typename LibFlatArray::estimate_optimum_short_vec_type<T, fake_accessor>::VALUE type; | ||
}; | ||
|
||
template <typename T, std::size_t N, typename NewT> | ||
struct rebind_pack<LibFlatArray::short_vec<T, N>, NewT> | ||
{ | ||
typedef typename LibFlatArray::estimate_optimum_short_vec_type<NewT, fake_accessor>::VALUE type; | ||
}; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
template <typename V, typename Enable> | ||
struct vector_pack_load | ||
{ | ||
template <typename Iter> | ||
static typename rebind_pack< | ||
V, typename std::iterator_traits<Iter>::value_type | ||
>::type | ||
aligned(Iter const& iter) | ||
{ | ||
typedef typename rebind_pack< | ||
V, typename std::iterator_traits<Iter>::value_type | ||
>::type vector_pack_type; | ||
|
||
return vector_pack_type( | ||
std::addressof(*iter)); | ||
} | ||
|
||
template <typename Iter> | ||
static typename rebind_pack< | ||
V, typename std::iterator_traits<Iter>::value_type | ||
>::type | ||
unaligned(Iter const& iter) | ||
{ | ||
typedef typename rebind_pack< | ||
V, typename std::iterator_traits<Iter>::value_type | ||
>::type vector_pack_type; | ||
|
||
vector_pack_type v; | ||
v.load_aligned(std::addressof(*iter)); | ||
return v; | ||
} | ||
}; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
template <typename V, typename Enable> | ||
struct vector_pack_store | ||
{ | ||
template <typename Iter_> | ||
static void aligned(V const& value, Iter_ const& iter) | ||
{ | ||
value.store(std::addressof(*iter)); | ||
} | ||
|
||
template <typename Iter_> | ||
static void unaligned(V const& value, Iter_ const& iter) | ||
{ | ||
value.store_aligned(std::addressof(*iter)); | ||
} | ||
}; | ||
}}} | ||
|
||
#endif | ||
#endif |
40 changes: 40 additions & 0 deletions
40
hpx/parallel/traits/detail/libflatarray/vector_pack_type.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2016 Hartmut Kaiser | ||
// Copyright (c) 2016 Andreas Schaefer | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#if !defined(HPX_PARALLEL_TRAITS_VECTOR_PACK_TYPE_LIBFLATARRAY) | ||
#define HPX_PARALLEL_TRAITS_VECTOR_PACK_TYPE_LIBFLATARRAY | ||
|
||
#include <hpx/config.hpp> | ||
|
||
#if defined(HPX_HAVE_DATAPAR_LIBFLATARRAY) | ||
#include <hpx/util/tuple.hpp> | ||
#include <hpx/parallel/traits/detail/libflatarray/fake_accessor.hpp> | ||
|
||
#include <cstddef> | ||
|
||
#include <libflatarray/flat_array.hpp> | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
namespace hpx { namespace parallel { namespace traits | ||
{ | ||
template <typename T, | ||
std::size_t N = LibFlatArray::estimate_optimum_short_vec_type<T, fake_accessor>::VALUE::ARITY, | ||
typename Abi = void> | ||
struct vector_pack_type | ||
{ | ||
typedef LibFlatArray::short_vec<T, N> type; | ||
}; | ||
|
||
template <typename ... T, std::size_t N> | ||
struct vector_pack_type<hpx::util::tuple<T...>, N, void> | ||
{ | ||
typedef hpx::util::tuple<LibFlatArray::short_vec<T, N>...> type; | ||
}; | ||
}}} | ||
|
||
#endif | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters