Skip to content

Commit

Permalink
Few more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed May 2, 2024
1 parent 9e5a3e9 commit 11248d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions benchmarks/triangulated_surface_distance/generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#include <Kokkos_MathematicalConstants.hpp>

#if KOKKOS_VERSION >= 40400
#include <Kokkos_Array.hpp>
using Array = Kokkos::Array;
#include <Kokkos_KokkosArray.hpp>
using KokkosArray = Kokkos::Kokkos;
#else
template <class T, size_t N>
struct Array
struct KokkosArray
{
static constexpr auto size() { return N; }
KOKKOS_FUNCTION constexpr T &operator[](int i) { return _data[i]; }
Expand All @@ -31,7 +31,7 @@ struct Array
};
#endif

static auto icosahedron()
auto icosahedron()
{
auto a = Kokkos::numbers::phi_v<float>;
auto b = 1.f;
Expand All @@ -53,7 +53,7 @@ static auto icosahedron()
vertices.push_back(Point{b, -a, 0});
vertices.push_back(Point{-b, -a, 0});

std::vector<Array<int, 3>> triangles;
std::vector<KokkosArray<int, 3>> triangles;

triangles.push_back({2, 1, 0});
triangles.push_back({1, 2, 3});
Expand All @@ -79,8 +79,8 @@ static auto icosahedron()
return std::make_tuple(vertices, triangles);
}

void convertTriangles2EdgeForm(std::vector<Array<int, 3>> &triangles,
std::vector<Array<int, 2>> &edges)
void convertTriangles2EdgeForm(std::vector<KokkosArray<int, 2>> &edges,
std::vector<KokkosArray<int, 3>> &triangles)
{
std::map<std::pair<int, int>, int> hash;

Expand Down Expand Up @@ -111,8 +111,8 @@ void convertTriangles2EdgeForm(std::vector<Array<int, 3>> &triangles,
template <typename ExecutionSpace, typename MemorySpace>
void convertTriangles2VertexForm(
ExecutionSpace const &space,
Kokkos::View<Array<int, 3> *, MemorySpace> &triangles,
Kokkos::View<Array<int, 2> *, MemorySpace> const &edges)
Kokkos::View<KokkosArray<int, 2> *, MemorySpace> const &edges,
Kokkos::View<KokkosArray<int, 3> *, MemorySpace> &triangles)
{
int const num_triangles = triangles.size();
Kokkos::parallel_for(
Expand Down Expand Up @@ -143,8 +143,8 @@ template <typename ExecutionSpace, typename MemorySpace>
void subdivide(ExecutionSpace const &space,
Kokkos::View<ArborX::ExperimentalHyperGeometry::Point<3> *,
MemorySpace> &vertices,
Kokkos::View<Array<int, 2> *, MemorySpace> &edges,
Kokkos::View<Array<int, 3> *, MemorySpace> &triangles)
Kokkos::View<KokkosArray<int, 2> *, MemorySpace> &edges,
Kokkos::View<KokkosArray<int, 3> *, MemorySpace> &triangles)
{
using Point = ArborX::ExperimentalHyperGeometry::Point<3>;

Expand All @@ -155,7 +155,7 @@ void subdivide(ExecutionSpace const &space,
Kokkos::resize(space, vertices, vertices.size() + edges.size());

// Each edge is split in two, and each triangle adds three internal edges
Kokkos::View<Array<int, 2> *, MemorySpace> new_edges(
Kokkos::View<KokkosArray<int, 2> *, MemorySpace> new_edges(
Kokkos::view_alloc(space, Kokkos::WithoutInitializing,
"Benchmark::edges"),
2 * num_edges + 3 * num_triangles);
Expand All @@ -174,7 +174,7 @@ void subdivide(ExecutionSpace const &space,
new_edges(2 * i + 1) = {w, new_vindex};
});

Kokkos::View<Array<int, 3> *, MemorySpace> new_triangles(
Kokkos::View<KokkosArray<int, 3> *, MemorySpace> new_triangles(
Kokkos::view_alloc(space, Kokkos::WithoutInitializing,
"Benchmark::triangles"),
4 * num_triangles);
Expand Down Expand Up @@ -251,8 +251,8 @@ auto buildTriangles(ExecutionSpace const &space, float radius,
auto [vertices_v, triangles_v] = icosahedron();

// Convert to edge form
std::vector<Array<int, 2>> edges_v;
convertTriangles2EdgeForm(triangles_v, edges_v);
std::vector<KokkosArray<int, 2>> edges_v;
convertTriangles2EdgeForm(edges_v, triangles_v);

auto vertices = vec2view<MemorySpace>(vertices_v);
auto edges = vec2view<MemorySpace>(edges_v);
Expand All @@ -263,7 +263,7 @@ auto buildTriangles(ExecutionSpace const &space, float radius,

projectVerticesToSphere(space, vertices, radius);

convertTriangles2VertexForm(space, triangles, edges);
convertTriangles2VertexForm(space, edges, triangles);

return std::make_pair(vertices, triangles);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ template <typename MemorySpace>
struct Triangles
{
Kokkos::View<Point *, MemorySpace> _points;
Kokkos::View<Array<int, 3> *, MemorySpace> _triangle_vertices;
Kokkos::View<KokkosArray<int, 3> *, MemorySpace> _triangle_vertices;
};

template <typename MemorySpace>
Expand Down

0 comments on commit 11248d1

Please sign in to comment.