Skip to content

Commit

Permalink
use enum class instead of static device values
Browse files Browse the repository at this point in the history
  • Loading branch information
trxcllnt committed Feb 1, 2023
1 parent 57a7a1e commit a7fc335
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cpp/include/cuspatial/experimental/detail/join/intersection.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
namespace cuspatial {
namespace detail {

static __device__ uint8_t const leaf_indicator = 0;
static __device__ uint8_t const quad_indicator = 1;
static __device__ uint8_t const none_indicator = 2;
enum class quadtree_node_indicator : uint8_t {
leaf, ///<
quad, ///<
none, ///<
};

template <typename InputIterator, typename OutputIterator>
inline int32_t copy_leaf_intersections(InputIterator input_begin,
Expand All @@ -50,7 +52,7 @@ inline int32_t copy_leaf_intersections(InputIterator input_begin,
output_begin,
thrust::copy_if(
rmm::exec_policy(stream), input_begin, input_end, output_begin, [] __device__(auto const& t) {
return thrust::get<0>(t) == leaf_indicator;
return thrust::get<0>(t) == static_cast<uint8_t>(quadtree_node_indicator::leaf);
}));
}

Expand All @@ -64,7 +66,7 @@ inline int32_t remove_non_quad_intersections(InputIterator input_begin,
output_begin,
thrust::remove_if(
rmm::exec_policy(stream), input_begin, input_end, output_begin, [] __device__(auto const& t) {
return thrust::get<0>(t) != quad_indicator;
return thrust::get<0>(t) != static_cast<uint8_t>(quadtree_node_indicator::quad);
}));
}

Expand Down Expand Up @@ -128,7 +130,8 @@ inline std::pair<int32_t, int32_t> find_intersections(KeyIterator keys_first,
if ((node_x_min > poly_x_max) || (node_x_max < poly_x_min) || (node_y_min > poly_y_max) ||
(node_y_max < poly_y_min)) {
// if no overlap, return type = none_indicator
return thrust::make_tuple(none_indicator, level, node_idx, bbox_idx);
return thrust::make_tuple(
static_cast<uint8_t>(quadtree_node_indicator::none), level, node_idx, bbox_idx);
}
// otherwise return type = leaf_indicator (0) or quad_indicator (1)
return thrust::make_tuple(is_internal_node, level, node_idx, bbox_idx);
Expand Down

0 comments on commit a7fc335

Please sign in to comment.