Skip to content

Commit

Permalink
RXMesh v0.2.0 (#3)
Browse files Browse the repository at this point in the history
**Highlights:**
- Eliminate global index space and identify mesh elements using the combination of their patch index and their local index within the patch
- All query operation no longer needs to map their output to global index space
- Allocating `Attributes` per-patch basis instead of a single large array 
- Introduce `Vertex/Edge/FaceHandle` to improve type safety which is used to identify different mesh element and index the mesh `Attributes`
- Introduce `LocalVertex/Edge/FaceT` to improve type safety for internal implementation of local index space 
- `Attributes` are now managed by `RXMeshStatic` using `add_vertex/edge/face_attribute()` API
- Introduce `for_each_vertex/edge/face()` API in `RXMeshStatic` for simple operations on the mesh that do not require query operations (i.e., map operations) for both CUDA and OpenMP backend
- Introduce `ReduceHandle` to do reduction operations on `Attribute` and so reduction operation temp memory is no longer handle by `Attribute` itself 
- Improve the documentation for most of the user-facing APIs
- Removing code related to shuffling and sorting the input mesh (it was only relevant to reproduce SIGGRAPH paper results) 
- Accurately report the register usage and static shared memory used by the kernel by using the (pointer to) kernel itself instead of the prototype function 
- Improve initializing the data structure by removing duplicate supporting structure that were created by both `RXMesh` and `Patcher` and by using OpenMP when possible in `RXMesh`

**Known Issues:**
- Some queries (VE, VF, and higher queries) now require more registers per thread and thus they might fail on some (less powerful) GPUs. 

Co-authored-by: Ahmed Mahmoud <[email protected]>
  • Loading branch information
Ahdhn and Ahdhn authored Jan 5, 2022
1 parent 4b74907 commit 19c7937
Show file tree
Hide file tree
Showing 92 changed files with 7,197 additions and 7,752 deletions.
4 changes: 3 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ BasedOnStyle: Chromium
TabWidth: 4
UseTab: Never

AlignConsecutiveAssignments: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: true
AlignTrailingComments: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeTernaryOperators: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
Cpp11BracedListStyle: true
IndentCaseLabels: true
IndentWidth: 4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Ubuntu
on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]
jobs:
UbuntuRun:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Windows.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Windows
on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]
jobs:
WindowsRun:
runs-on: windows-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
output/
input/
build/
include/rxmesh/util/git_sha1.cpp
.vscode/
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)

if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
cmake_policy(SET CMP0104 OLD)
endif()

project(RXMesh
VERSION 0.1.0
VERSION 0.2.0
LANGUAGES C CXX CUDA)

set(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -86,15 +86,16 @@ target_sources(RXMesh_header_lib

# CUDA and C++ compiler flags
set(cxx_flags
$<$<CXX_COMPILER_ID:MSVC>:-D_SCL_SECURE_NO_WARNINGS /openmp /std:c++17> #Add MSVC-specific compiler flags here
$<$<CXX_COMPILER_ID:GNU>:-Wall -m64 -fopenmp -O3 -std=c++17> #Add GCC/Clang-specific compiler flags here
$<$<CXX_COMPILER_ID:MSVC>:-D_SCL_SECURE_NO_WARNINGS /openmp /std:c++17> #Add MSVC-specific compiler flags here
$<$<CXX_COMPILER_ID:GNU>:-Wall -m64 -fopenmp -O3 -std=c++17 -Wno-unused-function> #Add GCC/Clang-specific compiler flags here
)
set(cuda_flags
-Xcompiler=$<$<CXX_COMPILER_ID:GNU>:-Wall -fopenmp -O3>
-Xcompiler=$<$<CXX_COMPILER_ID:GNU>:-Wall -fopenmp -O3 -Wno-unused-function>
#Disables warning
#177-D "function XXX was declared but never referenced"
-Xcudafe "--display_error_number --diag_suppress=177"
${CUDA_ARCHS}
-rdc=true
-lineinfo
--expt-extended-lambda
-use_fast_math
Expand All @@ -111,7 +112,6 @@ target_compile_options(developer_flags INTERFACE
$<$<COMPILE_LANGUAGE:CUDA>:${cuda_flags}>
)


target_link_libraries(RXMesh_header_lib INTERFACE $<BUILD_INTERFACE:developer_flags>)

#OpenMP
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 2-Clause License

Copyright (c) 2021, owensgroup
Copyright (c) 2022, owensgroup
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 2 additions & 0 deletions apps/Filtering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ endif()

set_target_properties(Filtering PROPERTIES FOLDER "apps")

set_property(TARGET Filtering PROPERTY CUDA_SEPARABLE_COMPILATION ON)

source_group(TREE ${CMAKE_CURRENT_LIST_DIR} PREFIX "Filtering" FILES ${SOURCE_LIST})

target_link_libraries(Filtering
Expand Down
5 changes: 2 additions & 3 deletions apps/Filtering/benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
echo "This script re-generates RXMesh data in Figure 8(c) in the paper."
echo "Please make sure to first compile the source code and then enter the input OBJ files directory."
read -p "OBJ files directory (no trailing slash): " input_dir

Expand All @@ -16,7 +15,7 @@ device_id=0

for file in $input_dir/*.obj; do
if [ -f "$file" ]; then
echo $exe -p -input "$file" -num_filter_iter 5 -device_id $device_id
$exe -p -input "$file" -num_filter_iter 5 -device_id $device_id
echo $exe -input "$file" -num_filter_iter 5 -device_id $device_id
$exe -input "$file" -num_filter_iter 5 -device_id $device_id
fi
done
67 changes: 16 additions & 51 deletions apps/Filtering/filtering.cu
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,22 @@

struct arg
{
std::string obj_file_name = STRINGIFY(INPUT_DIR) "sphere3.obj";
std::string output_folder = STRINGIFY(OUTPUT_DIR);
uint32_t device_id = 0;
std::string obj_file_name = STRINGIFY(INPUT_DIR) "sphere3.obj";
std::string output_folder = STRINGIFY(OUTPUT_DIR);
uint32_t device_id = 0;
uint32_t num_filter_iter = 5;
char** argv;
int argc;
bool shuffle = false;
bool sort = false;

} Arg;

#include "filtering_openmesh.h"
#include "filtering_rxmesh.cuh"

TEST(App, Filtering)
{
using namespace RXMESH;
using namespace rxmesh;
using dataT = float;


if (Arg.shuffle) {
ASSERT_FALSE(Arg.sort) << " cannot shuffle and sort at the same time!";
}
if (Arg.sort) {
ASSERT_FALSE(Arg.shuffle)
<< " cannot shuffle and sort at the same time!";
}

// Select device
cuda_query(Arg.device_id);

Expand All @@ -50,42 +38,27 @@ TEST(App, Filtering)
std::vector<std::vector<dataT>> Verts;
ASSERT_TRUE(import_obj(Arg.obj_file_name, Verts, Faces));

if (Arg.shuffle) {
shuffle_obj(Faces, Verts);
}

// Create RXMeshStatic instance. If Arg.sort is true, Faces and Verts will
// be sorted based on the patching happening inside RXMesh
RXMeshStatic<PATCH_SIZE> rxmesh_static(Faces, Verts, Arg.sort, false);
TriMesh input_mesh;
ASSERT_TRUE(OpenMesh::IO::read_mesh(input_mesh, Arg.obj_file_name));

ASSERT_EQ(input_mesh.n_vertices(), Verts.size());

// Since OpenMesh only accepts input as obj files, if the input mesh is
// shuffled or sorted, we have to write it to a temp file so that OpenMesh
// can pick it up
TriMesh input_mesh;
if (Arg.sort || Arg.shuffle) {
export_obj(Faces, Verts, "temp.obj", false);
ASSERT_TRUE(OpenMesh::IO::read_mesh(input_mesh, "temp.obj"));
} else {
ASSERT_TRUE(OpenMesh::IO::read_mesh(input_mesh, Arg.obj_file_name));
}
// OpenMesh Impl
std::vector<std::vector<dataT>> ground_truth(Verts);
size_t max_neighbour_size = 0;
filtering_openmesh(
omp_get_max_threads(), input_mesh, ground_truth, max_neighbour_size);

//*** OpenMesh Impl
RXMESH::RXMeshAttribute<dataT> ground_truth;
size_t max_neighbour_size = 0;
filtering_openmesh(omp_get_max_threads(), input_mesh, ground_truth, max_neighbour_size);


//*** RXMesh Impl
filtering_rxmesh(rxmesh_static, Verts, ground_truth, max_neighbour_size);
// RXMesh Impl
filtering_rxmesh(Faces, Verts, ground_truth, max_neighbour_size);

// Release allocation
ground_truth.release();
}

int main(int argc, char** argv)
{
using namespace RXMESH;
using namespace rxmesh;
Log::init();

::testing::InitGoogleTest(&argc, argv);
Expand All @@ -101,9 +74,7 @@ int main(int argc, char** argv)
" Default is {} \n"
" Hint: Only accepts OBJ files\n"
" -o: JSON file output folder. Default is {} \n"
" -num_filter_iter: Iteration count. Default is {} \n"
" -s: Shuffle input. Default is false.\n"
" -p: Sort input using patching output. Default is false.\n"
" -num_filter_iter: Iteration count. Default is {} \n"
" -device_id: GPU device ID. Default is {}",
Arg.obj_file_name, Arg.output_folder ,Arg.num_filter_iter ,Arg.device_id);
// clang-format on
Expand All @@ -123,12 +94,6 @@ int main(int argc, char** argv)
Arg.output_folder =
std::string(get_cmd_option(argv, argv + argc, "-o"));
}
if (cmd_option_exists(argv, argc + argv, "-s")) {
Arg.shuffle = true;
}
if (cmd_option_exists(argv, argc + argv, "-p")) {
Arg.sort = true;
}
if (cmd_option_exists(argv, argc + argv, "-device_id")) {
Arg.device_id =
atoi(get_cmd_option(argv, argv + argc, "-device_id"));
Expand Down
Loading

0 comments on commit 19c7937

Please sign in to comment.