26 #ifndef TILEDARRAY_SHARED_BUFFER_H__INCLUDED 27 #define TILEDARRAY_SHARED_BUFFER_H__INCLUDED 31 #ifndef TILEDARRAY_DEFAULT_ALIGNMENT 32 #define TILEDARRAY_DEFAULT_ALIGNMENT 16 33 #endif // TILEDARRAY_ALIGNMENT 62 mutable madness::AtomicInt* counter_;
65 typename std::enable_if<std::is_scalar<U>::value>::type
66 default_construct(
const size_type, U* MADNESS_RESTRICT) { }
69 typename std::enable_if<! std::is_scalar<U>::value>::type
70 default_construct(
const size_type n, U* MADNESS_RESTRICT u) {
83 const int count = (*counter_)--;
94 > sizeof_aligned_atomic_int;
98 if(posix_memalign(& buffer,
alignment, (n *
sizeof(
value_type)) + sizeof_aligned_atomic_int::value) != 0)
99 throw std::bad_alloc();
102 counter_ =
reinterpret_cast<madness::AtomicInt*
>(buffer);
103 new(counter_) madness::AtomicInt;
107 pointer const array =
reinterpret_cast<pointer>(
reinterpret_cast<char*
>(buffer) + sizeof_aligned_atomic_int::value);
122 template <
typename Value,
123 typename std::enable_if<
124 std::is_convertible<value_type, Value>::value
133 template <
typename Arg>
141 template <
typename Arg,
typename Op>
149 template <
typename U,
typename Op>
157 template <
typename Left,
typename Right,
typename Op>
159 const Right* MADNESS_RESTRICT
const right,
const Op& op) :
166 template <
typename U,
typename V,
typename Op>
178 counter_(other.counter_)
185 if(counter_ != other.counter_) {
187 madness::AtomicInt*
const counter = other.counter_;
245 template <
typename U,
typename Op>
263 template <
typename U,
typename V,
typename Op>
280 template <
typename U,
typename Op>
299 template <
typename U,
typename Result,
typename Op>
317 template <
typename U,
typename V,
typename Op>
333 template <
typename U,
typename Op>
351 template <
typename U,
typename V,
typename Op>
367 template <
typename U,
typename Op>
385 template <
typename U,
typename V,
typename Op>
403 template <
typename U,
typename V,
typename Op>
422 template <
typename U,
typename V,
typename A,
typename Op>
442 template <
typename U>
447 template <
typename U>
455 template <
typename T>
456 inline std::ostream& operator<<(std::ostream& os, const ValArray<T>& val_array) {
464 #endif // TILEDARRAY_SHARED_BUFFER_H__INCLUDED
void outer_fill(const ValArray< U > &left, const ValArray< V > &right, const Op &op)
Outer fill operation.
ValArray(const ValArray< U > &left, const ValArray< V > &right, const Op &op)
std::enable_if<!(std::is_scalar< Left >::value &&std::is_scalar< Right >::value &&std::is_scalar< Result >::value)>::type uninitialized_binary_vector_op(const std::size_t n, const Left *const left, const Right *const right, Result *const result, Op &&op)
void outer_fill(const size_type m, const size_type n, const Left *const left, const Right *const right, const Op &op)
Outer fill operation.
ValArray(const ValArray_ &other)
SizeArray< T >::const_pointer const_pointer
Const data pointer type.
ValArray(const size_type n, const Value &value)
void outer_fill(const ValArray< U > &left, const ValArray< V > &right, const ValArray< A > &a, const Op &op)
Outer operation.
void swap(Bitset< B > &b0, Bitset< B > &b1)
std::enable_if<!(std::is_scalar< Arg >::value &&std::is_scalar< Result >::value)>::type uninitialized_copy_vector(const std::size_t n, const Arg *const arg, Result *const result)
SizeArray< T >::size_type size_type
size type
void col_reduce(const ValArray< U > &arg, const Op &op)
Reduce column operation.
void set(pointer const first, const size_type n)
void binary(const ValArray< U > &arg, const Op &op)
Binary vector operation.
ValArray(const size_type n, const Arg *const arg)
ValArray_ & operator=(const ValArray_ &other)
void col_reduce(const ValArray< U > &left, const ValArray< V > &right, const Op &op)
Reduce column operation.
void col_reduce(const size_type m, const Left *const left, const Right *right, const Op &op)
Column reduce operation.
std::ptrdiff_t difference_type
SizeArray< T >::const_reference const_reference
Const reference type.
ValArray(const size_type n, const Arg *MADNESS_RESTRICT const arg, const Op &op)
const_pointer data() const
SizeArray< T >::reference reference
Reference type.
void row_reduce(const size_type n, const Left *const left, const Right *right, const Op &op)
Row reduce operation.
ValArray< T > ValArray_
This object type.
Result reduce(const ValArray< U > &arg, Result &result, const Op &op)
Binary reduce operation.
ValArray(const size_type n)
std::enable_if<! std::is_scalar< Arg >::value >::type destroy_vector(const std::size_t n, Arg *const arg)
void swap(ValArray_ &other)
const T & const_reference
SizeArray< T >::iterator iterator
Iterator type.
void outer(const ValArray< U > &left, const ValArray< V > &right, const Op &op)
Outer operation.
ValArray(const size_type n, const Left *MADNESS_RESTRICT const left, const Right *MADNESS_RESTRICT const right, const Op &op)
void print_array(std::ostream &out, const A &a, const std::size_t n)
Print the content of an array like object.
SizeArray< T >::pointer pointer
Data pointer type.
void row_reduce(const ValArray< U > &arg, const Op &op)
Reduce row operation.
SizeArray< T >::value_type value_type
Element type.
void unary(const ValArray< U > &arg, const Op &op)
Unary vector operation.
SizeArray< T >::difference_type difference_type
Difference type.
bool operator!=(const ValArray< U > &other) const
void binary(const Arg *const arg, const Op &op)
Binary vector operation.
#define TILEDARRAY_DEFAULT_ALIGNMENT
Result reduce(const Arg *const arg, Result result, const ReduceOp &reduce_op, const JoinOp &join_op) const
Binary reduction operation.
bool operator!=(const SizeArray< U > &other) const
void row_reduce(const ValArray< U > &left, const ValArray< V > &right, const Op &op)
Reduce row operation.
void unary(const Op &op)
Unary vector operation.
void outer(const size_type m, const size_type n, const Left *const left, const Right *const right, const Op &op)
Outer operation.
SizeArray< T >::const_iterator const_iterator
Const iterator type.
bool operator==(const SizeArray< U > &other) const
void binary(const ValArray< U > &left, const ValArray< V > &right, const Op &op)
Binary vector operation.
static const std::size_t alignment
std::enable_if<!(std::is_scalar< Arg >::value &&std::is_scalar< Result >::value)>::type uninitialized_unary_vector_op(const std::size_t n, const Arg *const arg, Result *const result, Op &&op)
ValArray(const ValArray< U > &arg, const Op &op)
bool operator==(const ValArray< U > &other) const
std::enable_if<!(std::is_scalar< Arg >::value &&std::is_scalar< Result >::value)>::type uninitialized_fill_vector(const std::size_t n, const Arg &arg, Result *const result)