Itoyori  v0.0.1
ityr Namespace Reference

Namespaces

 checkout_mode
 
 common
 
 execution
 
 ito
 
 ori
 
 reducer
 

Classes

class  checkout_span
 Checkout span to automatically manage the lifetime of checked-out memory. More...
 
class  global_span
 Global span to represent a view of a global memory range. More...
 
struct  global_vector_options
 Options for ityr::global_vector. More...
 
class  global_vector
 Global vector to manage a global memory region. More...
 
class  unique_file_ptr
 
class  workhint_range
 
class  workhint_range< void >
 
class  workhint_range_view
 
class  workhint_range_view< void >
 
class  count_iterator
 Count iterator. More...
 
struct  is_global_iterator
 See ityr::is_global_iterator_v. More...
 
struct  is_global_iterator< T, std::void_t< typename T::checkout_iterator > >
 See ityr::is_global_iterator_v. More...
 
class  global_iterator
 Global iterator to enable/disable automatic checkout. More...
 
class  global_move_iterator
 Global iterator for moving objects. More...
 
class  global_reverse_iterator
 Reverse iterator for global memory. More...
 
class  global_construct_iterator
 Global iterator for constructing objects. More...
 
class  global_destruct_iterator
 Global iterator for destructing objects. More...
 
struct  workhint
 

Typedefs

using rank_t = common::topology::rank_t
 Process rank (ID) starting from 0 (corresponding to an MPI rank). More...
 
using wallclock_t = common::wallclock::wallclock_t
 Wallclock time in nanoseconds. More...
 
using default_random_engine = internal::random_engine_dummy
 

Functions

template<typename T , typename Mode >
constexpr auto data (const checkout_span< T, Mode > &cs) noexcept
 
template<typename T , typename Mode >
constexpr auto size (const checkout_span< T, Mode > &cs) noexcept
 
template<typename T , typename Mode >
constexpr auto begin (const checkout_span< T, Mode > &cs) noexcept
 
template<typename T , typename Mode >
constexpr auto end (const checkout_span< T, Mode > &cs) noexcept
 
template<typename T , typename Mode >
checkout_span< T, Mode > make_checkout (ori::global_ptr< T > gptr, std::size_t n, Mode mode)
 Checkout a global memory region. More...
 
template<typename T , typename Mode >
checkout_span< T, Mode > make_checkout (global_span< T > gspan, Mode mode)
 Checkout a global memory region. More...
 
template<typename... Args>
auto make_checkouts (Args &&... args)
 Checkout multiple global memory regions. More...
 
template<typename T >
constexpr auto data (const global_span< T > &s) noexcept
 
template<typename T >
constexpr auto size (const global_span< T > &s) noexcept
 
template<typename T >
constexpr auto begin (const global_span< T > &s) noexcept
 
template<typename T >
constexpr auto end (const global_span< T > &s) noexcept
 
template<typename T >
void swap (global_vector< T > &v1, global_vector< T > &v2) noexcept
 
template<typename T >
bool operator== (const global_vector< T > &x, const global_vector< T > &y)
 
template<typename T >
bool operator!= (const global_vector< T > &x, const global_vector< T > &y)
 
template<typename T1 , typename T2 >
bool operator== (const unique_file_ptr< T1 > &ufp1, const unique_file_ptr< T2 > &ufp2)
 
template<typename T >
bool operator== (const unique_file_ptr< T > &ufp, std::nullptr_t)
 
template<typename T >
bool operator== (std::nullptr_t, const unique_file_ptr< T > &ufp)
 
template<typename T1 , typename T2 >
bool operator!= (const unique_file_ptr< T1 > &ufp1, const unique_file_ptr< T2 > &ufp2)
 
template<typename T >
bool operator!= (const unique_file_ptr< T > &ufp, std::nullptr_t)
 
template<typename T >
bool operator!= (std::nullptr_t, const unique_file_ptr< T > &ufp)
 
template<typename T1 , typename T2 >
bool operator> (const unique_file_ptr< T1 > &ufp1, const unique_file_ptr< T2 > &ufp2)
 
template<typename T >
bool operator> (const unique_file_ptr< T > &ufp, std::nullptr_t)
 
template<typename T >
bool operator> (std::nullptr_t, const unique_file_ptr< T > &ufp)
 
template<typename T1 , typename T2 >
bool operator>= (const unique_file_ptr< T1 > &ufp1, const unique_file_ptr< T2 > &ufp2)
 
template<typename T >
bool operator>= (const unique_file_ptr< T > &ufp, std::nullptr_t)
 
template<typename T >
bool operator>= (std::nullptr_t, const unique_file_ptr< T > &ufp)
 
template<typename T1 , typename T2 >
bool operator< (const unique_file_ptr< T1 > &ufp1, const unique_file_ptr< T2 > &ufp2)
 
template<typename T >
bool operator< (const unique_file_ptr< T > &ufp, std::nullptr_t)
 
template<typename T >
bool operator< (std::nullptr_t, const unique_file_ptr< T > &ufp)
 
template<typename T1 , typename T2 >
bool operator<= (const unique_file_ptr< T1 > &ufp1, const unique_file_ptr< T2 > &ufp2)
 
template<typename T >
bool operator<= (const unique_file_ptr< T > &ufp, std::nullptr_t)
 
template<typename T >
bool operator<= (std::nullptr_t, const unique_file_ptr< T > &ufp)
 
template<typename T >
void swap (unique_file_ptr< T > ufp1, unique_file_ptr< T > ufp2)
 
template<typename CharT , typename Traits , typename T >
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &ostream, const unique_file_ptr< T > &ufp)
 
template<typename T >
unique_file_ptr< T > make_unique_file (const std::string &fpath, bool mlock=false)
 
template<typename ExecutionPolicy , typename ForwardIterator , typename Op >
auto create_workhint_range (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Op op, std::size_t n_leaves)
 
template<typename ExecutionPolicy , typename ForwardIterator , typename Op >
auto create_workhint_range (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Op op)
 
void init (MPI_Comm comm=MPI_COMM_WORLD)
 Initialize Itoyori (collective). More...
 
void fini ()
 Finalize Itoyori (collective). More...
 
rank_t my_rank ()
 Return the rank of the process running the current thread. More...
 
rank_t n_ranks ()
 Return the total number of processes. More...
 
bool is_master ()
 Return true if ityr::my_rank() == 0. More...
 
bool is_root ()
 Return true if the current thread is the root thread. More...
 
void migrate_to (rank_t target_rank)
 Migrate the current thread to target_rank. For the root thread only. More...
 
void migrate_to_master ()
 Migrate the current thread to the master worker (of rank 0). More...
 
bool is_spmd ()
 Return true if the current execution context is within the SPMD region. More...
 
void barrier ()
 Barrier for all processes (collective). More...
 
wallclock_t gettime_ns ()
 Return the current wallclock time in nanoseconds. More...
 
void profiler_begin ()
 Start the profiler (collective). More...
 
void profiler_end ()
 Stop the profiler (collective). More...
 
void profiler_flush ()
 Print the profiled results to stdout (collective). More...
 
void print_compile_options ()
 Print the compile-time options to stdout. More...
 
void print_runtime_options ()
 Print the runtime options to stdout. More...
 
template<typename T >
bool operator== (const count_iterator< T > &it1, const count_iterator< T > &it2)
 
template<typename T >
bool operator!= (const count_iterator< T > &it1, const count_iterator< T > &it2)
 
template<typename T >
bool operator< (const count_iterator< T > &it1, const count_iterator< T > &it2)
 
template<typename T >
bool operator> (const count_iterator< T > &it1, const count_iterator< T > &it2)
 
template<typename T >
bool operator<= (const count_iterator< T > &it1, const count_iterator< T > &it2)
 
template<typename T >
bool operator>= (const count_iterator< T > &it1, const count_iterator< T > &it2)
 
template<typename T >
auto make_count_iterator (T x)
 
template<typename T , typename Mode >
global_iterator< T, Mode > make_global_iterator (ori::global_ptr< T > gptr, Mode)
 Make a global iterator to enable/disable automatic checkout. More...
 
template<typename T >
global_move_iterator< global_iterator< T, internal::src_checkout_mode_t< T > > > make_move_iterator (ori::global_ptr< T > gptr)
 Make a global iterator for moving objects. More...
 
template<typename T , typename Mode >
global_reverse_iterator< global_iterator< T, Mode > > make_reverse_iterator (ori::global_ptr< T > gptr, Mode mode)
 Make a reverse iterator for global memory. More...
 
template<typename GlobalIterator >
global_construct_iterator< GlobalIterator > make_construct_iterator (GlobalIterator git)
 Make a global iterator for constructing objects. More...
 
template<typename T >
global_construct_iterator< global_iterator< T, checkout_mode::write_t > > make_construct_iterator (ori::global_ptr< T > gptr)
 Make a global iterator for constructing objects. More...
 
template<typename GlobalIterator >
global_destruct_iterator< GlobalIterator > make_destruct_iterator (GlobalIterator git)
 Make a global iterator for destructing objects. More...
 
template<typename T >
global_destruct_iterator< global_iterator< T, checkout_mode::read_write_t > > make_destruct_iterator (ori::global_ptr< T > gptr)
 Make a global iterator for destructing objects. More...
 
template<typename T , typename Mode >
global_move_iterator< global_iterator< T, Mode > > make_move_iterator (global_iterator< T, Mode > git)
 Make a global iterator for moving objects. More...
 
template<typename GlobalIterator >
global_move_iterator< global_reverse_iterator< GlobalIterator > > make_move_iterator (global_reverse_iterator< GlobalIterator > git)
 Make a global iterator for moving objects. More...
 
template<typename T , typename Mode >
global_reverse_iterator< global_iterator< T, Mode > > make_reverse_iterator (global_iterator< T, Mode > git)
 Make a reverse iterator for global memory. More...
 
template<typename GlobalIterator >
global_reverse_iterator< global_move_iterator< GlobalIterator > > make_reverse_iterator (global_move_iterator< GlobalIterator > git)
 Make a reverse iterator for global memory. More...
 
template<typename ExecutionPolicy , typename BidirectionalIterator , typename Predicate >
BidirectionalIterator stable_partition (const ExecutionPolicy &policy, BidirectionalIterator first, BidirectionalIterator last, Predicate pred)
 Partition elements into two disjoint parts in place. More...
 
template<typename ExecutionPolicy , typename BidirectionalIterator , typename Predicate >
BidirectionalIterator partition (const ExecutionPolicy &policy, BidirectionalIterator first, BidirectionalIterator last, Predicate pred)
 Partition elements into two disjoint parts in place. More...
 
template<typename... Args>
auto parallel_invoke (Args &&... args)
 Fork parallel tasks and join them. More...
 
template<typename ExecutionPolicy , typename ForwardIterator , typename Op >
void for_each (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Op op)
 Apply an operator to each element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename Op >
void for_each (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, Op op)
 Apply an operator to each element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename Op >
void for_each (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator3 first3, Op op)
 Apply an operator to each element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename ForwardIterator4 , typename Op >
void for_each (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator3 first3, ForwardIterator4 first4, Op op)
 Apply an operator to each element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename ForwardIterator4 , typename ForwardIterator5 , typename Op >
void for_each (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator3 first3, ForwardIterator4 first4, ForwardIterator5 first5, Op op)
 Apply an operator to each element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename ForwardIterator4 , typename ForwardIterator5 , typename ForwardIterator6 , typename Op >
void for_each (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator3 first3, ForwardIterator4 first4, ForwardIterator5 first5, ForwardIterator6 first6, Op op)
 Apply an operator to each element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename ForwardIterator4 , typename ForwardIterator5 , typename ForwardIterator6 , typename ForwardIterator7 , typename Op >
void for_each (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator3 first3, ForwardIterator4 first4, ForwardIterator5 first5, ForwardIterator6 first6, ForwardIterator6 first7, Op op)
 Apply an operator to each element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename ForwardIterator4 , typename ForwardIterator5 , typename ForwardIterator6 , typename ForwardIterator7 , typename ForwardIterator8 , typename Op >
void for_each (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator3 first3, ForwardIterator4 first4, ForwardIterator5 first5, ForwardIterator6 first6, ForwardIterator6 first7, ForwardIterator6 first8, Op op)
 Apply an operator to each element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD , typename UnaryOp >
ForwardIteratorD transform (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d, UnaryOp unary_op)
 Transform elements in a given range and store them in another range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIteratorD , typename BinaryOp >
ForwardIteratorD transform (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIteratorD first_d, BinaryOp binary_op)
 Transform elements in given ranges and store them in another range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator , typename T >
void fill (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, const T &value)
 Fill a range with a given value. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD >
ForwardIteratorD copy (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d)
 Copy a range to another. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD >
ForwardIteratorD move (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d)
 Move a range to another. More...
 
template<typename ExecutionPolicy , typename BidirectionalIterator >
void reverse (const ExecutionPolicy &policy, BidirectionalIterator first, BidirectionalIterator last)
 Reverse a range. More...
 
template<typename ExecutionPolicy , typename BidirectionalIterator1 , typename BidirectionalIteratorD >
BidirectionalIteratorD reverse_copy (const ExecutionPolicy &policy, BidirectionalIterator1 first1, BidirectionalIterator1 last1, BidirectionalIteratorD first_d)
 Copy a reversed range to another. More...
 
template<typename ExecutionPolicy , typename BidirectionalIterator >
BidirectionalIterator rotate (const ExecutionPolicy &policy, BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last)
 Rotate a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD >
ForwardIteratorD rotate_copy (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 middle1, ForwardIterator1 last1, ForwardIteratorD first_d)
 Copy a rotated range to another. More...
 
template<typename ExecutionPolicy , typename RandomAccessIterator , typename Compare >
void inplace_merge (const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp)
 Merge two sorted ranges into one sorted range in place. More...
 
template<typename ExecutionPolicy , typename RandomAccessIterator >
void inplace_merge (const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last)
 Merge two sorted ranges into one sorted range in place. More...
 
template<typename ExecutionPolicy , typename ForwardIterator , typename Reducer , typename UnaryTransformOp >
Reducer::accumulator_type transform_reduce (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Reducer reducer, UnaryTransformOp unary_transform_op)
 Calculate reduction while transforming each element. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename Reducer , typename BinaryTransformOp >
Reducer::accumulator_type transform_reduce (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, Reducer reducer, BinaryTransformOp binary_transform_op)
 Calculate reduction by transforming each element. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 >
auto transform_reduce (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2)
 Calculate a dot product. More...
 
template<typename ExecutionPolicy , typename ForwardIterator , typename Reducer >
Reducer::accumulator_type reduce (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Reducer reducer)
 Calculate reduction. More...
 
template<typename ExecutionPolicy , typename ForwardIterator >
std::iterator_traits< ForwardIterator >::value_type reduce (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last)
 Calculate reduction. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD , typename Reducer , typename UnaryTransformOp >
ForwardIteratorD transform_inclusive_scan (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d, Reducer reducer, UnaryTransformOp unary_transform_op, typename Reducer::accumulator_type &&init)
 Calculate a prefix sum (inclusive scan) while transforming each element. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD , typename Reducer , typename UnaryTransformOp >
ForwardIteratorD transform_inclusive_scan (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d, Reducer reducer, UnaryTransformOp unary_transform_op)
 Calculate a prefix sum (inclusive scan) while transforming each element. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD , typename Reducer >
ForwardIteratorD inclusive_scan (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d, Reducer reducer, typename Reducer::accumulator_type &&init)
 Calculate a prefix sum (inclusive scan). More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD , typename Reducer >
ForwardIteratorD inclusive_scan (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d, Reducer reducer)
 Calculate a prefix sum (inclusive scan). More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD >
ForwardIteratorD inclusive_scan (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d)
 Calculate a prefix sum (inclusive scan). More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename BinaryPredicate >
bool equal (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, BinaryPredicate pred)
 Check if two ranges have equal values. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename BinaryPredicate >
bool equal (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred)
 Check if two ranges have equal values. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 >
bool equal (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2)
 Check if two ranges have equal values. More...
 
template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 >
bool equal (const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2)
 Check if two ranges have equal values. More...
 
template<typename ExecutionPolicy , typename ForwardIterator , typename Compare >
bool is_sorted (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Compare comp)
 Check if a range is sorted. More...
 
template<typename ExecutionPolicy , typename ForwardIterator >
bool is_sorted (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last)
 Check if a range is sorted. More...
 
template<typename ExecutionPolicy , typename ForwardIterator , typename Compare >
ForwardIterator min_element (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Compare comp)
 Search for the minimum element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator >
ForwardIterator min_element (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last)
 Search for the minimum element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator , typename Compare >
ForwardIterator max_element (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Compare comp)
 Search for the maximum element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator >
ForwardIterator max_element (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last)
 Search for the maximum element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator , typename Compare >
std::pair< ForwardIterator, ForwardIterator > minmax_element (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Compare comp)
 Search for the minimum and maximum element in a range. More...
 
template<typename ExecutionPolicy , typename ForwardIterator >
std::pair< ForwardIterator, ForwardIterator > minmax_element (const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last)
 Search for the minimum and maximum element in a range. More...
 
template<typename ExecutionPolicy , typename RandomAccessIterator , typename UniformRandomBitGenerator >
void shuffle (const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator last, UniformRandomBitGenerator &&urbg)
 Randomly shuffle elements in a range. More...
 
template<typename ExecutionPolicy , typename RandomAccessIterator , typename Compare >
void stable_sort (const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator last, Compare comp)
 Stable sort for a range. More...
 
template<typename ExecutionPolicy , typename RandomAccessIterator >
void stable_sort (const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator last)
 Stable sort for a range. More...
 
template<typename ExecutionPolicy , typename RandomAccessIterator , typename Compare >
void sort (const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator last, Compare comp)
 Sort a range. More...
 
template<typename ExecutionPolicy , typename RandomAccessIterator >
void sort (const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator last)
 Sort a range. More...
 
template<typename Fn , typename... Args>
auto root_exec (Fn &&fn, Args &&... args)
 Spawn the root thread (collective). More...
 
template<typename Fn , typename... Args>
auto coll_exec (const Fn &fn, const Args &... args)
 Execute the same function collectively on all processes. More...
 
template<typename BidirectionalIterator1 , typename BidirectionalIteratorD >
BidirectionalIteratorD move_backward (const execution::sequenced_policy &policy, BidirectionalIterator1 first1, BidirectionalIterator1 last1, BidirectionalIteratorD first_d)
 

Variables

template<typename T >
constexpr bool is_global_iterator_v = is_global_iterator<T>::value
 True if T is a global iterator (ityr::global_iterator). More...
 

Typedef Documentation

◆ default_random_engine

using ityr::default_random_engine = typedef internal::random_engine_dummy

◆ rank_t

Process rank (ID) starting from 0 (corresponding to an MPI rank).

See also
ityr::my_rank()
ityr::n_ranks()

◆ wallclock_t

Wallclock time in nanoseconds.

See also
ityr::gettime_ns().

Function Documentation

◆ barrier()

void ityr::barrier ( )
inline

Barrier for all processes (collective).

◆ begin() [1/2]

template<typename T , typename Mode >
constexpr auto ityr::begin ( const checkout_span< T, Mode > &  cs)
inlineconstexprnoexcept

◆ begin() [2/2]

template<typename T >
constexpr auto ityr::begin ( const global_span< T > &  s)
inlineconstexprnoexcept

◆ coll_exec()

template<typename Fn , typename... Args>
auto ityr::coll_exec ( const Fn &  fn,
const Args &...  args 
)
inline

Execute the same function collectively on all processes.

Parameters
fnFunction object to be called on all processes.
args...Argments to be passed to fn (optional).
Returns
The return value of fn(args...) executed on the calling process.

This function switches from the root thread to the SPMD region to execute fn(args...) on all processes. This function must be called by the root thread (within ityr::root_exec()). The return value of fn(args...) on the process calling this function is returned, and those on other processes are discarded. This function returns when all processes complete the function.

Example:

auto ret = ityr::coll_exec([] {
// SPMD region (all processes execute this function)
return ityr::my_rank();
});
// The return value on the calling process is returned
assert(ret == my_rank);
});
rank_t my_rank()
Return the rank of the process running the current thread.
Definition: ityr.hpp:99
auto coll_exec(const Fn &fn, const Args &... args)
Execute the same function collectively on all processes.
Definition: root_exec.hpp:109
auto root_exec(Fn &&fn, Args &&... args)
Spawn the root thread (collective).
Definition: root_exec.hpp:47
See also
ityr::root_exec()

◆ copy()

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD >
ForwardIteratorD ityr::copy ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIteratorD  first_d 
)
inline

Copy a range to another.

Parameters
policyExecution policy (ityr::execution).
first1Input begin iterator.
last1Input end iterator.
first_dOutput begin iterator.
Returns
The end iterator of the output range (first_d + (last1 - first1)).

This function copies the input region [first1, last1) to the output region [first_d, first_d + (last1 - first1)). Copy semantics is applied to each element in the ranges.

If given iterators are global pointers, they are automatically checked out in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators. Input global pointers (first1 and last1) are automatically checked out with the read-only mode. if their value type is trivially copyable; otherwise, they are checked out with the read-write mode, even if they are actually not modified. Similarly, output global iterator (first_d) are checked out with the write-only mode if their value type is trivially copyable; otherwise, they are checked out with the read-write mode.

The input and output regions should not be overlapped.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
ityr::copy(ityr::execution::par, v1.begin(), v1.end(), v2.begin());
// v2 = {1, 2, 3, 4, 5}
Global vector to manage a global memory region.
Definition: global_vector.hpp:129
iterator begin() noexcept
Definition: global_vector.hpp:233
size_type size() const noexcept
Definition: global_vector.hpp:228
iterator end() noexcept
Definition: global_vector.hpp:234
constexpr parallel_policy par
Default parallel execution policy for iterator-based loop functions.
Definition: execution.hpp:89
ForwardIteratorD copy(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d)
Copy a range to another.
Definition: parallel_loop.hpp:856
See also
std::copy – cppreference.com
ityr::move
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ create_workhint_range() [1/2]

template<typename ExecutionPolicy , typename ForwardIterator , typename Op >
auto ityr::create_workhint_range ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last,
Op  op 
)
inline

◆ create_workhint_range() [2/2]

template<typename ExecutionPolicy , typename ForwardIterator , typename Op >
auto ityr::create_workhint_range ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last,
Op  op,
std::size_t  n_leaves 
)
inline

◆ data() [1/2]

template<typename T , typename Mode >
constexpr auto ityr::data ( const checkout_span< T, Mode > &  cs)
inlineconstexprnoexcept

◆ data() [2/2]

template<typename T >
constexpr auto ityr::data ( const global_span< T > &  s)
inlineconstexprnoexcept

◆ end() [1/2]

template<typename T , typename Mode >
constexpr auto ityr::end ( const checkout_span< T, Mode > &  cs)
inlineconstexprnoexcept

◆ end() [2/2]

template<typename T >
constexpr auto ityr::end ( const global_span< T > &  s)
inlineconstexprnoexcept

◆ equal() [1/4]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 >
bool ityr::equal ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2 
)
inline

Check if two ranges have equal values.

Parameters
policyExecution policy (ityr::execution).
first11st begin iterator.
last11st end iterator.
first22nd begin iterator.

Equivalent to ityr::equal(policy, first1, last1, first2, std::equal_to<>{}).

See also
std::equal – cppreference.com
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ equal() [2/4]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename BinaryPredicate >
bool ityr::equal ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
BinaryPredicate  pred 
)
inline

Check if two ranges have equal values.

Parameters
policyExecution policy (ityr::execution).
first11st begin iterator.
last11st end iterator.
first22nd begin iterator.
predBinary predicate operator.
Returns
Returns true if pred returns true for all pairs of elements in the input ranges ([first1, last1) and [first2, first2 + (last1 - first1))).

If global pointers are provided as iterators, they are automatically checked out with the read-only mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
ityr::global_vector<double> v2 = {1.0, 2.0, 3.0, 4.0, 5.0};
bool r = ityr::equal(ityr::execution::par, v1.begin(), v1.end(), v2.begin(),
[](int x, double y) { return x == static_cast<int>(y); });
// r = true
bool equal(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, BinaryPredicate pred)
Check if two ranges have equal values.
Definition: parallel_reduce.hpp:887
See also
std::equal – cppreference.com
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ equal() [3/4]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 >
bool ityr::equal ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator2  last2 
)
inline

Check if two ranges have equal values.

Parameters
policyExecution policy (ityr::execution).
first11st begin iterator.
last11st end iterator.
first22nd begin iterator.
last22nd end iterator.

Equivalent to ityr::equal(policy, first1, last1, first2, last2, std::equal_to<>{}).

See also
std::equal – cppreference.com
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ equal() [4/4]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename BinaryPredicate >
bool ityr::equal ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator2  last2,
BinaryPredicate  pred 
)
inline

Check if two ranges have equal values.

Parameters
policyExecution policy (ityr::execution).
first11st begin iterator.
last11st end iterator.
first22nd begin iterator.
last22nd end iterator.
predBinary predicate operator.
Returns
Returns true if the input ranges are of the same size (last1 - first1 == last2 - first2) and pred returns true for all pairs of elements in the input ranges.

If global pointers are provided as iterators, they are automatically checked out with the read-only mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
ityr::global_vector<double> v2 = {1.0, 2.0, 3.0, 4.0, 5.0};
bool r = ityr::equal(ityr::execution::par, v1.begin(), v1.end(), v2.begin(), v2.end(),
[](int x, double y) { return x == static_cast<int>(y); });
// r = true
See also
std::equal – cppreference.com
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ fill()

template<typename ExecutionPolicy , typename ForwardIterator , typename T >
void ityr::fill ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last,
const T &  value 
)
inline

Fill a range with a given value.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
valueValue to be filled with.

This function assigns value to every element in the given range [first, last).

If global pointers are provided as iterators, they are automatically checked out with the read-only mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::fill(ityr::execution::par, v.begin(), v.end(), 100);
// v = {100, 100, 100, 100, 100}
void fill(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, const T &value)
Fill a range with a given value.
Definition: parallel_loop.hpp:771
See also
std::reduce – cppreference.com
ityr::transform()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ fini()

void ityr::fini ( )
inline

Finalize Itoyori (collective).

This function finalizes the Itoyori runtime system. Any itoyori APIs cannot be called after this call unless ityr::init() is called again.

MPI_Finalize() may be called in this function if MPI is not initialized by the user when ityr::init() is called.

See also
ityr::init()

◆ for_each() [1/8]

template<typename ExecutionPolicy , typename ForwardIterator , typename Op >
void ityr::for_each ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last,
Op  op 
)
inline

Apply an operator to each element in a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
opOperator for the i-th element in the range.

This function iterates over the given range and applies the operator op to the i-th element. The operator op should accept an argument of type T, which is the reference type of the given iterator type. This function resembles the standard std::for_each(), but it is extended to accept multiple streams of iterators.

Global pointers are not automatically checked out. If global iterators are explicitly given (by ityr::make_global_iterator), the regions are automatically checked out with the specified mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel).

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
[](int& x) { x++; });
// v1 = {2, 3, 4, 5, 6}
constexpr read_write_t read_write
Read+Write checkout mode.
Definition: checkout_span.hpp:39
void for_each(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Op op)
Apply an operator to each element in a range.
Definition: parallel_loop.hpp:136
global_iterator< T, Mode > make_global_iterator(ori::global_ptr< T > gptr, Mode)
Make a global iterator to enable/disable automatic checkout.
Definition: global_iterator.hpp:158
See also
std::for_each – cppreference.com
ityr::reduce()
ityr::transform()
ityr::transform_reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ for_each() [2/8]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename ForwardIterator4 , typename ForwardIterator5 , typename ForwardIterator6 , typename ForwardIterator7 , typename ForwardIterator8 , typename Op >
void ityr::for_each ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator3  first3,
ForwardIterator4  first4,
ForwardIterator5  first5,
ForwardIterator6  first6,
ForwardIterator6  first7,
ForwardIterator6  first8,
Op  op 
)
inline

Apply an operator to each element in a range.

◆ for_each() [3/8]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename ForwardIterator4 , typename ForwardIterator5 , typename ForwardIterator6 , typename ForwardIterator7 , typename Op >
void ityr::for_each ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator3  first3,
ForwardIterator4  first4,
ForwardIterator5  first5,
ForwardIterator6  first6,
ForwardIterator6  first7,
Op  op 
)
inline

Apply an operator to each element in a range.

◆ for_each() [4/8]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename ForwardIterator4 , typename ForwardIterator5 , typename ForwardIterator6 , typename Op >
void ityr::for_each ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator3  first3,
ForwardIterator4  first4,
ForwardIterator5  first5,
ForwardIterator6  first6,
Op  op 
)
inline

Apply an operator to each element in a range.

◆ for_each() [5/8]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename ForwardIterator4 , typename ForwardIterator5 , typename Op >
void ityr::for_each ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator3  first3,
ForwardIterator4  first4,
ForwardIterator5  first5,
Op  op 
)
inline

Apply an operator to each element in a range.

◆ for_each() [6/8]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename ForwardIterator4 , typename Op >
void ityr::for_each ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator3  first3,
ForwardIterator4  first4,
Op  op 
)
inline

Apply an operator to each element in a range.

◆ for_each() [7/8]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIterator3 , typename Op >
void ityr::for_each ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator3  first3,
Op  op 
)
inline

Apply an operator to each element in a range.

Parameters
policyExecution policy (ityr::execution).
first11st begin iterator.
last11st end iterator.
first22nd begin iterator.
first33rd begin iterator.
opOperator for the i-th element in the 1st, 2nd, and 3rd iterators.

This function iterates over the given ranges and applies the operator op to the i-th elements. The operator op should accept three arguments of type T1, T2, and T3, which are the reference types of the given iterators first1, first2, and first3. This function resembles the standard std::for_each(), but it is extended to accept multiple streams of iterators.

Global pointers are not automatically checked out. If global iterators are explicitly given (by ityr::make_global_iterator), the regions are automatically checked out with the specified mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel).

Example:

ityr::global_vector<int> v1 = {1, 1, 1, 1, 1};
[](int i, int x, int& y) { y = x << i; });
// v2 = {1, 2, 4, 8, 16}
Count iterator.
Definition: count_iterator.hpp:33
constexpr read_t read
Read-only checkout mode.
Definition: checkout_span.hpp:19
constexpr write_t write
Write-only checkout mode.
Definition: checkout_span.hpp:29
See also
std::for_each – cppreference.com
ityr::reduce()
ityr::transform()
ityr::transform_reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ for_each() [8/8]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename Op >
void ityr::for_each ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
Op  op 
)
inline

Apply an operator to each element in a range.

Parameters
policyExecution policy (ityr::execution).
first11st begin iterator.
last11st end iterator.
first22nd begin iterator.
opOperator for the i-th element in the 1st and 2nd iterators.

This function iterates over the given ranges and applies the operator op to the i-th elements. The operator op should accept three arguments of type T1 and T2, which are the reference types of the given iterators first1 and first2. This function resembles the standard std::for_each(), but it is extended to accept multiple streams of iterators.

Global pointers are not automatically checked out. If global iterators are explicitly given (by ityr::make_global_iterator), the regions are automatically checked out with the specified mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel).

Example:

See also
std::for_each – cppreference.com
ityr::reduce()
ityr::transform()
ityr::transform_reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ gettime_ns()

wallclock_t ityr::gettime_ns ( )
inline

Return the current wallclock time in nanoseconds.

The wallclock time is calibrated across different processes (that may reside in different machines) at the program startup in a simple way, but the clock may be skewed due to various reasons. To get an accurate execution time, it is recommended to call this function in the same process and calculate the difference.

◆ inclusive_scan() [1/3]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD >
ForwardIteratorD ityr::inclusive_scan ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIteratorD  first_d 
)
inline

Calculate a prefix sum (inclusive scan).

Parameters
policyExecution policy (ityr::execution).
first1Input begin iterator.
last1Input end iterator.
first_dOutput begin iterator.
Returns
The end iterator of the output range (first_d + (last1 - first1)).

Equivalent to ityr::inclusive_scan(policy, first1, last1, first_d, ityr::reducer::plus<T>{}), where T is the value type of the input iterator.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
// v2 = {1, 3, 6, 10, 15}
ForwardIteratorD inclusive_scan(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d, Reducer reducer, typename Reducer::accumulator_type &&init)
Calculate a prefix sum (inclusive scan).
Definition: parallel_reduce.hpp:724
See also
std::inclusive_scan – cppreference.com
ityr::transform_inclusive_scan()
ityr::reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ inclusive_scan() [2/3]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD , typename Reducer >
ForwardIteratorD ityr::inclusive_scan ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIteratorD  first_d,
Reducer  reducer 
)
inline

Calculate a prefix sum (inclusive scan).

Parameters
policyExecution policy (ityr::execution).
first1Input begin iterator.
last1Input end iterator.
first_dOutput begin iterator.
reducerReducer object (ityr::reducer).
Returns
The end iterator of the output range (first_d + (last1 - first1)).

Equivalent to ityr::inclusive_scan(policy, first1, last1, first_d, reducer, reducer()).

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
// v2 = {1, 2, 6, 24, 120}
Definition: reducer.hpp:15
See also
std::inclusive_scan – cppreference.com
ityr::transform_inclusive_scan()
ityr::reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ inclusive_scan() [3/3]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD , typename Reducer >
ForwardIteratorD ityr::inclusive_scan ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIteratorD  first_d,
Reducer  reducer,
typename Reducer::accumulator_type &&  init 
)
inline

Calculate a prefix sum (inclusive scan).

Parameters
policyExecution policy (ityr::execution).
first1Input begin iterator.
last1Input end iterator.
first_dOutput begin iterator.
reducerReducer object (ityr::reducer).
initInitial value for the prefix sum.
Returns
The end iterator of the output range (first_d + (last1 - first1)).

This function calculates a prefix sum over the elements in the input range [first1, last1). The prefix sum is inclusive, which means that the i-th element of the prefix sum includes the i-th element in the input range. That is, the i-th element of the prefix sum is: init + *first1 + ... + *(first1 + i), where + is the associative binary operator (provided by reducer). The calculated prefix sum is stored in the output range [first_d, first_d + (last1 - first1)).

If given iterators are global pointers, they are automatically checked out in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators. Input global pointers (first1 and last1) are automatically checked out with the read-only mode. Similarly, output global iterator (first_d) are checked out with the write-only mode if their value type is trivially copyable; otherwise, they are checked out with the read-write mode.

Overlapping regions can be specified for the input and output ranges.

Unlike the standard std::inclusive_scan(), Itoyori's ityr::inclusive_scan() requires a reducer as ityr::reduce() does.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
// v2 = {10, 20, 60, 240, 1200}
See also
std::inclusive_scan – cppreference.com
ityr::transform_inclusive_scan()
ityr::reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ init()

void ityr::init ( MPI_Comm  comm = MPI_COMM_WORLD)
inline

Initialize Itoyori (collective).

Parameters
commMPI communicator to be used in Itoyori (default: MPI_COMM_WORLD).

This function initializes the Itoyori runtime system. Any itoyori APIs (except for runtime option settings) cannot be called prior to this call. ityr::fini() must be called to properly release allocated resources.

If MPI is not initialized at this point, Itoyori calls MPI_Init() and finalizes MPI by calling MPI_Finalize() when ityr::fini() is called. If MPI is already initialized at this point, Itoyori does not have the responsibility to finalize MPI.

See also
ityr::fini()

◆ inplace_merge() [1/2]

template<typename ExecutionPolicy , typename RandomAccessIterator >
void ityr::inplace_merge ( const ExecutionPolicy &  policy,
RandomAccessIterator  first,
RandomAccessIterator  middle,
RandomAccessIterator  last 
)
inline

Merge two sorted ranges into one sorted range in place.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
middleMiddle iterator that splits the two sorted ranges.
lastEnd iterator.

Equivalent to ityr::inplace_merge(policy, first, middle, last, std::less<>{});

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5};
// v = {1, 1, 2, 2, 3, 3, 4, 4, 5, 5}
void inplace_merge(const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp)
Merge two sorted ranges into one sorted range in place.
Definition: parallel_merge.hpp:273
See also
std::inplace_merge – cppreference.com
ityr::sort()
ityr::stable_sort()
ityr::is_sorted()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ inplace_merge() [2/2]

template<typename ExecutionPolicy , typename RandomAccessIterator , typename Compare >
void ityr::inplace_merge ( const ExecutionPolicy &  policy,
RandomAccessIterator  first,
RandomAccessIterator  middle,
RandomAccessIterator  last,
Compare  comp 
)
inline

Merge two sorted ranges into one sorted range in place.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
middleMiddle iterator that splits the two sorted ranges.
lastEnd iterator.
compBinary comparison operator.

This function merges two sorted ranges ([first, middle) and [middle, last)) into one sorted range ([first, last)) in place. This merge opreration is stable.

If global pointers are provided as iterators, they are automatically checked out with the read-write mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {5, 4, 3, 2, 1, 5, 4, 3, 2, 1};
ityr::inplace_merge(ityr::execution::par, v.begin(), v.begin() + 5, v.end(), std::greater<>{});
// v = {5, 5, 4, 4, 3, 3, 2, 2, 1, 1}
See also
std::inplace_merge – cppreference.com
ityr::sort()
ityr::stable_sort()
ityr::is_sorted()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ is_master()

bool ityr::is_master ( )
inline

Return true if ityr::my_rank() == 0.

See also
ityr::my_rank()

◆ is_root()

bool ityr::is_root ( )
inline

Return true if the current thread is the root thread.

◆ is_sorted() [1/2]

template<typename ExecutionPolicy , typename ForwardIterator >
bool ityr::is_sorted ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last 
)
inline

Check if a range is sorted.

Parameters
policyExecution policy (ityr::execution).
firstInput begin iterator.
lastInput end iterator.
Returns
Returns true if *(first + i + 1) < *(first + i) is false for all i.

Equivalent to is_sorted(policy, first, last, std::less<>{}).

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
// r = true (v is sorted in ascending order)
bool is_sorted(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Compare comp)
Check if a range is sorted.
Definition: parallel_reduce.hpp:1054
See also
std::is_sorted – cppreference.com
ityr::sort()
ityr::stable_sort()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ is_sorted() [2/2]

template<typename ExecutionPolicy , typename ForwardIterator , typename Compare >
bool ityr::is_sorted ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last,
Compare  comp 
)
inline

Check if a range is sorted.

Parameters
policyExecution policy (ityr::execution).
firstInput begin iterator.
lastInput end iterator.
compBinary comparison operator.
Returns
Returns true if comp(*(first + i + 1), *(first + i)) is false for all i.

This function checks if the given range is sorted with respect to the comparison operator comp.

If global pointers are provided as iterators, they are automatically checked out with the read-only mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {5, 4, 3, 2, 1};
bool r = ityr::is_sorted(ityr::execution::par, v.begin(), v.end(), std::greater<>{});
// r = true (v is sorted in descending order)
See also
std::is_sorted – cppreference.com
ityr::sort()
ityr::stable_sort()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ is_spmd()

bool ityr::is_spmd ( )
inline

Return true if the current execution context is within the SPMD region.

◆ make_checkout() [1/2]

template<typename T , typename Mode >
checkout_span<T, Mode> ityr::make_checkout ( global_span< T >  gspan,
Mode  mode 
)
inline

Checkout a global memory region.

Parameters
gspanGlobal span to be checked out.
modeCheckout mode (ityr::checkout_mode).
Returns
The checkout span ityr::checkout_span for the specified range.

Equivalent to ityr::make_checkout(gspan.data(), gspan.size(), mode).

◆ make_checkout() [2/2]

template<typename T , typename Mode >
checkout_span<T, Mode> ityr::make_checkout ( ori::global_ptr< T >  gptr,
std::size_t  n,
Mode  mode 
)
inline

Checkout a global memory region.

Parameters
gptrStarting global pointer.
nNumber of elements to be checked out.
modeCheckout mode (ityr::checkout_mode).
Returns
The checkout span ityr::checkout_span for the specified range.

This function checks out the global memory range [gptr, gptr + n). After this call, this virtual memory region becomes directly accessible by CPU load/store instructions. In programs, it is recommended to access the memory via the returned checkout span.

The checkout mode mode can be either read, read_write, or write.

  • If read or read_write, the checked-out region has the latest data.
  • If read_write or write, the entire checked-out region is considered modified.

The checkout span automatically performs a checkin operation when destroyed (e.g., when exiting the scope). The lifetime of the checkout span cannot overlap with any fork/join call, because threads can be migrated and a pair of checkout and checkin calls must be performed in the same process.

Overlapping regions can be checked out by multiple processes at the same time, as long as no data race occurs (i.e., all regions are checked out with ityr::checkout_mode::read). Within each process, multiple regions can be simultaneously checked out with an arbitrary mode, and the memory ordering to the checked-out region is determined to the program order (because the same memory view is exposed to the process).

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
{
for (int i : cs) {
std::cout << i << " ";
}
std::cout << std::endl;
// automatic checkin when `cs` is destroyed
}
// Output: 1 2 3 4 5
pointer data() noexcept
Definition: global_vector.hpp:225
checkout_span< T, Mode > make_checkout(ori::global_ptr< T > gptr, std::size_t n, Mode mode)
Checkout a global memory region.
Definition: checkout_span.hpp:238
See also
std::span – cppreference.com
ityr::checkout_mode::read, ityr::checkout_mode::read_write, ityr::checkout_mode::write
ityr::make_global_iterator()

◆ make_checkouts()

template<typename... Args>
auto ityr::make_checkouts ( Args &&...  args)
inline

Checkout multiple global memory regions.

Parameters
args...Sequence of checkout requests. Each checkout request should be in the form of <global_ptr>, <num_elems>, <checkout_mode> or <global_span>, <checkout_mode>.
Returns
A tuple collecting the checkout spans for each checkout request.

This function performs multiple checkout operations at the same time. This may improve performance by overlapping communication to fetch remote data, compared to checking out one by one.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
ityr::global_vector<int> v2 = {2, 3, 4, 5, 6};
auto [cs1, cs2, cs3] =
v3.data() + 2, 3, ityr::checkout_mode::write);
Global span to represent a view of a global memory range.
Definition: global_span.hpp:33
auto make_checkouts(Args &&... args)
Checkout multiple global memory regions.
Definition: checkout_span.hpp:311
See also
ityr::make_checkout()

◆ make_construct_iterator() [1/2]

template<typename GlobalIterator >
global_construct_iterator<GlobalIterator> ityr::make_construct_iterator ( GlobalIterator  git)
inline

Make a global iterator for constructing objects.

Parameters
gitGlobal iterator (see ityr::make_global_iterator).
Returns
The global iterator for constructing objects.
See also
ityr::make_global_iterator()
ityr::make_destruct_iterator()

◆ make_construct_iterator() [2/2]

template<typename T >
global_construct_iterator<global_iterator<T, checkout_mode::write_t> > ityr::make_construct_iterator ( ori::global_ptr< T >  gptr)
inline

Make a global iterator for constructing objects.

Parameters
gptrGlobal pointer to be converted to global iterator.
Returns
The global iterator for constructing objects.

This function converts a global pointer to a global iterator for constructing objects. The region will be checked out with the ityr::checkout_mode::write mode. Raw pointers (not references) are returned when iterators are dereferenced.

See also
ityr::make_global_iterator()
ityr::make_destruct_iterator()

◆ make_count_iterator()

template<typename T >
auto ityr::make_count_iterator ( x)
inline

◆ make_destruct_iterator() [1/2]

template<typename GlobalIterator >
global_destruct_iterator<GlobalIterator> ityr::make_destruct_iterator ( GlobalIterator  git)
inline

Make a global iterator for destructing objects.

Parameters
gitGlobal iterator (see ityr::make_global_iterator).
Returns
The global iterator for destructing objects.
See also
ityr::make_global_iterator()
ityr::make_construct_iterator()

◆ make_destruct_iterator() [2/2]

template<typename T >
global_destruct_iterator<global_iterator<T, checkout_mode::read_write_t> > ityr::make_destruct_iterator ( ori::global_ptr< T >  gptr)
inline

Make a global iterator for destructing objects.

Parameters
gptrGlobal pointer to be converted to global iterator.
Returns
The global iterator for destructing objects.

This function converts a global pointer to a global iterator for destructing objects. The region will be checked out with the ityr::checkout_mode::read_write mode. Raw pointers (not references) are returned when iterators are dereferenced.

See also
ityr::make_global_iterator()
ityr::make_construct_iterator()

◆ make_global_iterator()

template<typename T , typename Mode >
global_iterator<T, Mode> ityr::make_global_iterator ( ori::global_ptr< T >  gptr,
Mode   
)
inline

Make a global iterator to enable/disable automatic checkout.

Parameters
gptrGlobal pointer to be converted to global iterator.
modeCheckout mode (ityr::checkout_mode).
Returns
The global iterator (ityr::global_iterator).

This function converts a global pointer to a global iterator to enable/disable automatic checkout. If the checkout mode is read, read_write, or write, these iterators are automatically checked out in iterator-based loop functions (e.g., ityr::for_each()). Some loop functions in which the access mode is clear from definition (e.g., ityr::reduce()) automatically enable automatic checkout. If so, this explicit conversion is not needed.

ityr::checkout_mode::no_access can be speficied to disable automatic checkout, so that iterator-based loop functions (e.g., ityr::transform_reduce()) do not automatically enable automatic checkout. This would be required if parallelism is nested.

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
// vector of vectors {v, v, ..., v} (10 elements)
// Disable automatic checkout in `ityr::transform_reduce()` for nested parallelism
0, std::plus<int>{},
// A global reference is passed to the user function if automatic checkout is disabled
// Checkout each vector explicitly
auto cs = ityr::make_checkout(&v_ref, 1, ityr::checkout_mode::read);
// Get begin/end iterators to data in each vector
auto v_begin = cs[0].begin();
auto v_end = cs[0].end();
// Explicit checkin before making parallel calls
cs.checkin();
// Nested reduction for inner elements
return ityr::reduce(ityr::execution::par, v_begin, v_end);
});
// s = 150
Definition: global_ptr.hpp:173
constexpr no_access_t no_access
Checkout mode to disable automatic checkout.
Definition: checkout_span.hpp:48
Reducer::accumulator_type transform_reduce(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Reducer reducer, UnaryTransformOp unary_transform_op)
Calculate reduction while transforming each element.
Definition: parallel_reduce.hpp:167
See also
ityr::checkout_mode::read, ityr::checkout_mode::read_write, ityr::checkout_mode::write, ityr::checkout_mode::no_access
ityr::for_each()

◆ make_move_iterator() [1/3]

template<typename T , typename Mode >
global_move_iterator<global_iterator<T, Mode> > ityr::make_move_iterator ( global_iterator< T, Mode >  git)
inline

Make a global iterator for moving objects.

Parameters
gitGlobal iterator (ityr::global_iterator).
Returns
The global move iterator (ityr::global_move_iterator).
See also
std::make_move_iterator – cppreference.com
ityr::make_global_iterator()

◆ make_move_iterator() [2/3]

template<typename GlobalIterator >
global_move_iterator<global_reverse_iterator<GlobalIterator> > ityr::make_move_iterator ( global_reverse_iterator< GlobalIterator >  git)
inline

Make a global iterator for moving objects.

Parameters
gitGlobal iterator (ityr::global_reverse_iterator).
Returns
The global move iterator (ityr::global_move_iterator).
See also
std::make_move_iterator – cppreference.com
ityr::make_global_iterator()

◆ make_move_iterator() [3/3]

template<typename T >
global_move_iterator<global_iterator<T, internal::src_checkout_mode_t<T> > > ityr::make_move_iterator ( ori::global_ptr< T >  gptr)
inline

Make a global iterator for moving objects.

Parameters
gptrGlobal pointer to be converted to global iterator.
Returns
The global move iterator (ityr::global_move_iterator).

This function converts a global pointer to a global iterator for moving objects. The region will be checked out with the ityr::checkout_mode::read_write mode. After the region is automatically checked out in generic loops, the raw pointers are wrapped with std::make_move_iterator to force move semantics.

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
// vector of vectors
// `v` is copied to each element of `vv1`
ityr::fill(ityr::execution::par, vv1.begin(), vv1.end(), v);
// Each element of `vv1` is moved to `vv2`
[](ityr::global_vector<int>&& v1, ityr::global_vector<int>& v2) { v2 = std::move(v1); });
// Now `vv2` has valid vector elements, while `vv1` does not
global_move_iterator< global_iterator< T, internal::src_checkout_mode_t< T > > > make_move_iterator(ori::global_ptr< T > gptr)
Make a global iterator for moving objects.
Definition: global_iterator.hpp:258
See also
std::make_move_iterator – cppreference.com
ityr::make_global_iterator()

◆ make_reverse_iterator() [1/3]

template<typename T , typename Mode >
global_reverse_iterator<global_iterator<T, Mode> > ityr::make_reverse_iterator ( global_iterator< T, Mode >  git)
inline

Make a reverse iterator for global memory.

Parameters
gitGlobal iterator (ityr::global_iterator).
Returns
The global reverse iterator (ityr::global_reverse_iterator).
See also
std::make_reverse_iterator – cppreference.com
ityr::make_global_iterator()

◆ make_reverse_iterator() [2/3]

template<typename GlobalIterator >
global_reverse_iterator<global_move_iterator<GlobalIterator> > ityr::make_reverse_iterator ( global_move_iterator< GlobalIterator >  git)
inline

Make a reverse iterator for global memory.

Parameters
gitGlobal iterator (ityr::global_move_iterator).
Returns
The global reverse iterator (ityr::global_reverse_iterator).
See also
std::make_reverse_iterator – cppreference.com
ityr::make_global_iterator()

◆ make_reverse_iterator() [3/3]

template<typename T , typename Mode >
global_reverse_iterator<global_iterator<T, Mode> > ityr::make_reverse_iterator ( ori::global_ptr< T >  gptr,
Mode  mode 
)
inline

Make a reverse iterator for global memory.

Parameters
gptrGlobal pointer to be converted to global iterator.
modeCheckout mode (ityr::checkout_mode).
Returns
The global reverse iterator (ityr::global_reverse_iterator).

This function converts a global pointer to a reverse global iterator with mode.

See also
std::make_reverse_iterator – cppreference.com
ityr::make_global_iterator()

◆ make_unique_file()

template<typename T >
unique_file_ptr<T> ityr::make_unique_file ( const std::string &  fpath,
bool  mlock = false 
)
inline

◆ max_element() [1/2]

template<typename ExecutionPolicy , typename ForwardIterator >
ForwardIterator ityr::max_element ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last 
)
inline

Search for the maximum element in a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
Returns
Iterator to the first maximum element in the range [first, last).

Equivalent to `ityrmax_element(policy, first, last, std::less<>{});

Example:

ityr::global_vector<int> v = {2, 5, 3, 1, 5};
// it = v.begin() + 1, *it = 5
ForwardIterator max_element(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Compare comp)
Search for the maximum element in a range.
Definition: parallel_search.hpp:191
See also
std::max_element – cppreference.com
ityr::min_element()
ityr::minmax_element()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ max_element() [2/2]

template<typename ExecutionPolicy , typename ForwardIterator , typename Compare >
ForwardIterator ityr::max_element ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last,
Compare  comp 
)
inline

Search for the maximum element in a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
compBinary comparison operator. Returns true if the first argument is less than the second argument.
Returns
Iterator to the first maximum element in the range [first, last).

This function returns an iterator to the maximum element in the given range [first, last). If multiple maximum elements exist, the iterator to the first element is returned.

If global pointers are provided as iterators, they are automatically checked out with the read-only mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {2, -5, -3, 1, 5};
[](int x, int y) { return std::abs(x) < std::abs(y); });
// it = v.begin() + 1, *it = -5
See also
std::max_element – cppreference.com
ityr::min_element()
ityr::minmax_element()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ migrate_to()

void ityr::migrate_to ( rank_t  target_rank)
inline

Migrate the current thread to target_rank. For the root thread only.

◆ migrate_to_master()

void ityr::migrate_to_master ( )
inline

Migrate the current thread to the master worker (of rank 0).

◆ min_element() [1/2]

template<typename ExecutionPolicy , typename ForwardIterator >
ForwardIterator ityr::min_element ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last 
)
inline

Search for the minimum element in a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
Returns
Iterator to the first minimum element in the range [first, last).

Equivalent to `ityrmin_element(policy, first, last, std::less<>{});

Example:

ityr::global_vector<int> v = {1, 5, 3, 1, 5};
// it = v.begin(), *it = 1
ForwardIterator min_element(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Compare comp)
Search for the minimum element in a range.
Definition: parallel_search.hpp:88
See also
std::min_element – cppreference.com
ityr::max_element()
ityr::minmax_element()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ min_element() [2/2]

template<typename ExecutionPolicy , typename ForwardIterator , typename Compare >
ForwardIterator ityr::min_element ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last,
Compare  comp 
)
inline

Search for the minimum element in a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
compBinary comparison operator. Returns true if the first argument is less than the second argument.
Returns
Iterator to the first minimum element in the range [first, last).

This function returns an iterator to the minimum element in the given range [first, last). If multiple minimum elements exist, the iterator to the first element is returned.

If global pointers are provided as iterators, they are automatically checked out with the read-only mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {2, -5, -3, 1, 5};
[](int x, int y) { return std::abs(x) < std::abs(y); });
// it = v.begin() + 3, *it = 1
See also
std::min_element – cppreference.com
ityr::max_element()
ityr::minmax_element()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ minmax_element() [1/2]

template<typename ExecutionPolicy , typename ForwardIterator >
std::pair<ForwardIterator, ForwardIterator> ityr::minmax_element ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last 
)
inline

Search for the minimum and maximum element in a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
Returns
Pair of iterators to the first minimum and maximum element in the range [first, last).

Equivalent to `ityrminmax_element(policy, first, last, std::less<>{});

Example:

ityr::global_vector<int> v = {2, 5, 3, 1, 5};
auto [min_it, max_it] = ityr::minmax_element(ityr::execution::par, v.begin(), v.end());
// min_it = v.begin() + 3, *it = 1
// max_it = v.begin() + 1, *it = 5
std::pair< ForwardIterator, ForwardIterator > minmax_element(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Compare comp)
Search for the minimum and maximum element in a range.
Definition: parallel_search.hpp:297
See also
std::minmax_element – cppreference.com
ityr::min_element()
ityr::max_element()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ minmax_element() [2/2]

template<typename ExecutionPolicy , typename ForwardIterator , typename Compare >
std::pair<ForwardIterator, ForwardIterator> ityr::minmax_element ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last,
Compare  comp 
)
inline

Search for the minimum and maximum element in a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
compBinary comparison operator. Returns true if the first argument is less than the second argument.
Returns
Pair of iterators to the first minimum and maximum element in the range [first, last).

This function returns a pair of iterators to the minimum (.first) and maximum (.second) element in the given range [first, last). If multiple minimum/maximum elements exist, the iterator to the first element is returned for each.

If global pointers are provided as iterators, they are automatically checked out with the read-only mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {2, -5, -3, 1, 5};
auto [min_it, max_it] = ityr::minmax_element(ityr::execution::par, v.begin(), v.end(),
[](int x, int y) { return std::abs(x) < std::abs(y); });
// min_it = v.begin() + 3, *it = 1
// max_it = v.begin() + 1, *it = -5
See also
std::minmax_element – cppreference.com
ityr::min_element()
ityr::max_element()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ move()

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD >
ForwardIteratorD ityr::move ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIteratorD  first_d 
)
inline

Move a range to another.

Parameters
policyExecution policy (ityr::execution).
first1Input begin iterator.
last1Input end iterator.
first_dOutput begin iterator.

Equivalent to:

ityr::copy(policy, make_move_iterator(first1), make_move_iterator(last1), first_d);
See also
std::move – cppreference.com
ityr::copy
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ move_backward()

template<typename BidirectionalIterator1 , typename BidirectionalIteratorD >
BidirectionalIteratorD ityr::move_backward ( const execution::sequenced_policy policy,
BidirectionalIterator1  first1,
BidirectionalIterator1  last1,
BidirectionalIteratorD  first_d 
)
inline

◆ my_rank()

rank_t ityr::my_rank ( )
inline

Return the rank of the process running the current thread.

See also
ityr::n_ranks()

◆ n_ranks()

rank_t ityr::n_ranks ( )
inline

Return the total number of processes.

See also
ityr::n_ranks()

◆ operator!=() [1/5]

template<typename T >
bool ityr::operator!= ( const count_iterator< T > &  it1,
const count_iterator< T > &  it2 
)
inline

◆ operator!=() [2/5]

template<typename T >
bool ityr::operator!= ( const global_vector< T > &  x,
const global_vector< T > &  y 
)

◆ operator!=() [3/5]

template<typename T >
bool ityr::operator!= ( const unique_file_ptr< T > &  ufp,
std::nullptr_t   
)
inline

◆ operator!=() [4/5]

template<typename T1 , typename T2 >
bool ityr::operator!= ( const unique_file_ptr< T1 > &  ufp1,
const unique_file_ptr< T2 > &  ufp2 
)
inline

◆ operator!=() [5/5]

template<typename T >
bool ityr::operator!= ( std::nullptr_t  ,
const unique_file_ptr< T > &  ufp 
)
inline

◆ operator<() [1/4]

template<typename T >
bool ityr::operator< ( const count_iterator< T > &  it1,
const count_iterator< T > &  it2 
)
inline

◆ operator<() [2/4]

template<typename T >
bool ityr::operator< ( const unique_file_ptr< T > &  ufp,
std::nullptr_t   
)
inline

◆ operator<() [3/4]

template<typename T1 , typename T2 >
bool ityr::operator< ( const unique_file_ptr< T1 > &  ufp1,
const unique_file_ptr< T2 > &  ufp2 
)
inline

◆ operator<() [4/4]

template<typename T >
bool ityr::operator< ( std::nullptr_t  ,
const unique_file_ptr< T > &  ufp 
)
inline

◆ operator<<()

template<typename CharT , typename Traits , typename T >
std::basic_ostream<CharT, Traits>& ityr::operator<< ( std::basic_ostream< CharT, Traits > &  ostream,
const unique_file_ptr< T > &  ufp 
)
inline

◆ operator<=() [1/4]

template<typename T >
bool ityr::operator<= ( const count_iterator< T > &  it1,
const count_iterator< T > &  it2 
)
inline

◆ operator<=() [2/4]

template<typename T >
bool ityr::operator<= ( const unique_file_ptr< T > &  ufp,
std::nullptr_t   
)
inline

◆ operator<=() [3/4]

template<typename T1 , typename T2 >
bool ityr::operator<= ( const unique_file_ptr< T1 > &  ufp1,
const unique_file_ptr< T2 > &  ufp2 
)
inline

◆ operator<=() [4/4]

template<typename T >
bool ityr::operator<= ( std::nullptr_t  ,
const unique_file_ptr< T > &  ufp 
)
inline

◆ operator==() [1/5]

template<typename T >
bool ityr::operator== ( const count_iterator< T > &  it1,
const count_iterator< T > &  it2 
)
inline

◆ operator==() [2/5]

template<typename T >
bool ityr::operator== ( const global_vector< T > &  x,
const global_vector< T > &  y 
)

◆ operator==() [3/5]

template<typename T >
bool ityr::operator== ( const unique_file_ptr< T > &  ufp,
std::nullptr_t   
)
inline

◆ operator==() [4/5]

template<typename T1 , typename T2 >
bool ityr::operator== ( const unique_file_ptr< T1 > &  ufp1,
const unique_file_ptr< T2 > &  ufp2 
)
inline

◆ operator==() [5/5]

template<typename T >
bool ityr::operator== ( std::nullptr_t  ,
const unique_file_ptr< T > &  ufp 
)
inline

◆ operator>() [1/4]

template<typename T >
bool ityr::operator> ( const count_iterator< T > &  it1,
const count_iterator< T > &  it2 
)
inline

◆ operator>() [2/4]

template<typename T >
bool ityr::operator> ( const unique_file_ptr< T > &  ufp,
std::nullptr_t   
)
inline

◆ operator>() [3/4]

template<typename T1 , typename T2 >
bool ityr::operator> ( const unique_file_ptr< T1 > &  ufp1,
const unique_file_ptr< T2 > &  ufp2 
)
inline

◆ operator>() [4/4]

template<typename T >
bool ityr::operator> ( std::nullptr_t  ,
const unique_file_ptr< T > &  ufp 
)
inline

◆ operator>=() [1/4]

template<typename T >
bool ityr::operator>= ( const count_iterator< T > &  it1,
const count_iterator< T > &  it2 
)
inline

◆ operator>=() [2/4]

template<typename T >
bool ityr::operator>= ( const unique_file_ptr< T > &  ufp,
std::nullptr_t   
)
inline

◆ operator>=() [3/4]

template<typename T1 , typename T2 >
bool ityr::operator>= ( const unique_file_ptr< T1 > &  ufp1,
const unique_file_ptr< T2 > &  ufp2 
)
inline

◆ operator>=() [4/4]

template<typename T >
bool ityr::operator>= ( std::nullptr_t  ,
const unique_file_ptr< T > &  ufp 
)
inline

◆ parallel_invoke()

template<typename... Args>
auto ityr::parallel_invoke ( Args &&...  args)
inline

Fork parallel tasks and join them.

Parameters
args...Sequence of function objects and their arguments in the form of fn1, (args1), fn2, (args2), ..., where fn1 is a function object and args1 is a tuple of arguments for fn1, and so on. The tuples of arguments are optional if functions require no argument.
Returns
A tuple collecting the results of each function invocation. For a void function, std::monostate is used as a placeholder.

This function forks parallel tasks given as function objects and joins them at a time. This function blocks the current thread's execution until all of the child tasks are completed.

The executing process can be changed across this function call (due to thread migration).

Example:

[]() { return 1; }, // no argument
[](int x) { return x; }, std::make_tuple(2), // one argument
[](int x, int y) { return x * y; }, std::make_tuple(3, 4), // two arguments
[]() {}, // no return value
std::plus<int>{}, std::make_tuple(5, 6) // a function (not lambda)
);
// returns std::tuple(1, 2, 12, std::monospace{}, 11)
auto parallel_invoke(Args &&... args)
Fork parallel tasks and join them.
Definition: parallel_invoke.hpp:238

◆ partition()

template<typename ExecutionPolicy , typename BidirectionalIterator , typename Predicate >
BidirectionalIterator ityr::partition ( const ExecutionPolicy &  policy,
BidirectionalIterator  first,
BidirectionalIterator  last,
Predicate  pred 
)
inline

Partition elements into two disjoint parts in place.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
predPredicate operator to determine a group.
Returns
Iterator to the partition point (the first element of the second group).

This function partitions the elements in the range [first, last) into two disjoint parts, so that elements with pred(x) == true precede those with pred(x) == false. This partition operation may not be stable (see ityr::stable_partition()).

If global pointers are provided as iterators, they are automatically checked out with the read-write mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
[](int x) { return x % 2 == 0; });
// v = {2, 4, 1, 3, 5}
// ^
// it
BidirectionalIterator partition(const ExecutionPolicy &policy, BidirectionalIterator first, BidirectionalIterator last, Predicate pred)
Partition elements into two disjoint parts in place.
Definition: parallel_filter.hpp:247
See also
std::partition – cppreference.com
ityr::stable_partition()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ print_compile_options()

void ityr::print_compile_options ( )
inline

Print the compile-time options to stdout.

See also
ityr::print_runtime_options().

◆ print_runtime_options()

void ityr::print_runtime_options ( )
inline

Print the runtime options to stdout.

See also
ityr::print_compile_options().

◆ profiler_begin()

void ityr::profiler_begin ( )
inline

Start the profiler (collective).

See also
ityr::profiler_end().
ityr::profiler_flush().

◆ profiler_end()

void ityr::profiler_end ( )
inline

Stop the profiler (collective).

See also
ityr::profiler_begin().
ityr::profiler_flush().

◆ profiler_flush()

void ityr::profiler_flush ( )
inline

Print the profiled results to stdout (collective).

See also
ityr::profiler_begin().
ityr::profiler_end().

◆ reduce() [1/2]

template<typename ExecutionPolicy , typename ForwardIterator >
std::iterator_traits<ForwardIterator>::value_type ityr::reduce ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last 
)
inline

Calculate reduction.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
Returns
The reduced result.

Equivalent to ityr::reduce(policy, first, last, ityr::reducer::plus<T>{}), where type T is the value type of given iterators (ForwardIterator).

◆ reduce() [2/2]

template<typename ExecutionPolicy , typename ForwardIterator , typename Reducer >
Reducer::accumulator_type ityr::reduce ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last,
Reducer  reducer 
)
inline

Calculate reduction.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
reducerReducer object (ityr::reducer).
Returns
The reduced result.

This function performs reduction over the elements in the given range [first, last).

If global pointers are provided as iterators, they are automatically checked out with the read-only mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Itoyori's reduce operation resembles the standard std::reduce(), but it differs from the standard one in that ityr::reduce() receives a reducer. A reducer offers an associative binary operator that satisfies op(x, op(y, z)) == op(op(x, y), z), and an identity element that satisfies op(identity, x) = x and op(x, identity) = x. Note that commucativity is not required unlike the standard std::reduce().

TODO: How to define a reducer is to be documented.

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
// product = 120
Reducer::accumulator_type reduce(const ExecutionPolicy &policy, ForwardIterator first, ForwardIterator last, Reducer reducer)
Calculate reduction.
Definition: parallel_reduce.hpp:340
See also
std::reduce – cppreference.com
ityr::transform_reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ reverse()

template<typename ExecutionPolicy , typename BidirectionalIterator >
void ityr::reverse ( const ExecutionPolicy &  policy,
BidirectionalIterator  first,
BidirectionalIterator  last 
)
inline

Reverse a range.

Parameters
policyExecution policy (ityr::execution).
firstInput begin iterator.
lastInput end iterator.

This function reverses the input region [first1, last1) (in-place).

If given iterators are global pointers, they are automatically checked out in the read-write mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
// v = {5, 4, 3, 2, 1}
void reverse(const ExecutionPolicy &policy, BidirectionalIterator first, BidirectionalIterator last)
Reverse a range.
Definition: parallel_loop.hpp:1014
See also
std::reverse – cppreference.com
ityr::reverse_copy()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ reverse_copy()

template<typename ExecutionPolicy , typename BidirectionalIterator1 , typename BidirectionalIteratorD >
BidirectionalIteratorD ityr::reverse_copy ( const ExecutionPolicy &  policy,
BidirectionalIterator1  first1,
BidirectionalIterator1  last1,
BidirectionalIteratorD  first_d 
)
inline

Copy a reversed range to another.

Parameters
policyExecution policy (ityr::execution).
first1Input begin iterator.
last1Input end iterator.
first_dOutput begin iterator.

Equivalent to:

ityr::copy(policy, make_reverse_iterator(last1), make_reverse_iterator(first1), first_d);
global_reverse_iterator< global_iterator< T, Mode > > make_reverse_iterator(ori::global_ptr< T > gptr, Mode mode)
Make a reverse iterator for global memory.
Definition: global_iterator.hpp:333
See also
std::reverse_copy – cppreference.com
ityr::reverse()
ityr::copy()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ root_exec()

template<typename Fn , typename... Args>
auto ityr::root_exec ( Fn &&  fn,
Args &&...  args 
)
inline

Spawn the root thread (collective).

Parameters
fnFunction object to be called by the root thread.
args...Argments to be passed to fn (optional).
Returns
The return value of the root thread function fn(args...).

This function switches from the SPMD region to the root thread executing fn(args...). This function must be called by all processes collectively (i.e., in the SPMD region). This function returns when the root thread is completed and its return value is broadcasted to all processes.

The root thread is created and started by the master process (of rank 0), but it is not guaranteed to be continuously executed by the master process, because it can be migrated to other processes at fork/join calls.

Example:

int main() {
// SPMD region
// Only one root thread is spawned globally
});
// returns when the root thread is completed
// SPMD region
}
void fini()
Finalize Itoyori (collective).
Definition: ityr.hpp:84
void init(MPI_Comm comm=MPI_COMM_WORLD)
Initialize Itoyori (collective).
Definition: ityr.hpp:69
See also
ityr::coll_exec()

◆ rotate()

template<typename ExecutionPolicy , typename BidirectionalIterator >
BidirectionalIterator ityr::rotate ( const ExecutionPolicy &  policy,
BidirectionalIterator  first,
BidirectionalIterator  middle,
BidirectionalIterator  last 
)
inline

Rotate a range.

Parameters
policyExecution policy (ityr::execution).
firstInput begin iterator.
middleInput iterator to the element that should be placed at the beginning of the range.
lastInput end iterator.
Returns
The iterator to the original first element (first + (last - middle)).

This function performs the left rotation for the given range. The elements in the range are swapped so that the range [first, middle) is placed before the range [middle, last), preserving the original order in each range.

If given iterators are global pointers, they are automatically checked out in the read-write mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
// v = {3, 4, 5, 1, 2}
BidirectionalIterator rotate(const ExecutionPolicy &policy, BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last)
Rotate a range.
Definition: parallel_loop.hpp:1135
See also
std::rotate – cppreference.com
ityr::rotate_copy
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ rotate_copy()

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD >
ForwardIteratorD ityr::rotate_copy ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  middle1,
ForwardIterator1  last1,
ForwardIteratorD  first_d 
)
inline

Copy a rotated range to another.

Parameters
policyExecution policy (ityr::execution).
first1Input begin iterator.
middle1Input iterator to the element that should be placed at the beginning of the output range.
last1Input end iterator.
first_dOutput begin iterator.
Returns
The end iterator of the output range (first_d + (last1 - first1)).

This function copies the left rotation for the input range to the output range..

If given iterators are global pointers, they are automatically checked out in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators. Input global pointers (first1 and last1) are automatically checked out with the read-only mode. if their value type is trivially copyable; otherwise, they are checked out with the read-write mode, even if they are actually not modified. Similarly, output global iterator (first_d) are checked out with the write-only mode if their value type is trivially copyable; otherwise, they are checked out with the read-write mode.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
ityr::rotate_copy(ityr::execution::par, v1.begin(), v1.begin() + 2, v1.end(), v2.begin());
// v2 = {3, 4, 5, 1, 2}
ForwardIteratorD rotate_copy(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 middle1, ForwardIterator1 last1, ForwardIteratorD first_d)
Copy a rotated range to another.
Definition: parallel_loop.hpp:1188
See also
std::rotate_copy – cppreference.com
ityr::rotate
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ shuffle()

template<typename ExecutionPolicy , typename RandomAccessIterator , typename UniformRandomBitGenerator >
void ityr::shuffle ( const ExecutionPolicy &  policy,
RandomAccessIterator  first,
RandomAccessIterator  last,
UniformRandomBitGenerator &&  urbg 
)
inline

Randomly shuffle elements in a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
urbgUniform random bit generator. It needs to be splittable if parallel.

This function randomly shuffles the elements in the input range. Randomness is given by the random number generator urbg.

Although the standard std::shuffle() does not have a parallel variant, ityr::shuffle() can be computed in parallel if a splittable random number generator is provided. A splittable random number generator has a member split() to spawn an apparently independent child stream of random numbers. LXM is a representative splittable random number generator, which was presented in the following paper.

Guy L. Steele Jr. and Sebastiano Vigna. "LXM: better splittable pseudorandom number generators (and almost as fast)" in ACM OOPSLA '21.

For a C++ implementation, see s417-lama/lxm_random. The default random number generator in Itoyori (ityr::default_random_engine) uses LXM.

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
ityr::default_random_engine rng(42); // seed = 42
// v = {1, 2, 5, 4, 3}
void shuffle(const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator last, UniformRandomBitGenerator &&urbg)
Randomly shuffle elements in a range.
Definition: parallel_shuffle.hpp:113
internal::random_engine_dummy default_random_engine
Definition: random.hpp:41
See also
std::shuffle – cppreference.com
ityr::default_random_engine
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ size() [1/2]

template<typename T , typename Mode >
constexpr auto ityr::size ( const checkout_span< T, Mode > &  cs)
inlineconstexprnoexcept

◆ size() [2/2]

template<typename T >
constexpr auto ityr::size ( const global_span< T > &  s)
inlineconstexprnoexcept

◆ sort() [1/2]

template<typename ExecutionPolicy , typename RandomAccessIterator >
void ityr::sort ( const ExecutionPolicy &  policy,
RandomAccessIterator  first,
RandomAccessIterator  last 
)
inline

Sort a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.

Equivalent to ityr::sort(policy, first, last, std::less<>{}).

Example:

ityr::global_vector<int> v = {2, 3, 4, 1, 5};
// v = {1, 2, 3, 4, 5}
void sort(const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator last, Compare comp)
Sort a range.
Definition: parallel_sort.hpp:210
See also
std::sort – cppreference.com
ityr::stable_sort()
ityr::is_sorted()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ sort() [2/2]

template<typename ExecutionPolicy , typename RandomAccessIterator , typename Compare >
void ityr::sort ( const ExecutionPolicy &  policy,
RandomAccessIterator  first,
RandomAccessIterator  last,
Compare  comp 
)
inline

Sort a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.

This function sorts the given range ([first, last)) in place. This sort may not be stable.

If global pointers are provided as iterators, they are automatically checked out with the read-write mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {2, 3, 4, 1, 5};
ityr::sort(ityr::execution::par, v.begin(), v.end(), std::greater<>{});
// v = {5, 4, 3, 2, 1}
See also
std::sort – cppreference.com
ityr::stable_sort()
ityr::is_sorted()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ stable_partition()

template<typename ExecutionPolicy , typename BidirectionalIterator , typename Predicate >
BidirectionalIterator ityr::stable_partition ( const ExecutionPolicy &  policy,
BidirectionalIterator  first,
BidirectionalIterator  last,
Predicate  pred 
)
inline

Partition elements into two disjoint parts in place.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
predPredicate operator to determine a group.
Returns
Iterator to the partition point (the first element of the second group).

This function partitions the elements in the range [first, last) into two disjoint parts, so that elements with pred(x) == true precede those with pred(x) == false. This partition operation is stable, meaning that the original order of elements is preserved in each group.

If global pointers are provided as iterators, they are automatically checked out with the read-write mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {1, 2, 3, 4, 5};
[](int x) { return x % 2 == 0; });
// v = {2, 4, 1, 3, 5}
// ^
// it
BidirectionalIterator stable_partition(const ExecutionPolicy &policy, BidirectionalIterator first, BidirectionalIterator last, Predicate pred)
Partition elements into two disjoint parts in place.
Definition: parallel_filter.hpp:76
See also
std::stable_partition – cppreference.com
ityr::partition()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ stable_sort() [1/2]

template<typename ExecutionPolicy , typename RandomAccessIterator >
void ityr::stable_sort ( const ExecutionPolicy &  policy,
RandomAccessIterator  first,
RandomAccessIterator  last 
)
inline

Stable sort for a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.

Equivalent to ityr::stable_sort(policy, first, last, std::less<>{}).

See also
std::stable_sort – cppreference.com
ityr::sort()
ityr::inplace_merge()
ityr::is_sorted()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ stable_sort() [2/2]

template<typename ExecutionPolicy , typename RandomAccessIterator , typename Compare >
void ityr::stable_sort ( const ExecutionPolicy &  policy,
RandomAccessIterator  first,
RandomAccessIterator  last,
Compare  comp 
)
inline

Stable sort for a range.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
compBinary comparison operator.

This function sorts the given range ([first, last)) in place. This sort is stable.

If global pointers are provided as iterators, they are automatically checked out with the read-write mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v = {2, 13, 4, 14, 15};
[](int a, int b) { return a / 10 < b / 10; });
// v = {2, 4, 13, 14, 15}
void stable_sort(const ExecutionPolicy &policy, RandomAccessIterator first, RandomAccessIterator last, Compare comp)
Stable sort for a range.
Definition: parallel_sort.hpp:71
See also
std::stable_sort – cppreference.com
ityr::sort()
ityr::inplace_merge()
ityr::is_sorted()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ swap() [1/2]

template<typename T >
void ityr::swap ( global_vector< T > &  v1,
global_vector< T > &  v2 
)
inlinenoexcept

◆ swap() [2/2]

template<typename T >
void ityr::swap ( unique_file_ptr< T >  ufp1,
unique_file_ptr< T >  ufp2 
)
inline

◆ transform() [1/2]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename ForwardIteratorD , typename BinaryOp >
ForwardIteratorD ityr::transform ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIteratorD  first_d,
BinaryOp  binary_op 
)
inline

Transform elements in given ranges and store them in another range.

Parameters
policyExecution policy (ityr::execution).
first11st input begin iterator.
last11st input end iterator.
first22nd input begin iterator.
first_dOutput begin iterator (output).
binary_opBinary operator to transform a pair of each element.
Returns
The end iterator of the output range (first_d + (last1 - first1)).

This function applies binary_op to a pair of each element in the range [first1, last1) and [first2, (last1 - first1)), and the result is stored to the output range [first_d, first_d + (last1 - first1)). The element order is preserved, and this operation corresponds to the higher-order map function. This function resembles the standard std::transform.

If given iterators are global pointers, they are automatically checked out in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators. Input global pointers (first1, last1, and first2) are automatically checked out with the read-only mode. Similarly, output global iterator (first_d) are checked out with the write-only mode if their value type is trivially copyable; otherwise, they are checked out with the read-write mode.

Overlapping regions can be specified for the input and output ranges.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
ityr::global_vector<int> v2 = {2, 3, 4, 5, 6};
ityr::transform(ityr::execution::par, v1.begin(), v1.end(), v2.begin(), v3.begin(),
[](int x, int y) { return x * y; });
// v3 = {2, 6, 12, 20, 30}
ForwardIteratorD transform(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d, UnaryOp unary_op)
Transform elements in a given range and store them in another range.
Definition: parallel_loop.hpp:583
See also
std::transform – cppreference.com
ityr::transform_reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ transform() [2/2]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD , typename UnaryOp >
ForwardIteratorD ityr::transform ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIteratorD  first_d,
UnaryOp  unary_op 
)
inline

Transform elements in a given range and store them in another range.

Parameters
policyExecution policy (ityr::execution).
first1Input begin iterator.
last1Input end iterator.
first_dOutput begin iterator.
unary_opUnary operator to transform each element.
Returns
The end iterator of the output range (first_d + (last1 - first1)).

This function applies unary_op to each element in the range [first1, last1) and stores the result to the output range [first_d, first_d + (last1 - first1)). The element order is preserved, and this operation corresponds to the higher-order map function. This function resembles the standard std::transform.

If given iterators are global pointers, they are automatically checked out in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators. Input global pointers (first1 and last1) are automatically checked out with the read-only mode. Similarly, output global iterator (first_d) are checked out with the write-only mode if their value type is trivially copyable; otherwise, they are checked out with the read-write mode.

Overlapping regions can be specified for the input and output ranges.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
[](int x) { return x * x; });
// v2 = {1, 4, 9, 16, 25}
See also
std::transform – cppreference.com
ityr::transform_reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ transform_inclusive_scan() [1/2]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD , typename Reducer , typename UnaryTransformOp >
ForwardIteratorD ityr::transform_inclusive_scan ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIteratorD  first_d,
Reducer  reducer,
UnaryTransformOp  unary_transform_op 
)
inline

Calculate a prefix sum (inclusive scan) while transforming each element.

Parameters
policyExecution policy (ityr::execution).
first1Input begin iterator.
last1Input end iterator.
first_dOutput begin iterator.
reducerReducer object (ityr::reducer).
unary_transform_opUnary operator to transform each element.
Returns
The end iterator of the output range (first_d + (last1 - first1)).

Equivalent to ityr::transform_inclusive_reduce(policy, first1, last1, first_d, reducer, unary_transform_op, reducer()).

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
ityr::reducer::multiplies<double>{}, [](int x) { return 0.1 * x; });
// v2 = {0.1, 0.02, 0.006, 0.0024, 0.0012}
ForwardIteratorD transform_inclusive_scan(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d, Reducer reducer, UnaryTransformOp unary_transform_op, typename Reducer::accumulator_type &&init)
Calculate a prefix sum (inclusive scan) while transforming each element.
Definition: parallel_reduce.hpp:574
See also
std::transform_inclusive_scan – cppreference.com
ityr::inclusive_scan()
ityr::reduce()
ityr::transform()
ityr::transform_reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ transform_inclusive_scan() [2/2]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIteratorD , typename Reducer , typename UnaryTransformOp >
ForwardIteratorD ityr::transform_inclusive_scan ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIteratorD  first_d,
Reducer  reducer,
UnaryTransformOp  unary_transform_op,
typename Reducer::accumulator_type &&  init 
)
inline

Calculate a prefix sum (inclusive scan) while transforming each element.

Parameters
policyExecution policy (ityr::execution).
first1Input begin iterator.
last1Input end iterator.
first_dOutput begin iterator.
reducerReducer object (ityr::reducer).
unary_transform_opUnary operator to transform each element.
initInitial value for the prefix sum.
Returns
The end iterator of the output range (first_d + (last1 - first1)).

This function applies unary_transform_op to each element in the range [first1, last1) and calculates a prefix sum over them. The prefix sum is inclusive, which means that the i-th element of the prefix sum includes the i-th element in the input range. That is, the i-th element of the prefix sum is: init + f(*first1) + ... + f(*(first1 + i)), where + is the associative binary operator (provided by reducer) and f() is the transform operator (unary_transform_op). The calculated prefix sum is stored in the output range [first_d, first_d + (last1 - first1)).

If given iterators are global pointers, they are automatically checked out in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators. Input global pointers (first1 and last1) are automatically checked out with the read-only mode. Similarly, output global iterator (first_d) are checked out with the write-only mode if their value type is trivially copyable; otherwise, they are checked out with the read-write mode.

Overlapping regions can be specified for the input and output ranges.

Unlike the standard std::transform_inclusive_scan(), Itoyori's ityr::transform_inclusive_scan() requires a reducer as ityr::reduce() does.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
[](int x) { return static_cast<double>(x); }, 0.01);
// v2 = {0.01, 0.02, 0.06, 0.24, 1.2}
See also
std::transform_inclusive_scan – cppreference.com
ityr::inclusive_scan()
ityr::reduce()
ityr::transform()
ityr::transform_reduce()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ transform_reduce() [1/3]

template<typename ExecutionPolicy , typename ForwardIterator , typename Reducer , typename UnaryTransformOp >
Reducer::accumulator_type ityr::transform_reduce ( const ExecutionPolicy &  policy,
ForwardIterator  first,
ForwardIterator  last,
Reducer  reducer,
UnaryTransformOp  unary_transform_op 
)
inline

Calculate reduction while transforming each element.

Parameters
policyExecution policy (ityr::execution).
firstBegin iterator.
lastEnd iterator.
reducerReducer object (ityr::reducer).
unary_transform_opUnary operator to transform each element.
Returns
The reduced result.

This function applies unary_transform_op to each element in the range [first, last) and performs reduction over them.

If global pointers are provided as iterators, they are automatically checked out with the read-only mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
[](int x) { return x * x; });
// r = 55
See also
std::transform_reduce – cppreference.com
ityr::reduce()
ityr::transform()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ transform_reduce() [2/3]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 >
auto ityr::transform_reduce ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2 
)
inline

Calculate a dot product.

Parameters
policyExecution policy (ityr::execution).
first11st begin iterator.
last11st end iterator.
first22nd begin iterator.
Returns
The reduced result.

Equivalent to ityr::transform_reduce(policy, first1, last1, first2, ityr::reducer::plus<T>{}, std::multiplies<>{}), where T is the type of the expression (*first1) * (*first2). This corresponds to calculating a dot product of two vectors.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
ityr::global_vector<int> v2 = {2, 3, 4, 5, 6};
// dot = 70
See also
std::transform_reduce – cppreference.com
ityr::reduce()
ityr::transform()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

◆ transform_reduce() [3/3]

template<typename ExecutionPolicy , typename ForwardIterator1 , typename ForwardIterator2 , typename Reducer , typename BinaryTransformOp >
Reducer::accumulator_type ityr::transform_reduce ( const ExecutionPolicy &  policy,
ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
Reducer  reducer,
BinaryTransformOp  binary_transform_op 
)
inline

Calculate reduction by transforming each element.

Parameters
policyExecution policy (ityr::execution).
first11st begin iterator.
last11st end iterator.
first22nd begin iterator.
reducerReducer object (ityr::reducer).
binary_transform_opBinary operator to transform a pair of each element.
Returns
The reduced result.

This function applies binary_transform_op to a pair of each element in the range [first1, last1) and [first2, first2 + (last1 - first1)] and performs reduction over them.

If global pointers are provided as iterators, they are automatically checked out with the read-only mode in the specified granularity (ityr::execution::sequenced_policy::checkout_count if serial, or ityr::execution::parallel_policy::checkout_count if parallel) without explicitly passing them as global iterators. The specified regions can be overlapped.

Example:

ityr::global_vector<int> v1 = {1, 2, 3, 4, 5};
bool r = ityr::transform_reduce(ityr::execution::par, v1.begin(), v1.end() - 1, v1.begin() + 1,
ityr::reducer::logical_and{}, [](int x, int y) { return x <= y; });
// r = true (v1 is sorted)
See also
std::transform_reduce – cppreference.com
ityr::reduce()
ityr::transform()
ityr::execution::sequenced_policy, ityr::execution::seq, ityr::execution::parallel_policy, ityr::execution::par

Variable Documentation

◆ is_global_iterator_v

template<typename T >
constexpr bool ityr::is_global_iterator_v = is_global_iterator<T>::value
inlineconstexpr

True if T is a global iterator (ityr::global_iterator).

See also
ityr::make_global_iterator().