compute

#include <hpx/compute/host.hpp>

#include <hpx/compute/traits.hpp>

#include <hpx/compute/vector.hpp>

namespace hpx
namespace compute

Functions

template <typename T, typename Allocator>
void swap(vector<T, Allocator> &x, vector<T, Allocator> &y)

Effects: x.swap(y);.

template <typename T, typename Allocator = std::allocator<T>>
class vector

Public Types

typedef T value_type

Member types (FIXME: add reference to std.

typedef Allocator allocator_type
typedef alloc_traits::access_target access_target
typedef std::size_t size_type
typedef std::ptrdiff_t difference_type
typedef alloc_traits::reference reference
typedef alloc_traits::const_reference const_reference
typedef alloc_traits::pointer pointer
typedef alloc_traits::const_pointer const_pointer
typedef detail::iterator<T, Allocator> iterator
typedef detail::iterator<T const, Allocator> const_iterator
typedef detail::reverse_iterator<T, Allocator> reverse_iterator
typedef detail::const_reverse_iterator<T, Allocator> const_reverse_iterator

Public Functions

vector(Allocator const &alloc = Allocator())
vector(size_type count, T const &value, Allocator const &alloc = Allocator())
vector(size_type count, Allocator const &alloc = Allocator())
template <typename InIter, typename Enable = typename std::enable_if< hpx::traits::is_input_iterator<InIter>::value>::type>
vector(InIter first, InIter last, Allocator const &alloc)
vector(vector const &other)
vector(vector const &other, Allocator const &alloc)
vector(vector &&other)
vector(vector &&other, Allocator const &alloc)
vector(std::initializer_list<T> init, Allocator const &alloc)
~vector()
vector &operator=(vector const &other)
vector &operator=(vector &&other)
allocator_type get_allocator() const

Returns the allocator associated with the container.

HPX_HOST_DEVICE reference hpx::compute::vector::operator[](size_type pos)
HPX_HOST_DEVICE const_reference hpx::compute::vector::operator[](size_type pos) const
pointer data()

Returns pointer to the underlying array serving as element storage. The pointer is such that range [data(); data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).

const_pointer data() const

Returns pointer to the underlying array serving as element storage. The pointer is such that range [data(); data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).

T *device_data() const

Returns a raw pointer corresponding to the address of the data allocated on the device.

std::size_t size() const
std::size_t capacity() const
bool empty() const

Returns: size() == 0.

void resize(size_type size)

Effects: If size <= size(), equivalent to calling pop_back() size() - size times. If size() < size, appends size - size() default-inserted elements to the sequence.

Requires: T shall be MoveInsertable and DefaultInsertable into *this.

Remarks: If an exception is thrown other than by the move constructor of a non-CopyInsertable T there are no effects.

void resize(size_type size, T const &val)

Effects: If size <= size(), equivalent to calling pop_back() size() - size times. If size() < size, appends size - size() copies of val to the sequence.

Requires: T shall be CopyInsertable into *this.

Remarks: If an exception is thrown there are no effects.

iterator begin()
iterator end()
const_iterator cbegin() const
const_iterator cend() const
const_iterator begin() const
const_iterator end() const
void swap(vector &other)

Effects: Exchanges the contents and capacity() of *this with that of x.

Complexity: Constant time.

void clear()

Effects: Erases all elements in the range [begin(),end()). Destroys all elements in a. Invalidates all references, pointers, and iterators referring to the elements of a and may invalidate the past-the-end iterator.

Post: a.empty() returns true.

Complexity: Linear.

Private Types

typedef traits::allocator_traits<Allocator> alloc_traits

Private Members

size_type size_
size_type capacity_
allocator_type alloc_
pointer data_

#include <hpx/compute/host/default_executor.hpp>

template <>
template<>
struct executor_execution_category<compute::host::default_executor>

Public Types

typedef parallel::execution::parallel_execution_tag type
namespace hpx
namespace compute
namespace host
struct default_executor

Public Functions

default_executor(host::target &target)
template <typename F, typename... Ts>
void post(F &&f, Ts&&... ts)
template <typename F, typename... Ts>
hpx::future<void> async_execute(F &&f, Ts&&... ts)

Public Static Functions

template <typename F, typename... Ts>
static void sync_execute(F &&f, Ts&&... ts)
template <typename F, typename Shape, typename... Ts>
static std::vector<hpx::future<void>> bulk_async_execute(F &&f, Shape const &shape, Ts&&... ts)
template <typename F, typename Shape, typename... Ts>
static void bulk_sync_execute(F &&f, Shape const &shape, Ts&&... ts)
namespace parallel
namespace execution
template <>
template<>
struct executor_execution_category<compute::host::default_executor>

Public Types

typedef parallel::execution::parallel_execution_tag type

#include <hpx/compute/host/numa_domains.hpp>

namespace hpx
namespace compute
namespace host

Functions

std::vector<target> numa_domains()

#include <hpx/compute/host/block_allocator.hpp>

namespace hpx
namespace compute
namespace host
template <typename T, typename Executor = hpx::parallel::execution::local_priority_queue_attached_executor>
struct block_allocator
#include <block_allocator.hpp>

The block_allocator allocates blocks of memory evenly divided onto the passed vector of targets. This is done by using first touch memory placement. (maybe better methods will be used in the future…);

This allocator can be used to write NUMA aware algorithms:

typedef hpx::compute::host::block_allocator<int> allocator_type; typedef hpx::compute::vector<int, allocator_type> vector_type;

auto numa_nodes = hpx::compute::host::numa_domains(); std::size_t N = 2048; vector_type v(N, allocator_type(numa_nodes));

Public Types

typedef T value_type
typedef T *pointer
typedef const T *const_pointer
typedef T &reference
typedef T const &const_reference
typedef std::size_t size_type
typedef std::ptrdiff_t difference_type
typedef Executor executor_type
typedef std::false_type is_always_equal
typedef std::true_type propagate_on_container_move_assignment
typedef std::vector<host::target> target_type

Public Functions

block_allocator()
block_allocator(target_type const &targets)
block_allocator(target_type &&targets)
block_allocator(block_allocator const &alloc)
block_allocator(block_allocator &&alloc)
template <typename U>
block_allocator(block_allocator<U> const &alloc)
template <typename U>
block_allocator(block_allocator<U> &&alloc)
block_allocator &operator=(block_allocator const &rhs)
block_allocator &operator=(block_allocator &&rhs)
pointer address(reference x) const
const_pointer address(const_reference x) const
pointer allocate(size_type n, std::allocator<void>::const_pointer hint = nullptr)
void deallocate(pointer p, size_type n)
size_type max_size() const
template <typename U, typename... Args>
void bulk_construct(U *p, std::size_t count, Args&&... args)
template <typename U, typename... Args>
void construct(U *p, Args&&... args)
template <typename U>
void bulk_destroy(U *p, std::size_t count)
template <typename U>
void destroy(U *p)
target_type const &target() const

Private Members

block_executor<executor_type> executor_
template <typename U>
struct rebind

Public Types

template<>
typedef block_allocator<U> other

#include <hpx/compute/host/target.hpp>

namespace hpx
namespace compute
namespace host
struct target

Public Functions

target()
target(hpx::threads::mask_type mask)
target(hpx::id_type const &locality)
target(hpx::id_type const &locality, hpx::threads::mask_type mask)
native_handle_type &native_handle()
native_handle_type const &native_handle() const
hpx::id_type const &get_locality() const
std::pair<std::size_t, std::size_t> num_pus() const
void synchronize() const
hpx::future<void> get_future() const

Public Static Functions

static std::vector<target> get_local_targets()
static hpx::future<std::vector<target>> get_targets(hpx::id_type const &locality)

Private Functions

void serialize(serialization::input_archive &ar, const unsigned int)
void serialize(serialization::output_archive &ar, const unsigned int)

Private Members

native_handle_type handle_
hpx::id_type locality_

Friends

friend hpx::compute::host::hpx::serialization::access
bool operator==(target const &lhs, target const &rhs)
struct native_handle_type

Public Functions

native_handle_type()
native_handle_type(hpx::threads::mask_type mask)
hpx::threads::mask_type &get_device()
hpx::threads::mask_type const &get_device() const

Private Members

hpx::threads::mask_type mask_

Friends

friend hpx::compute::host::target

#include <hpx/compute/host/target_distribution_policy.hpp>

namespace hpx
namespace compute
namespace host

Variables

target_distribution_policy const target_layout

A predefined instance of the target_distribution_policy for localities. It will represent all NUMA domains of the given locality and will place all items to create here.

struct target_distribution_policy : public compute::detail::target_distribution_policy<host::target>
#include <target_distribution_policy.hpp>

A target_distribution_policy used for CPU bound localities.

Public Types

typedef compute::detail::target_distribution_policy<host::target> base_type

Public Functions

target_distribution_policy()

Default-construct a new instance of a target_distribution_policy. This policy will represent all devices on the current locality.

target_distribution_policy operator()(std::vector<target_type> const &targets, std::size_t num_partitions = std::size_t(-1)) const

Create a new target_distribution_policy representing the given set of targets

Parameters
  • targets: [in] The targets the new instances should represent

target_distribution_policy operator()(std::vector<target_type> &&targets, std::size_t num_partitions = std::size_t(-1)) const

Create a new target_distribution_policy representing the given set of targets

Parameters
  • targets: [in] The targets the new instances should represent

target_distribution_policy operator()(target_type const &target, std::size_t num_partitions = 1) const

Create a new target_distribution_policy representing the given target

Parameters
  • target: [in] The target the new instances should represent

target_distribution_policy operator()(target_type &&target, std::size_t num_partitions = 1) const

Create a new target_distribution_policy representing the given target

Parameters
  • target: [in] The target the new instances should represent

template <typename Component, typename... Ts>
hpx::future<hpx::id_type> create(Ts&&... ts) const

Create one object on one of the localities associated by this policy instance

Note
This function is part of the placement policy implemented by this class
Return
A future holding the global address which represents the newly created object
Parameters
  • ts: [in] The arguments which will be forwarded to the constructor of the new object.

template <typename Component, typename... Ts>
hpx::future<std::vector<bulk_locality_result>> bulk_create(std::size_t count, Ts&&... ts) const

Create multiple objects on the localities associated by this policy instance

Note
This function is part of the placement policy implemented by this class
Return
A future holding the list of global addresses which represent the newly created objects
Parameters
  • count: [in] The number of objects to create
  • vs: [in] The arguments which will be forwarded to the constructors of the new objects.

#include <hpx/compute/host/get_targets.hpp>

namespace hpx
namespace compute
namespace host

Functions

std::vector<target> get_local_targets()
hpx::future<std::vector<target>> get_targets(hpx::id_type const &locality)

#include <hpx/compute/host/block_executor.hpp>

template <typename Executor>
template<>
struct executor_execution_category<compute::host::block_executor<Executor>>

Public Types

typedef parallel::execution::parallel_execution_tag type
namespace hpx
namespace compute
namespace host
template <typename Executor = hpx::threads::executors::local_priority_queue_attached_executor>
struct block_executor
#include <block_executor.hpp>

The block executor can be used to build NUMA aware programs. It will distribute work evenly across the passed targets

Template Parameters
  • Executor: The underlying executor to use

Public Types

typedef hpx::parallel::execution::static_chunk_size executor_parameters_type

Public Functions

block_executor(std::vector<host::target> const &targets)
block_executor(std::vector<host::target> &&targets)
block_executor(block_executor const &other)
block_executor(block_executor &&other)
block_executor &operator=(block_executor const &other)
block_executor &operator=(block_executor &&other)
template <typename F, typename... Ts>
void post(F &&f, Ts&&... ts)
template <typename F, typename... Ts>
hpx::future<typename hpx::util::detail::invoke_deferred_result<F, Ts...>::type> async_execute(F &&f, Ts&&... ts)
template <typename F, typename... Ts>
hpx::util::detail::invoke_deferred_result<F, Ts...>::type sync_execute(F &&f, Ts&&... ts)
template <typename F, typename Shape, typename... Ts>
std::vector<hpx::future<typename parallel::execution::detail::bulk_function_result<F, Shape, Ts...>::type>> bulk_async_execute(F &&f, Shape const &shape, Ts&&... ts)
template <typename F, typename Shape, typename... Ts>
parallel::execution::detail::bulk_execute_result<F, Shape, Ts...>::type bulk_sync_execute(F &&f, Shape const &shape, Ts&&... ts)
std::vector<host::target> const &targets() const

Private Functions

void init_executors()

Private Members

std::vector<host::target> targets_
std::atomic<std::size_t> current_
std::vector<Executor> executors_
namespace parallel
namespace execution
template <typename Executor>
template<>
struct executor_execution_category<compute::host::block_executor<Executor>>

Public Types

typedef parallel::execution::parallel_execution_tag type

#include <hpx/compute/host/traits/access_target.hpp>

template <>
template<>
struct access_target<host::target>

Public Types

typedef host::target target_type

Public Static Functions

template <typename T>
static T const &read(target_type const &tgt, T const *t)
template <typename T>
static void write(target_type const &tgt, T *dst, T const *src)
template <>
template<>
struct access_target<std::vector<host::target>>

Public Types

typedef std::vector<host::target> target_type

Public Static Functions

template <typename T>
static T const &read(target_type const &tgt, T const *t)
template <typename T>
static void write(target_type const &tgt, T *dst, T const *src)
namespace hpx
namespace compute
namespace traits
template <>
template<>
struct access_target<host::target>

Public Types

typedef host::target target_type

Public Static Functions

template <typename T>
static T const &read(target_type const &tgt, T const *t)
template <typename T>
static void write(target_type const &tgt, T *dst, T const *src)
template <>
template<>
struct access_target<std::vector<host::target>>

Public Types

typedef std::vector<host::target> target_type

Public Static Functions

template <typename T>
static T const &read(target_type const &tgt, T const *t)
template <typename T>
static void write(target_type const &tgt, T *dst, T const *src)

#include <hpx/compute/traits/access_target.hpp>

#include <hpx/compute/traits/allocator_traits.hpp>

namespace hpx
namespace compute
namespace traits
template <typename Allocator>
struct allocator_traits : public std::allocator_traits<Allocator>

Public Types

typedef detail::get_reference_type<Allocator>::type reference
typedef detail::get_const_reference_type<Allocator>::type const_reference
typedef detail::get_target_traits<Allocator>::type access_target
typedef access_target::target_type target_type

Public Static Functions

static HPX_HOST_DEVICE auto hpx::compute::traits::allocator_traits::target(Allocator const & alloc)
template <typename… Ts>
static HPX_HOST_DEVICE void hpx::compute::traits::allocator_traits::bulk_construct(Allocator & alloc, pointer p, size_type count, Ts &&... vs)
static HPX_HOST_DEVICE void hpx::compute::traits::allocator_traits::bulk_destroy(Allocator & alloc, pointer p, size_type count)

Private Types

typedef std::allocator_traits<Allocator> base_type

#include <hpx/compute/serialization/vector.hpp>

namespace hpx
namespace serialization

Functions

template <typename T, typename Allocator>
void serialize(input_archive &ar, compute::vector<T, Allocator> &v, unsigned)
template <typename T, typename Allocator>
void serialize(output_archive &ar, compute::vector<T, Allocator> const &v, unsigned)