Skip to content

Commit

Permalink
Merge branch 'dev' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
larc committed Mar 25, 2024
2 parents 0f367f4 + fccd82a commit 0100f16
Show file tree
Hide file tree
Showing 39 changed files with 336 additions and 330 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on: [push]

env:
CUDA_BIN: /usr/local/cuda/bin
CC: gcc-12
CXX: g++-12
CUDAHOSTCXX: g++-12

jobs:
build:
Expand Down Expand Up @@ -33,6 +36,7 @@ jobs:
libglew-dev \
libglfw3-dev \
cimg-dev \
g++-12 \
wget
wget http://mirrors.kernel.org/ubuntu/pool/universe/f/flann/libflann-dev_1.9.2+dfsg-1_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/f/flann/libflann1.9_1.9.2+dfsg-1_amd64.deb
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ finally execute:

./gproshan [mesh_paths.(off,obj,ply)]

### Dependencies (Linux)
g++ >= 9.4, cuda >= 11.8, cmake >= 3.24, armadillo, eigen3, cgal, suitesparse, openblas, glew, glfw3, cimg, gnuplot, embree >= 3.13

In Ubuntu you can install them with:
### Dependencies (Linux/MacOS)
g++ >= 12.3, cuda >= 12.4, cmake >= 3.28, embree >= 4.3, glew, glfw3, armadillo, suitesparse, openblas, flann, cimg

On Ubuntu you can install them with:

sudo apt install cmake libglew-dev libglfw3-dev libarmadillo-dev libsuitesparse-dev libopenblas-dev libflann-dev cimg-dev

Install Cuda if available to enable Cuda-based modules.
Export environment variable `OptiX_INSTALL_DIR` with the path to the OptiX library to enable it.

sudo apt install cmake libarmadillo-dev libeigen3-dev libcgal-dev libsuitesparse-dev libopenblas-dev libglew-dev libglfw3-dev cimg-dev gnuplot

#### Installing Intel Embree

Expand Down
2 changes: 1 addition & 1 deletion cmake/FindOptiX.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down
22 changes: 11 additions & 11 deletions cmake/FindSuiteSparse.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## CMake file to locate SuiteSparse and its useful composite projects
## The first developpement of this file was made fro Windows users who
## use:
## The first development of this file was done by Windows users who
## used:
## https://github.com/jlblancoc/suitesparse-metis-for-windows
## Anyway, it chould be work also on linux (tested on fedora 17 when you installed suitesparse from yum)
## Anyway, it could work also on linux (tested on fedora 17 when you installed suitesparse from yum)
##
##
## Inputs variables this file can process (variable must be given before find_package(SUITESPARES ...) command) :
Expand All @@ -11,7 +11,7 @@
## Note: SuiteSparse lib usually requires linking to a blas and lapack library.
##
##
## Help variables this file handle internaly :
## Help variables this file handle internally :
## * SuiteSparse_SEARCH_LIB_POSTFIX Is set in cache (as advanced) to look into the right lib/lib64 dir for libraries (user can change)
##
##
Expand All @@ -20,19 +20,19 @@
## * SuiteSparse_INCLUDE_DIRS Paths containing SuiteSparse needed headers (depend on which COMPONENTS you gave)
## * SuiteSparse_LIBRARIES Absolute paths of SuiteSparse libs found (depend on which COMPONENTS you gave)
## If SuiteSparse_USE_LAPACK_BLAS is set to ON :
## * SuiteSparse_LAPACK_BLAS_LIBRARIES Which contain the libblas and liblapack libraries
## * SuiteSparse_LAPACK_BLAS_LIBRARIES Which contain the libblas and liblapack libraries
## On windows:
## * SuiteSparse_LAPACK_BLAS_DLL Which contain all requiered binaries for use libblas and liblapack
## * SuiteSparse_LAPACK_BLAS_DLL Which contain all required binaries for use libblas and liblapack
##
##
## Detailed variables this file provide :
## * SuiteSparse_<UPPPER_CASE_COMPONENT>_FOUND True if the given component to look for is found (INCLUDE DIR and LIBRARY)
## * SuiteSparse_<UPPPER_CASE_COMPONENT>_INCLUDE_DIR The path directory where we can found all compenent header files
## * SuiteSparse_<UPPPER_CASE_COMPONENT>_INCLUDE_DIR The path directory where all component header files can be found
## * SuiteSparse_<UPPPER_CASE_COMPONENT>_LIBRARY The file path to the component library
## Note: If a component is not found, a SuiteSparse_<UPPPER_CASE_COMPONENT>_DIR cache variable is set to allow user set the search directory.
##
##
## Possible componnents to find are (maybe some others can be available):
## Possible components to find are (maybe some others can be available):
## * AMD
## * CAMD
## * COLAMD
Expand Down Expand Up @@ -125,13 +125,13 @@ endif()
## we can use a generic way to find all of these with simple cmake lines of code
macro(SuiteSparse_FIND_COMPONENTS )

## On windows : we absolutly need SuiteSparse_config.h every time for all projects
## On windows : we absolutely need SuiteSparse_config.h every time for all projects
if(WIN32)
list(FIND SuiteSparse_FIND_COMPONENTS "suitesparseconfig" SS_config_index)
if(${SS_config_index} MATCHES "-1")
list(APPEND SuiteSparse_FIND_COMPONENTS suitesparseconfig)
if(SuiteSparse_VERBOSE)
message(STATUS " On windows, we absolutly need SuiteSparse_config.h every time for all projects : add suitesparseconfig component to look for")
message(STATUS " On windows, we absolutely need SuiteSparse_config.h every time for all projects : add suitesparseconfig component to look for")
endif()
endif()
endif()
Expand Down Expand Up @@ -292,7 +292,7 @@ macro(SuiteSparse_FIND_COMPONENTS )
endif()
if(NOT ${componentToCheck})
set(SuiteSparse_FOUND OFF)
break() ## one component not found is enought to failed
break() ## one component not found is enough to failed
endif()
endforeach()
endmacro()
Expand Down
2 changes: 2 additions & 0 deletions gproshanConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

include(CMakeFindDependencyMacro)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")

find_package(CUDAToolkit 12)

find_dependency(embree 4)
Expand Down
11 changes: 6 additions & 5 deletions include/gproshan/features/descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#define DESCRIPTOR_H

#include <gproshan/mesh/che.h>
#include <gproshan/include_arma.h>

#include <armadillo>


// geometry processing and shape analysis framework
Expand All @@ -15,10 +16,10 @@ class descriptor
enum signature { GPS, HKS, WKS };

private:
a_sp_mat L, A;
a_vec eigval;
a_mat eigvec;
a_mat features;
arma::sp_mat L, A;
arma::vec eigval;
arma::mat eigvec;
arma::mat features;

public:
descriptor(const signature & sig, const che * mesh, const size_t n_eigs);
Expand Down
12 changes: 0 additions & 12 deletions include/gproshan/geodesics/heat_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <gproshan/mesh/che.h>

#include <armadillo>
#include <cholmod.h>


// geometry processing and shape analysis framework
Expand All @@ -31,21 +30,10 @@ double heat_method(real_t * dist, const che * mesh, const std::vector<index_t> &

arma::vec compute_divergence(const che * mesh, const arma::vec & u);

/// cholmod Keenan implementation
/// base on the code https://github.com/larc/dgpdec-course/tree/master/Geodesics
double solve_positive_definite(arma::mat & x, const arma::sp_mat & A, const arma::mat & b, cholmod_common * context);

cholmod_dense * arma_2_cholmod(const arma::mat & m, cholmod_common * context);

cholmod_sparse * arma_2_cholmod(const arma::sp_mat & m, cholmod_common * context);

#ifdef GPROSHAN_CUDA

///
double solve_positive_definite_gpu(arma::mat & x, const arma::sp_mat & A, const arma::mat & b);

/// host and device support
/// https://docs.nvidia.com/cuda/cusolver/index.html#cusolver-lt-t-gt-csrlsvchol
double solve_positive_definite_cusolver(const int m, const int nnz, const double * hA_values, const int * hA_col_ptrs, const int * hA_row_indices, const double * hb, double * hx, const bool host = 0);

#endif // GPROSHAN_CUDA
Expand Down
50 changes: 38 additions & 12 deletions include/gproshan/geometry/mat.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include <gproshan/geometry/vec.h>

#ifndef __CUDACC__
#include <armadillo>
#endif // __CUDACC__


// geometry processing and shape analysis framework
namespace gproshan {
Expand Down Expand Up @@ -73,26 +77,34 @@ class mat
}

__host_device__
static mat<T, N> identity()
mat<T, N> t() const
{
mat<T, N> res;
for(index_t i = 0; i < N; ++i)
res[i][i] = 1;
return res;
return transpose(*this);
}

__host_device__
static mat<T, N> transpose(const mat<T, N> & m)
static mat<T, N> identity()
{
mat<T, N> res;
for(index_t i = 0; i < N; ++i)
for(index_t j = 0; j < N; ++j)
res[i][j] = m[j][i];
res[i][i] = 1;
return res;
}
};

///< std std::ostream

template<class T, size_t N>
__host_device__
mat<T, N> transpose(const mat<T, N> & m)
{
mat<T, N> res;
for(index_t i = 0; i < N; ++i)
for(index_t j = 0; j < N; ++j)
res[i][j] = m[j][i];
return res;
}


template<class T, size_t N>
std::ostream & operator << (std::ostream & os, const mat<T, N> & m)
{
Expand All @@ -101,7 +113,6 @@ std::ostream & operator << (std::ostream & os, const mat<T, N> & m)
return os;
}

///< std std::istream
template<class T, size_t N>
std::istream & operator >> (std::istream & is, mat<T, N> & m)
{
Expand All @@ -111,12 +122,27 @@ std::istream & operator >> (std::istream & is, mat<T, N> & m)
}


#ifndef __CUDACC__
template<class T, size_t N>
mat<T, N> inverse(const mat<T, N> & m)
{
mat<T, N> inv;
mat<T, N> mt = m.t();

arma::Mat<T> ainv((T *) &inv, N, N, false, true);
arma::Mat<T> amt((T *) &mt, N, N, false, true);

arma::inv(ainv, amt);

return inv.t();
}
#endif // __CUDACC__


using mat2 = mat<real_t, 2>;
using mat3 = mat<real_t, 3>;
using mat4 = mat<real_t, 4>;

mat4 inverse(const mat4 & m);


} // namespace gproshan

Expand Down
34 changes: 0 additions & 34 deletions include/gproshan/include_arma.h

This file was deleted.

13 changes: 7 additions & 6 deletions include/gproshan/mdict/basis.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#define BASIS_H

#include <gproshan/include.h>
#include <gproshan/include_arma.h>

#include <fstream>

#include <armadillo>


// geometry processing and shape analysis framework
// mesh dictionary learning and sparse coding namespace
Expand All @@ -21,18 +22,18 @@ class basis
public:
basis(const real_t r, const size_t d);
virtual ~basis() = default;
virtual void discrete(a_mat & phi, const a_vec & x, const a_vec & y) = 0;
virtual void d_discrete(a_mat & phi, const a_vec & x, const a_vec & y, const bool b) = 0;
virtual void discrete(arma::fmat & phi, const arma::fvec & x, const arma::fvec & y) = 0;
virtual void d_discrete(arma::fmat & phi, const arma::fvec & x, const arma::fvec & y, const bool b) = 0;
virtual real_t freq(const index_t idx) = 0;
real_t & radio();
size_t dim() const;
void plot_basis();
void plot_atoms(const a_mat & A);
void plot_patch(const a_mat & A, const a_mat & xyz, const index_t p);
void plot_atoms(const arma::fmat & A);
void plot_patch(const arma::fmat & A, const arma::fmat & xyz, const index_t p);

private:
virtual void plot_basis(std::ostream & os) = 0;
virtual void plot_atoms(std::ostream & os, const a_vec & A) = 0;
virtual void plot_atoms(std::ostream & os, const arma::fvec & A) = 0;
};


Expand Down
6 changes: 3 additions & 3 deletions include/gproshan/mdict/basis_cosine.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class basis_cosine: public basis

public:
basis_cosine(const size_t nr, const size_t nf, const real_t r = 0);
void discrete(a_mat & phi, const a_vec & x, const a_vec & y);
void discrete(arma::fmat & phi, const arma::fvec & x, const arma::fvec & y);

private:
void plot_basis(std::ostream & os);
void plot_atoms(std::ostream & os, const a_vec & A);
a_vec cosine(const a_vec & x, const a_vec & y, const real_t c, const real_t alpha);
void plot_atoms(std::ostream & os, const arma::fvec & A);
arma::fvec cosine(const arma::fvec & x, const arma::fvec & y, const real_t c, const real_t alpha);
void cosine(std::ostream & os, const real_t c, const real_t alpha);
};

Expand Down
10 changes: 5 additions & 5 deletions include/gproshan/mdict/basis_dct.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class basis_dct: public basis

public:
basis_dct(const size_t n, const real_t r = 1);
void discrete(a_mat & phi, const a_vec & x, const a_vec & y);
void d_discrete(a_mat & phi, const a_vec & x, const a_vec & y, const bool b);
void discrete(arma::fmat & phi, const arma::fvec & x, const arma::fvec & y);
void d_discrete(arma::fmat & phi, const arma::fvec & x, const arma::fvec & y, const bool b);
real_t freq(const index_t idx);

private:
void plot_basis(std::ostream & os);
void plot_atoms(std::ostream & os, const a_vec & A);
a_vec dct(const a_vec & x, const a_vec & y, const index_t nx, const index_t ny);
a_vec d_dct(const a_vec & x, const a_vec & y, const index_t nx, const index_t ny);
void plot_atoms(std::ostream & os, const arma::fvec & A);
arma::fvec dct(const arma::fvec & x, const arma::fvec & y, const index_t nx, const index_t ny);
arma::fvec d_dct(const arma::fvec & x, const arma::fvec & y, const index_t nx, const index_t ny);
void dct(std::ostream & os, const index_t nx, const index_t ny);
};

Expand Down
Loading

0 comments on commit 0100f16

Please sign in to comment.