1#ifndef AMREX_PARTITION_H_
2#define AMREX_PARTITION_H_
3#include <AMReX_Config.H>
18 template <
typename T,
typename F>
21 return Scan::PrefixSum<int> (n,
40 pv2[n-1-(i-s)] = pv[i];
43 Scan::Type::exclusive);
47 void amrex_stable_partition_helper (T* p,
int n2)
55 Gpu::streamSynchronize();
81template <
typename T,
typename F>
86 int tot = detail::amrex_partition_helper(data + beg, v2.
dataPtr(), n, std::forward<F>(f));
110template <
typename T,
typename F>
113 return Partition(data, 0, n, std::forward<F>(f));
134template <
typename T,
typename F>
139 int tot = detail::amrex_partition_helper(v.
dataPtr(), v2.
dataPtr(), n, std::forward<F>(f));
166template <
typename T,
typename F>
170 int n2 =
end - beg - n;
171 detail::amrex_stable_partition_helper(data + beg + n, n2);
196template <
typename T,
typename F>
222template <
typename T,
typename F>
225 int n =
Partition(v, std::forward<F>(f));
226 int n2 =
static_cast<int>(v.
size()) - n;
227 detail::amrex_stable_partition_helper(v.
dataPtr() + n, n2);
253template <
typename T,
typename F>
256 auto it = std::partition(data + beg, data +
end, f);
257 return static_cast<int>(std::distance(data + beg, it));
279template <
typename T,
typename F>
282 return Partition(data, 0, n, std::forward<F>(f));
303template <
typename T,
typename F>
304int Partition (Gpu::DeviceVector<T>& v,
F && f)
306 auto it = std::partition(v.begin(), v.end(), f);
307 return static_cast<int>(std::distance(v.begin(), it));
332template <
typename T,
typename F>
335 auto it = std::stable_partition(data + beg, data +
end, f);
336 return static_cast<int>(std::distance(data + beg, it));
360template <
typename T,
typename F>
386template <
typename T,
typename F>
389 auto it = std::stable_partition(v.begin(), v.end(), f);
390 return static_cast<int>(std::distance(v.begin(), it));
#define AMREX_RESTRICT
Definition AMReX_Extension.H:32
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
Dynamically allocated vector for trivially copyable data.
Definition AMReX_PODVector.H:308
size_type size() const noexcept
Definition AMReX_PODVector.H:648
void swap(PODVector< T, Allocator > &a_vector) noexcept
Definition AMReX_PODVector.H:840
iterator begin() noexcept
Definition AMReX_PODVector.H:674
iterator end() noexcept
Definition AMReX_PODVector.H:678
T * dataPtr() noexcept
Definition AMReX_PODVector.H:670
void copy(HostToDevice, InIter begin, InIter end, OutIter result) noexcept
A host-to-device copy routine. Note this is just a wrapper around memcpy, so it assumes contiguous st...
Definition AMReX_GpuContainers.H:128
static constexpr DeviceToDevice deviceToDevice
Definition AMReX_GpuContainers.H:107
Definition AMReX_Amr.cpp:49
__host__ __device__ void Swap(T &t1, T &t2) noexcept
Definition AMReX_Algorithm.H:75
std::enable_if_t< std::is_integral_v< T > > ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:193
int Partition(T *data, int beg, int end, F &&f)
A GPU-capable partition function for contiguous data.
Definition AMReX_Partition.H:82
int StablePartition(T *data, int beg, int end, F &&f)
A GPU-capable partition function for contiguous data.
Definition AMReX_Partition.H:167
__host__ __device__ Dim3 end(BoxND< dim > const &box) noexcept
Definition AMReX_Box.H:2015