Skip to content

Commit

Permalink
update remeshing app
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahdhn committed Jan 13, 2025
1 parent 185fbfb commit 3b4a7c5
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 74 deletions.
48 changes: 25 additions & 23 deletions apps/Remesh/collapse.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -516,20 +516,20 @@ inline void collapse_short_edges(rxmesh::RXMeshDynamic& rx,
int prv_remaining_work = rx.get_num_edges();

LaunchBox<blockThreads> lb;
rx.prepare_launch_box({Op::EVDiamond, Op::VV},
lb,
(void*)edge_collapse_1<T, blockThreads>,
true,
false,
false,
false,
[&](uint32_t v, uint32_t e, uint32_t f) {
return detail::mask_num_bytes(e) +
2 * v * sizeof(uint16_t) +
2 * ShmemAllocator::default_alignment;
// 2 * detail::mask_num_bytes(v) +
// 3 * ShmemAllocator::default_alignment;
});
rx.update_launch_box({Op::EVDiamond, Op::VV},
lb,
(void*)edge_collapse_1<T, blockThreads>,
true,
false,
false,
false,
[&](uint32_t v, uint32_t e, uint32_t f) {
return detail::mask_num_bytes(e) +
2 * v * sizeof(uint16_t) +
2 * ShmemAllocator::default_alignment;
// 2 * detail::mask_num_bytes(v) +
// 3 * ShmemAllocator::default_alignment;
});


int num_outer_iter = 0;
Expand Down Expand Up @@ -574,6 +574,7 @@ inline void collapse_short_edges(rxmesh::RXMeshDynamic& rx,
rx.cleanup();
timers.stop("CollapseCleanup");

#ifdef USE_POLYSCOPE
bool show = false;
if (show) {

Expand All @@ -596,6 +597,7 @@ inline void collapse_short_edges(rxmesh::RXMeshDynamic& rx,

polyscope::show();
}
#endif
}

int remaining_work = is_done(rx, edge_status, d_buffer);
Expand All @@ -608,13 +610,13 @@ inline void collapse_short_edges(rxmesh::RXMeshDynamic& rx,
timers.stop("CollapseTotal");

// RXMESH_INFO("total num_collapses {}", num_collapses);
RXMESH_INFO("num_outer_iter {}", num_outer_iter);
RXMESH_INFO("num_inner_iter {}", num_inner_iter);
RXMESH_INFO("Collapse total time {} (ms)",
timers.elapsed_millis("CollapseTotal"));
RXMESH_INFO("Collapse time {} (ms)", timers.elapsed_millis("Collapse"));
RXMESH_INFO("Collapse slice time {} (ms)",
timers.elapsed_millis("CollapseSlice"));
RXMESH_INFO("Collapse cleanup time {} (ms)",
timers.elapsed_millis("CollapseCleanup"));
// RXMESH_INFO("num_outer_iter {}", num_outer_iter);
// RXMESH_INFO("num_inner_iter {}", num_inner_iter);
// RXMESH_INFO("Collapse total time {} (ms)",
// timers.elapsed_millis("CollapseTotal"));
// RXMESH_INFO("Collapse time {} (ms)", timers.elapsed_millis("Collapse"));
// RXMESH_INFO("Collapse slice time {} (ms)",
// timers.elapsed_millis("CollapseSlice"));
// RXMESH_INFO("Collapse cleanup time {} (ms)",
// timers.elapsed_millis("CollapseCleanup"));
}
45 changes: 23 additions & 22 deletions apps/Remesh/flip.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -406,21 +406,21 @@ inline void equalize_valences(rxmesh::RXMeshDynamic& rx,
LaunchBox<blockThreads> lb_flip;


rx.prepare_launch_box({Op::EVDiamond, Op::VV},
lb_flip,
//(void*)edge_flip<T, blockThreads>,
(void*)edge_flip_1<T, blockThreads>,
true,
false,
false,
false,
[&](uint32_t v, uint32_t e, uint32_t f) {
return detail::mask_num_bytes(e) +
2 * v * sizeof(uint16_t) +
2 * ShmemAllocator::default_alignment;
// 2 * detail::mask_num_bytes(v) +
// 3 * ShmemAllocator::default_alignment;
});
rx.update_launch_box({Op::EVDiamond, Op::VV},
lb_flip,
//(void*)edge_flip<T, blockThreads>,
(void*)edge_flip_1<T, blockThreads>,
true,
false,
false,
false,
[&](uint32_t v, uint32_t e, uint32_t f) {
return detail::mask_num_bytes(e) +
2 * v * sizeof(uint16_t) +
2 * ShmemAllocator::default_alignment;
// 2 * detail::mask_num_bytes(v) +
// 3 * ShmemAllocator::default_alignment;
});

edge_status->reset(UNSEEN, DEVICE);

Expand Down Expand Up @@ -482,11 +482,12 @@ inline void equalize_valences(rxmesh::RXMeshDynamic& rx,
timers.stop("FlipTotal");

// RXMESH_INFO("total num_flips {}", num_flips);
RXMESH_INFO("num_outer_iter {}", num_outer_iter);
RXMESH_INFO("num_inner_iter {}", num_inner_iter);
RXMESH_INFO("Flip total time {} (ms)", timers.elapsed_millis("FlipTotal"));
RXMESH_INFO("Flip time {} (ms)", timers.elapsed_millis("Flip"));
RXMESH_INFO("Flip slice time {} (ms)", timers.elapsed_millis("FlipSlice"));
RXMESH_INFO("Flip cleanup time {} (ms)",
timers.elapsed_millis("FlipCleanup"));
// RXMESH_INFO("num_outer_iter {}", num_outer_iter);
// RXMESH_INFO("num_inner_iter {}", num_inner_iter);
// RXMESH_INFO("Flip total time {} (ms)",
// timers.elapsed_millis("FlipTotal")); RXMESH_INFO("Flip time {} (ms)",
// timers.elapsed_millis("Flip")); RXMESH_INFO("Flip slice time {} (ms)",
// timers.elapsed_millis("FlipSlice")); RXMESH_INFO("Flip cleanup time {}
// (ms)",
// timers.elapsed_millis("FlipCleanup"));
}
2 changes: 1 addition & 1 deletion apps/Remesh/remesh.cu
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TEST(Apps, Remesh)
// rx.add_vertex_coordinates(verts, "Coords");


RXMeshDynamic rx(Arg.obj_file_name);
RXMeshDynamic rx(Arg.obj_file_name, "", 256, 4.0, 2);
// rx.save(STRINGIFY(OUTPUT_DIR) + extract_file_name(Arg.obj_file_name) +
// "_patches");

Expand Down
12 changes: 6 additions & 6 deletions apps/Remesh/remesh_rxmesh.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ inline void remesh_rxmesh(rxmesh::RXMeshDynamic& rx)

timers.start("Total");
for (uint32_t iter = 0; iter < Arg.num_iter; ++iter) {
RXMESH_INFO(" Edge Split -- iter {}", iter);
// RXMESH_INFO(" Edge Split -- iter {}", iter);
split_long_edges(rx,
coords.get(),
edge_status.get(),
Expand All @@ -309,7 +309,7 @@ inline void remesh_rxmesh(rxmesh::RXMeshDynamic& rx)
timers,
d_buffer);

RXMESH_INFO(" Edge Collapse -- iter {}", iter);
// RXMESH_INFO(" Edge Collapse -- iter {}", iter);
collapse_short_edges(rx,
coords.get(),
edge_status.get(),
Expand All @@ -321,7 +321,7 @@ inline void remesh_rxmesh(rxmesh::RXMeshDynamic& rx)
d_buffer);


RXMESH_INFO(" Edge Flip -- iter {}", iter);
// RXMESH_INFO(" Edge Flip -- iter {}", iter);
equalize_valences(rx,
coords.get(),
v_valence.get(),
Expand All @@ -331,7 +331,7 @@ inline void remesh_rxmesh(rxmesh::RXMeshDynamic& rx)
timers,
d_buffer);

RXMESH_INFO(" Vertex Smoothing -- iter {}", iter);
// RXMESH_INFO(" Vertex Smoothing -- iter {}", iter);
tangential_relaxation(rx,
coords.get(),
new_coords.get(),
Expand Down Expand Up @@ -400,8 +400,8 @@ inline void remesh_rxmesh(rxmesh::RXMeshDynamic& rx)
report.add_member("smoothing_time_ms",
timers.elapsed_millis("SmoothTotal"));

EXPECT_TRUE(rx.validate());
// rx.export_obj("remesh.obj", *coords);
// EXPECT_TRUE(rx.validate());
// rx.export_obj("remesh.obj", *coords);

#if USE_POLYSCOPE
rx.update_polyscope();
Expand Down
2 changes: 1 addition & 1 deletion apps/Remesh/smoothing.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,5 @@ inline void tangential_relaxation(rxmesh::RXMeshDynamic& rx,
}
timers.stop("SmoothTotal");

RXMESH_INFO("Relax time {} (ms)", timers.elapsed_millis("SmoothTotal"));
// RXMESH_INFO("Relax time {} (ms)", timers.elapsed_millis("SmoothTotal"));
}
40 changes: 20 additions & 20 deletions apps/Remesh/split.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,17 @@ inline void split_long_edges(rxmesh::RXMeshDynamic& rx,
int num_inner_iter = 0;

LaunchBox<blockThreads> lb;
rx.prepare_launch_box({Op::EVDiamond},
lb,
(void*)edge_split<T, blockThreads>,
true,
false,
false,
false,
[&](uint32_t v, uint32_t e, uint32_t f) {
return detail::mask_num_bytes(e) +
ShmemAllocator::default_alignment;
});
rx.update_launch_box({Op::EVDiamond},
lb,
(void*)edge_split<T, blockThreads>,
true,
false,
false,
false,
[&](uint32_t v, uint32_t e, uint32_t f) {
return detail::mask_num_bytes(e) +
ShmemAllocator::default_alignment;
});

timers.start("SplitTotal");

Expand Down Expand Up @@ -374,13 +374,13 @@ inline void split_long_edges(rxmesh::RXMeshDynamic& rx,
// " "max_f_lf={},", min_v_lf, max_v_lf, min_e_lf, max_e_lf, min_f_lf,
// max_f_lf);

RXMESH_INFO("num_outer_iter {}", num_outer_iter);
RXMESH_INFO("num_inner_iter {}", num_inner_iter);
RXMESH_INFO("Split total time {} (ms)",
timers.elapsed_millis("SplitTotal"));
RXMESH_INFO("Split time {} (ms)", timers.elapsed_millis("Split"));
RXMESH_INFO("Split slice time {} (ms)",
timers.elapsed_millis("SplitSlice"));
RXMESH_INFO("Split cleanup time {} (ms)",
timers.elapsed_millis("SplitCleanup"));
// RXMESH_INFO("num_outer_iter {}", num_outer_iter);
// RXMESH_INFO("num_inner_iter {}", num_inner_iter);
// RXMESH_INFO("Split total time {} (ms)",
// timers.elapsed_millis("SplitTotal"));
// RXMESH_INFO("Split time {} (ms)", timers.elapsed_millis("Split"));
// RXMESH_INFO("Split slice time {} (ms)",
// timers.elapsed_millis("SplitSlice"));
// RXMESH_INFO("Split cleanup time {} (ms)",
// timers.elapsed_millis("SplitCleanup"));
}
2 changes: 1 addition & 1 deletion apps/SECHistogram/sec.cu
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ TEST(Apps, SEC)
// Select device
cuda_query(Arg.device_id);

RXMeshDynamic rx(Arg.obj_file_name);
RXMeshDynamic rx(Arg.obj_file_name, "", 256, 3.5, 1.5);

// const std::string p_file = STRINGIFY(OUTPUT_DIR) +
// extract_file_name(Arg.obj_file_name) +
Expand Down
4 changes: 4 additions & 0 deletions apps/SurfaceTracking/tracking_rxmesh.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ __global__ void ckeck_kernel_ev(const rxmesh::Context context,
template <typename T>
void check(rxmesh::RXMeshDynamic& rx, rxmesh::VertexAttribute<T>& position)
{
#if USE_POLYSCOPE

using namespace rxmesh;

Expand Down Expand Up @@ -194,13 +195,15 @@ void check(rxmesh::RXMeshDynamic& rx, rxmesh::VertexAttribute<T>& position)
launch_box.smem_bytes_dyn>>>(rx.get_context(), position, *v_err);
CUDA_ERROR(cudaDeviceSynchronize());
viz();
#endif
}

template <typename T, typename U>
void check2(rxmesh::RXMeshDynamic& rx,
rxmesh::VertexAttribute<T>& v_attr,
rxmesh::VertexAttribute<U>& position)
{
#if USE_POLYSCOPE
using namespace rxmesh;

rx.update_host();
Expand Down Expand Up @@ -238,6 +241,7 @@ void check2(rxmesh::RXMeshDynamic& rx,
polyscope::show();
ps_mesh->setEnabled(false);
}
#endif
}

template <typename T>
Expand Down

0 comments on commit 3b4a7c5

Please sign in to comment.