Skip to content

Commit

Permalink
speedup unit test compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahdhn committed Sep 23, 2024
1 parent ee69403 commit 6542975
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 81 deletions.
34 changes: 17 additions & 17 deletions tests/RXMesh_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
add_executable( RXMesh_test )

set( SOURCE_LIST
rxmesh_test_main.cu
rxmesh_test_main.cu
rxmesh_test.h
test_attribute.cuh
test_attribute.cu
test_util.cu
test_iterator.cu
test_queries.h
test_queries_oriented.h
test_higher_queries.h
test_queries_oriented.cu
test_higher_queries.cu
query_kernel.cuh
higher_query.cuh
test_for_each.cuh
test_validate.h
test_lp_pair.h
test_dynamic.cuh
test_ev_diamond.h
test_sparse_matrix.cuh
test_for_each.cu
test_validate.cu
test_lp_pair.cu
test_dynamic.cu
test_ev_diamond.cu
test_sparse_matrix.cu
test_patch_lock.cuh
test_patch_scheduler.cuh
test_patch_slicing.cuh
test_multi_queries.cuh
test_patch_slicing.cu
test_multi_queries.cu
test_wasted_work.cuh
test_eigen.cuh
test_boundary.cuh
test_dense_matrix.cuh
test_export.cuh
test_svd.cuh
test_eigen.cu
test_boundary.cu
test_dense_matrix.cu
test_export.cu
test_svd.cu
test_scalar.cu
)

Expand Down
22 changes: 2 additions & 20 deletions tests/RXMesh_test/rxmesh_test_main.cu
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#include <vector>
#include "gtest/gtest.h"
#include "rxmesh/util/cuda_query.h"
#include "rxmesh/util/log.h"
#include "rxmesh/util/report.h"
#include "rxmesh/util/cuda_query.h"

using dataT = float;

struct RXMeshTestArg
{
Expand All @@ -17,26 +15,10 @@ struct RXMeshTestArg
} rxmesh_args;

// clang-format off
#include "test_higher_queries.h"
#include "test_queries.h"
#include "test_queries_oriented.h"
#include "test_attribute.cuh"
#include "test_for_each.cuh"
#include "test_validate.h"
#include "test_lp_pair.h"
#include "test_dynamic.cuh"
#include "test_ev_diamond.h"
#include "test_sparse_matrix.cuh"
#include "test_patch_lock.cuh"
#include "test_patch_scheduler.cuh"
#include "test_patch_slicing.cuh"
#include "test_multi_queries.cuh"
#include "test_patch_lock.cuh"
#include "test_wasted_work.cuh"
#include "test_eigen.cuh"
#include "test_boundary.cuh"
#include "test_dense_matrix.cuh"
#include "test_export.cuh"
#include "test_svd.cuh"
// clang-format on

int main(int argc, char** argv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "rxmesh/attribute.h"
#include "rxmesh/reduce_handle.h"
#include "rxmesh/util/macros.h"
#include "rxmesh/rxmesh_static.h"

template <typename T>
void populate(rxmesh::RXMeshStatic& rx, rxmesh::VertexAttribute<T>& v, T val)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TEST(RXMeshStatic, DISABLED_HigherQueries)
using namespace rxmesh;


std::vector<std::vector<dataT>> Verts;
std::vector<std::vector<float>> Verts;
std::vector<std::vector<uint32_t>> Faces;
ASSERT_TRUE(import_obj(STRINGIFY(INPUT_DIR) "sphere3.obj", Verts, Faces));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "gtest/gtest.h"

#include "rxmesh/lp_hashtable.cuh"
#include "rxmesh/lp_pair.cuh"
#include "rxmesh/util/util.h"

TEST(RXMesh, LPPair)
{
Expand Down Expand Up @@ -76,7 +78,7 @@ TEST(RXMesh, LPHashTable)
TEST(RXMesh, DISABLED_BenchmarkLPHashTable)
{
using namespace rxmesh;

const float load_factor = 0.9;
const uint32_t low_size = 128;
const uint32_t high_size = 2048;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TEST(RXMeshStatic, MultiQueries)
using namespace rxmesh;
constexpr uint32_t blockThreads = 320;

RXMeshStatic rx(rxmesh_args.obj_file_name);
RXMeshStatic rx(STRINGIFY(INPUT_DIR) "sphere3.obj");

const auto coords = rx.get_input_vertex_coordinates();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ __global__ static void set_patch_should_slice(rxmesh::Context context, int p)
TEST(RXMeshDynamic, PatchSlicing)
{
using namespace rxmesh;

RXMeshDynamic rx(rxmesh_args.obj_file_name,
STRINGIFY(OUTPUT_DIR) +
extract_file_name(rxmesh_args.obj_file_name) +
"_patches");

RXMeshDynamic rx(STRINGIFY(INPUT_DIR) "sphere3.obj");

auto coords = rx.get_input_vertex_coordinates();

Expand Down
6 changes: 3 additions & 3 deletions tests/RXMesh_test/test_queries.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ TEST(RXMeshStatic, Queries)
using namespace rxmesh;

bool oriented = false;
std::vector<std::vector<dataT>> Verts;

std::vector<std::vector<float>> Verts;
std::vector<std::vector<uint32_t>> Faces;

ASSERT_TRUE(import_obj(rxmesh_args.obj_file_name, Verts, Faces));


RXMeshStatic rx(Faces);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TEST(RXMeshStatic, Oriented_VV_Open)
{
using namespace rxmesh;

std::vector<std::vector<dataT>> Verts;
std::vector<std::vector<float>> Verts;
std::vector<std::vector<uint32_t>> Faces;

// This is how the plane.obj looks like
Expand All @@ -39,7 +39,7 @@ TEST(RXMeshStatic, Oriented_VV_Open)
EXPECT_FALSE(rx.is_closed())
<< " Expected input to be open with boundaries";

auto coordinates = rx.add_vertex_attribute<dataT>(Verts, "coordinates");
auto coordinates = rx.add_vertex_attribute<float>(Verts, "coordinates");

// input/output container
auto input = rx.add_vertex_attribute<VertexHandle>("input", 1);
Expand Down Expand Up @@ -76,11 +76,11 @@ TEST(RXMeshStatic, Oriented_VV_Open)
RXMeshTest tester(rx, Faces);
EXPECT_TRUE(tester.run_test(rx, Faces, *input, *output));

auto vector_length = [](const dataT x, const dataT y, const dataT z) {
auto vector_length = [](const float x, const float y, const float z) {
return std::sqrt(x * x + y * y + z * z);
};

auto dot = [](const std::vector<dataT>& u, const std::vector<dataT>& v) {
auto dot = [](const std::vector<float>& u, const std::vector<float>& v) {
return std::inner_product(
std::begin(u), std::end(u), std::begin(v), 0.0);
};
Expand All @@ -90,7 +90,7 @@ TEST(RXMeshStatic, Oriented_VV_Open)
// and the sum angle around it is 360
if (rx.map_to_global(vertex) != 4) {

dataT sum_angles = 0;
float sum_angles = 0;

// 2 since every vertex is connected to three vertices (except
// vertex 4 which is connected to 8 other vertices but we don't
Expand All @@ -104,18 +104,18 @@ TEST(RXMeshStatic, Oriented_VV_Open)

if (v_1.is_valid() && v_0.is_valid()) {

std::vector<dataT> p1{
std::vector<float> p1{
(*coordinates)(vertex, 0) - (*coordinates)(v_0, 0),
(*coordinates)(vertex, 1) - (*coordinates)(v_0, 1),
(*coordinates)(vertex, 2) - (*coordinates)(v_0, 2)};

std::vector<dataT> p2{
std::vector<float> p2{
(*coordinates)(vertex, 0) - (*coordinates)(v_1, 0),
(*coordinates)(vertex, 1) - (*coordinates)(v_1, 1),
(*coordinates)(vertex, 2) - (*coordinates)(v_1, 2)};

dataT dot_pro = dot(p1, p2);
dataT angle = std::acos(
float dot_pro = dot(p1, p2);
float angle = std::acos(
dot_pro / (vector_length(p1[0], p1[1], p1[2]) *
vector_length(p2[0], p2[1], p2[2])));
sum_angles += (angle * 180) / 3.14159265;
Expand All @@ -132,7 +132,7 @@ TEST(RXMeshStatic, Oriented_VV_Closed)
{
using namespace rxmesh;

std::vector<std::vector<dataT>> Verts;
std::vector<std::vector<float>> Verts;
std::vector<std::vector<uint32_t>> Faces;

ASSERT_TRUE(import_obj(STRINGIFY(INPUT_DIR) "cube.obj", Verts, Faces));
Expand All @@ -143,7 +143,7 @@ TEST(RXMeshStatic, Oriented_VV_Closed)
EXPECT_TRUE(rx.is_closed())
<< " Expecting input to be closed without boundaries";

auto coordinates = rx.add_vertex_attribute<dataT>(Verts, "coordinates");
auto coordinates = rx.add_vertex_attribute<float>(Verts, "coordinates");

// input/output container
auto input = rx.add_vertex_attribute<VertexHandle>("input", 1);
Expand Down Expand Up @@ -184,11 +184,11 @@ TEST(RXMeshStatic, Oriented_VV_Closed)
// Make sure orientation is accurate
// for the cube, all angle are either 45 or 90

auto vector_length = [](const dataT x, const dataT y, const dataT z) {
auto vector_length = [](const float x, const float y, const float z) {
return std::sqrt(x * x + y * y + z * z);
};

auto dot = [](const std::vector<dataT>& u, const std::vector<dataT>& v) {
auto dot = [](const std::vector<float>& u, const std::vector<float>& v) {
return std::inner_product(
std::begin(u), std::end(u), std::begin(v), 0.0);
};
Expand All @@ -203,18 +203,18 @@ TEST(RXMeshStatic, Oriented_VV_Closed)

if (v_1.is_valid() && v_0.is_valid()) {

std::vector<dataT> p1{
std::vector<float> p1{
(*coordinates)(vertex, 0) - (*coordinates)(v_0, 0),
(*coordinates)(vertex, 1) - (*coordinates)(v_0, 1),
(*coordinates)(vertex, 2) - (*coordinates)(v_0, 2)};

std::vector<dataT> p2{
std::vector<float> p2{
(*coordinates)(vertex, 0) - (*coordinates)(v_1, 0),
(*coordinates)(vertex, 1) - (*coordinates)(v_1, 1),
(*coordinates)(vertex, 2) - (*coordinates)(v_1, 2)};

dataT dot_pro = dot(p1, p2);
dataT theta =
float dot_pro = dot(p1, p2);
float theta =
std::acos(dot_pro / (vector_length(p1[0], p1[1], p1[2]) *
vector_length(p2[0], p2[1], p2[2])));
theta = (theta * 180) / 3.14159265;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ TEST(RXMeshStatic, SparseMatrix)

using namespace rxmesh;

// generate rxmesh obj
std::string obj_path = STRINGIFY(INPUT_DIR) "dragon.obj";
RXMeshStatic rx(obj_path);
RXMeshStatic rx(STRINGIFY(INPUT_DIR) "dragon.obj");

uint32_t num_vertices = rx.get_num_vertices();

Expand Down Expand Up @@ -201,7 +199,7 @@ TEST(RXMeshStatic, SparseMatrixEdgeLen)


// generate rxmesh obj
RXMeshStatic rx(rxmesh_args.obj_file_name);
RXMeshStatic rx(STRINGIFY(INPUT_DIR) "sphere3.obj");

uint32_t num_vertices = rx.get_num_vertices();

Expand Down Expand Up @@ -268,9 +266,7 @@ TEST(RXMeshStatic, SparseMatrixSimpleSolve)

using namespace rxmesh;

// generate rxmesh obj
std::string obj_path = rxmesh_args.obj_file_name;
RXMeshStatic rx(obj_path);
RXMeshStatic rx(STRINGIFY(INPUT_DIR) "sphere3.obj");

uint32_t num_vertices = rx.get_num_vertices();

Expand Down Expand Up @@ -328,10 +324,7 @@ TEST(RXMeshStatic, SparseMatrixLowerLevelAPISolve)
{
using namespace rxmesh;


// generate rxmesh obj
std::string obj_path = rxmesh_args.obj_file_name;
RXMeshStatic rx(obj_path);
RXMeshStatic rx(STRINGIFY(INPUT_DIR) "sphere3.obj");

uint32_t num_vertices = rx.get_num_vertices();

Expand Down Expand Up @@ -388,9 +381,7 @@ TEST(RXMeshStatic, SparseMatrixToEigen)
{
using namespace rxmesh;

// generate rxmesh obj
std::string obj_path = rxmesh_args.obj_file_name;
RXMeshStatic rx(obj_path);
RXMeshStatic rx(STRINGIFY(INPUT_DIR) "sphere3.obj");

uint32_t num_vertices = rx.get_num_vertices();

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "gtest/gtest.h"

#include "rxmesh/rxmesh_dynamic.h"

TEST(RXMeshDynamic, Validate)
Expand Down
1 change: 0 additions & 1 deletion tests/RXMesh_test/test_wasted_work.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "rxmesh/cavity_manager.cuh"
#include "rxmesh/rxmesh_dynamic.h"

#include "rxmesh/util/report.h"

template <uint32_t blockThreads>
Expand Down

0 comments on commit 6542975

Please sign in to comment.