From 17ab9b01b7d3139170c846ef11d8e5759ce657b2 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sun, 18 Aug 2013 06:34:18 +0000 Subject: [PATCH] fix prealloc (make sure it's smaller than matrix size) --- Common/onelabUtils.cpp | 6 +++--- Solver/linearSystemPETSc.hpp | 3 ++- benchmarks/misc/cpu.geo | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 benchmarks/misc/cpu.geo diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp index a81f918f35..223fcd23fe 100644 --- a/Common/onelabUtils.cpp +++ b/Common/onelabUtils.cpp @@ -399,9 +399,9 @@ namespace onelabUtils { x.setStep((x.getMax() - x.getMin()) / 100.); } if(val && isInteger){ - x.setMin((int) x.getMin()); - x.setMax((int) x.getMax()); - x.setStep((int) x.getStep()); + x.setMin((int)x.getMin()); + x.setMax((int)x.getMax()); + x.setStep((int)x.getStep()); } } } diff --git a/Solver/linearSystemPETSc.hpp b/Solver/linearSystemPETSc.hpp index 34f8ce44e6..02f6d48a9f 100644 --- a/Solver/linearSystemPETSc.hpp +++ b/Solver/linearSystemPETSc.hpp @@ -103,9 +103,10 @@ void linearSystemPETSc<scalar>::preAllocateEntries() int blockSize = _getBlockSizeFromParameters(); std::vector<int> nByRowDiag (_localSize), nByRowOffDiag (_localSize); if (_sparsity.getNbRows() == 0) { - PetscInt prealloc = std::min(300,_localSize); + PetscInt prealloc = 300; PetscBool set; PetscOptionsGetInt(PETSC_NULL, "-petsc_prealloc", &prealloc, &set); + prealloc = std::min(prealloc, _localSize); nByRowDiag.resize(0); nByRowDiag.resize(_localSize, prealloc); } else { diff --git a/benchmarks/misc/cpu.geo b/benchmarks/misc/cpu.geo new file mode 100644 index 0000000000..873e38e682 --- /dev/null +++ b/benchmarks/misc/cpu.geo @@ -0,0 +1,3 @@ + +ss = Sprintf(" (CPU = %g s, Memory = %g Mb)", Cpu, Memory); +Printf( StrCat(Today, ss) ); -- GitLab