diff --git a/Src/Kernels/Chebyshev/FChebSymM2LHandler.hpp b/Src/Kernels/Chebyshev/FChebSymM2LHandler.hpp index b26cfccea8df250201c1445731f47556b96e404d..ebb1709fffd154e612804b5b6e1ea9a9ff55a353 100644 --- a/Src/Kernels/Chebyshev/FChebSymM2LHandler.hpp +++ b/Src/Kernels/Chebyshev/FChebSymM2LHandler.hpp @@ -1,7 +1,12 @@ // See LICENCE file at project root +/** + * @author Matthias Messner (matthias.matthias@inria.fr) + * Please read the license + */ #ifndef FCHEBSYMM2LHANDLER_HPP #define FCHEBSYMM2LHANDLER_HPP + #include <array> #include <climits> #include <sstream> @@ -17,10 +22,7 @@ #include "Utils/FAca.hpp" -/** - * @author Matthias Messner (matthias.matthias@inria.fr) - * Please read the license - */ + /*! Choose either \a FULLY_PIVOTED_ACASVD or \a PARTIALLY_PIVOTED_ACASVD or @@ -40,12 +42,11 @@ template <class FReal, int ORDER, typename MatrixKernelClass, class ArrayK, class ArrayLr> static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal CellWidth, const FReal Epsilon, ArrayK K, ArrayLr LowRank) -// const FReal Epsilon, FReal* K[343], int LowRank[343]) { // std::cout << "\nComputing 16 far-field interactions (l=" << ORDER << ", eps=" << Epsilon // << ") for cells of width w = " << CellWidth << std::endl; - static const unsigned int nnodes = ORDER*ORDER*ORDER; + static constexpr unsigned int nnodes = ORDER*ORDER*ORDER; // interpolation points of source (Y) and target (X) cell FPoint<FReal> X[nnodes], Y[nnodes]; @@ -56,7 +57,7 @@ static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal // needed for the SVD int INFO; - const unsigned int LWORK = 2 * (3*nnodes + nnodes); + constexpr unsigned int LWORK = 2 * (3*nnodes + nnodes); FReal *const WORK = new FReal [LWORK]{}; FReal *const VT = new FReal [nnodes*nnodes]{}; FReal *const S = new FReal [nnodes]{}; @@ -196,13 +197,6 @@ static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal delete [] V; } - //// store recompressed UV - //const unsigned int idx = (i+3)*7*7 + (j+3)*7 + (k+3); - //assert(K[idx]==NULL); - //K[idx] = new FReal [2*rank*nnodes]; - //LowRank[idx] = rank; - //FBlas::copy(rank*nnodes, UU, K[idx]); - //FBlas::copy(rank*nnodes, VV, K[idx] + rank*nnodes); delete [] UU; delete [] VV; @@ -210,8 +204,6 @@ static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal elapsed_time = time.tacAndElapsed(); overall_time += elapsed_time; overall_rank += rank; - // std::cout << "(" << i << "," << j << "," << k << ") " << idx << - // ", low rank = " << rank << " (" << aca_rank << ") in " << elapsed_time << "s" << std::endl; ////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////// @@ -275,14 +267,15 @@ static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal } } } +#ifdef SCALFMM_M2L_VERBOSE //std::cout << "The approximation of the " << counter // << " far-field interactions (overall rank " << overall_rank // << " / " << 16*nnodes // << " , sizeM2L= " << 2*overall_rank*nnodes*sizeof(FReal) << "" // << " / " << 16*nnodes*nnodes*sizeof(FReal) << " B" // << ") took " << overall_time << "s\n" << std::endl; - std::cout << "Compressed and set M2L operators (" << 2*overall_rank*nnodes*sizeof(FReal) << " B) in " << overall_time << "sec." << std::endl; +#endif delete [] U; delete [] WORK; @@ -328,7 +321,8 @@ public: /** Constructor: with 16 small SVDs */ template <typename MatrixKernelClass> - SymmetryHandler(const MatrixKernelClass *const MatrixKernel, const FReal Epsilon, + SymmetryHandler(const MatrixKernelClass *const MatrixKernel, + const FReal Epsilon, const FReal, const unsigned int) { // init all 343 item to zero, because effectively only 16 exist @@ -344,8 +338,9 @@ public: for (int k=-3; k<=3; ++k) { const unsigned int idx = ((i+3) * 7 + (j+3)) * 7 + (k+3); pindices[idx] = 0; - if (abs(i)>1 || abs(j)>1 || abs(k)>1) + if (abs(i)>1 || abs(j)>1 || abs(k)>1){ pindices[idx] = Symmetries.getPermutationArrayAndIndex(i,j,k, pvectors[idx]); + } } } } @@ -413,17 +408,13 @@ public: // init all 343 item to zero, because effectively only 16 exist K = new FReal** [TreeHeight]{}; LowRank = new int* [TreeHeight]{}; - K[0] = nullptr; - K[1] = nullptr; - LowRank[0] = nullptr; - LowRank[1] = nullptr; + // K[0] = nullptr; + // K[1] = nullptr; + // LowRank[0] = nullptr; + // LowRank[1] = nullptr; for (unsigned int l=2; l<TreeHeight; ++l) { K[l] = new FReal* [343]{}; LowRank[l] = new int [343]{}; - // for (unsigned int t=0; t<343; ++t) { - // K[l][t] = nullptr; - // LowRank[l][t] = 0; - // } } @@ -434,8 +425,9 @@ public: for (int k=-3; k<=3; ++k) { const unsigned int idx = ((i+3) * 7 + (j+3)) * 7 + (k+3); pindices[idx] = 0; - if (abs(i)>1 || abs(j)>1 || abs(k)>1) + if (abs(i)>1 || abs(j)>1 || abs(k)>1){ pindices[idx] = Symmetries.getPermutationArrayAndIndex(i,j,k, pvectors[idx]); + } } } } @@ -499,17 +491,17 @@ public: template <class FReal, int ORDER, typename MatrixKernelClass> static void ComputeAndCompressAndStoreInBinaryFile(const MatrixKernelClass *const MatrixKernel, const FReal Epsilon) { - static const unsigned int nnodes = ORDER*ORDER*ORDER; + static constexpr unsigned int nnodes = ORDER*ORDER*ORDER; // compute and compress //////////// std::array<FReal*,343> K{}; std::array<int,343> LowRank{}; - // for (unsigned int idx=0; idx<343; ++idx) - // { K[idx] = nullptr; LowRank[idx] = 0; } + precompute<FReal,ORDER>(MatrixKernel, FReal(2.), Epsilon, K, LowRank); // write to binary file //////////// - FTic time; time.tic(); + FTic time; + time.tic(); // start computing process const char precision = (typeid(FReal)==typeid(double) ? 'd' : 'f'); std::stringstream sstream; @@ -538,9 +530,6 @@ static void ComputeAndCompressAndStoreInBinaryFile(const MatrixKernelClass *cons throw std::runtime_error("File could not be opened to write"); } stream.close(); - // write info - // std::cout << "Compressed M2L operators stored in binary file " << filename - // << " in " << time.tacAndElapsed() << "sec." << std::endl; // free memory ///////////////////// for (unsigned int t=0; t<343; ++t) { @@ -571,7 +560,9 @@ void ReadFromBinaryFile(const FReal Epsilon, FReal* K[343], int LowRank[343]) std::ifstream istream(filename.c_str(), std::ios::in | std::ios::binary | std::ios::ate); const std::ifstream::pos_type size = istream.tellg(); - if (size<=0) throw std::runtime_error("The requested binary file does not yet exist. Exit."); + if (size<=0) { + throw std::runtime_error("The requested binary file does not yet exist. Exit."); + } if (istream.good()) { istream.seekg(0); diff --git a/Src/Utils/FMemStats.h b/Src/Utils/FMemStats.h index 822d22d6276e717822f108651463caf517d62429..57a5b3b5b6df5dbb401c954ce047964c58cdebc8 100644 --- a/Src/Utils/FMemStats.h +++ b/Src/Utils/FMemStats.h @@ -51,10 +51,10 @@ private: void plotState() const { #ifdef SCALFMM_USE_MEM_STATS - printf("[SCALFMM-MEMSTAT] Total number of allocations %lld \n", numberOfAllocations); + printf("[SCALFMM-MEMSTAT] Total number of allocations %llu \n", numberOfAllocations); printf("[SCALFMM-MEMSTAT] Memory used at the end %lu Bytes (%f MB)\n", FMemStats::controler.getCurrentAllocated(), FMemStats::controler.getCurrentAllocatedMB()); - printf("[SCALFMM-MEMSTAT] Max memory used %lld Bytes (%f MB)\n", FMemStats::controler.getMaxAllocated(), FMemStats::controler.getMaxAllocatedMB()); - printf("[SCALFMM-MEMSTAT] Total memory used %lld Bytes (%f MB)\n", FMemStats::controler.getTotalAllocated(), FMemStats::controler.getTotalAllocatedMB()); + printf("[SCALFMM-MEMSTAT] Max memory used %llu Bytes (%f MB)\n", FMemStats::controler.getMaxAllocated(), FMemStats::controler.getMaxAllocatedMB()); + printf("[SCALFMM-MEMSTAT] Total memory used %llu Bytes (%f MB)\n", FMemStats::controler.getTotalAllocated(), FMemStats::controler.getTotalAllocatedMB()); #else printf("[SCALFMM-MEMSTAT] unused\n"); #endif diff --git a/Src/Utils/FMpi.hpp b/Src/Utils/FMpi.hpp index 7a5338ab9a6c0d0b07faafe4caa598cd2a5dec70..a4a047296a745173e71d02b5fa506a053846bf80 100644 --- a/Src/Utils/FMpi.hpp +++ b/Src/Utils/FMpi.hpp @@ -437,7 +437,7 @@ public: /// Generic mpi assert function static void Assert(const int test, const unsigned line, const char* const message = nullptr){ if(test != MPI_SUCCESS){ - printf("[ERROR-QS] Test failled at line %d, result is %d", line, test); + printf("[ERROR-QS] Test failled at line %u, result is %d", line, test); if(message) printf(", message: %s",message); printf("\n"); fflush(stdout); @@ -471,7 +471,7 @@ public: /// assert if mpi error */ static void MpiAssert(const int test, const unsigned line, const char* const message = nullptr){ if(test != MPI_SUCCESS){ - printf("[ERROR] Test failed at line %d, result is %d", line, test); + printf("[ERROR] Test failed at line %u, result is %d", line, test); if(message) printf(", message: %s",message); printf("\n"); fflush(stdout);