1 #ifndef VERTEX_LIST_HPP
2 #define VERTEX_LIST_HPP
6 template<
typename Device,
typename F>
7 int get_starts_and_ends(
int n, F condition, View<bool*, CLayout, HostType>& starts_h, View<bool*, CLayout, HostType>& ends_h){
8 View<bool*, CLayout, Device> starts(
NoInit(
"starts"), n);
9 View<bool*, CLayout, Device> ends(
NoInit(
"ends"), n);
12 View<bool*, CLayout, Device> is_in(
NoInit(
"is_in"), n);
13 Kokkos::parallel_for(
"check_condition", Kokkos::RangePolicy<typename Device::execution_space>(0, n), KOKKOS_LAMBDA(
const int i){
14 is_in(i) = condition(i);
19 Kokkos::parallel_reduce(
"check_condition", Kokkos::RangePolicy<typename Device::execution_space>(0, n), KOKKOS_LAMBDA(
const int i,
int& nranges_l){
43 ends_h = View<bool*, CLayout, HostType>(
NoInit(
"ends"), n);
44 starts_h = View<bool*, CLayout, HostType>(
NoInit(
"starts"), n);
45 Kokkos::deep_copy(ends_h, ends);
46 Kokkos::deep_copy(starts_h, starts);
62 KOKKOS_INLINE_FUNCTION
int size()
const{
67 View<IntegerRange*,CLayout,HostType>
ranges;
82 View<bool*, CLayout, HostType> starts_h;
83 View<bool*, CLayout, HostType> ends_h;
84 int nranges = get_starts_and_ends<DeviceType>(n, condition, starts_h, ends_h);
85 ranges = View<IntegerRange*,CLayout,HostType>(
NoInit(
"ranges"), nranges);
89 for(
int i=0; i<n; i++){
101 VertexList(
const View<int*,CLayout,HostType>& unordered_full_list,
bool one_indexed);
112 for (
int is=0; is<
ranges.size(); is++){
113 if(
ranges(is).is_in_range(i))
return true;
120 KOKKOS_INLINE_FUNCTION
int size()
const{
124 for (
int is=0; is<
ranges.size(); is++){
136 template<
typename DeviceExSpace,
typename F>
137 inline void for_all(
const std::string label, F lambda_func)
const {
139 for (
int is=0; is<
ranges.size(); is++){
144 template<
class Device>
145 void pack_contiguous(
const View<double*, CLayout, Device>& input,
const View<double*, CLayout, Device>& contiguous)
const;
147 template<
class Device>
148 void unpack_contiguous(
const View<double*, CLayout, Device>& contiguous,
const View<double*, CLayout, Device>& output)
const;
154 void batch(
int first_val,
int nvals,
const View<int*, CLayout, HostType>& view)
const;
160 void print(
const std::string& msg)
const;
bool is_contiguous() const
Definition: vertex_list.cpp:273
void pack_contiguous(const View< double *, CLayout, Device > &input, const View< double *, CLayout, Device > &contiguous) const
Definition: vertex_list.cpp:56
KOKKOS_INLINE_FUNCTION bool is_in_range(int i) const
Definition: vertex_list.hpp:58
int start
Definition: vertex_list.hpp:55
int get_starts_and_ends(int n, F condition, View< bool *, CLayout, HostType > &starts_h, View< bool *, CLayout, HostType > &ends_h)
Definition: vertex_list.hpp:7
KOKKOS_INLINE_FUNCTION int size() const
Definition: vertex_list.hpp:120
void unpack_contiguous(const View< double *, CLayout, Device > &contiguous, const View< double *, CLayout, Device > &output) const
Definition: vertex_list.cpp:72
void for_all(const std::string label, F lambda_func) const
Definition: vertex_list.hpp:137
void print(const std::string &msg) const
Definition: vertex_list.cpp:277
VertexList & operator|=(const VertexList &rhs)
Definition: vertex_list.cpp:171
VertexList()
Definition: vertex_list.hpp:71
VertexList operator&(const VertexList &list2) const
Definition: vertex_list.cpp:123
int min() const
Definition: vertex_list.cpp:268
void batch(int first_val, int nvals, const View< int *, CLayout, HostType > &view) const
Definition: vertex_list.cpp:243
Definition: vertex_list.hpp:54
bool is_subset(const VertexList &list2) const
Definition: vertex_list.cpp:288
VertexList(int n, F condition)
Definition: vertex_list.hpp:81
KOKKOS_INLINE_FUNCTION bool is_in_list(int i) const
Definition: vertex_list.hpp:110
View< IntegerRange *, CLayout, HostType > ranges
Definition: vertex_list.hpp:67
int end
Definition: vertex_list.hpp:56
Definition: vertex_list.hpp:53
void parallel_for(const std::string name, int n_ptl, Function func, Option option, HostAoSoA aosoa_h, DeviceAoSoA aosoa_d)
Definition: streamed_parallel_for.hpp:252
KOKKOS_INLINE_FUNCTION int size() const
Definition: vertex_list.hpp:62
Kokkos::ViewAllocateWithoutInitializing NoInit
Definition: space_settings.hpp:68
bool intersects(const VertexList &list2) const
Definition: vertex_list.cpp:116