From 34ceae0fa17f8663a7a1703b84beea17abfd0497 Mon Sep 17 00:00:00 2001 From: Wenqing Wang <wenqing.wang@ufz.de> Date: Mon, 20 Oct 2014 12:14:35 +0200 Subject: [PATCH] Removed class PETScWallClockTimer and minor changes in cmake files --- Applications/CLI/CMakeLists.txt | 2 +- BaseLib/CMakeLists.txt | 4 -- BaseLib/PETScWallClockTimer.h | 57 ---------------------- MathLib/LinAlg/PETSc/PETScLinearSolver.cpp | 8 +-- MathLib/LinAlg/PETSc/PETScLinearSolver.h | 4 +- scripts/cmake/Find.cmake | 10 +++- 6 files changed, 15 insertions(+), 70 deletions(-) delete mode 100644 BaseLib/PETScWallClockTimer.h diff --git a/Applications/CLI/CMakeLists.txt b/Applications/CLI/CMakeLists.txt index 836daed4fc4..a5724eff5bb 100644 --- a/Applications/CLI/CMakeLists.txt +++ b/Applications/CLI/CMakeLists.txt @@ -12,7 +12,7 @@ TARGET_LINK_LIBRARIES(ogs ) IF(OGS_USE_PETSC) - TARGET_LINK_LIBRARIES(ogs ${ogs} ${PETSC_LIBRARIES}) + TARGET_LINK_LIBRARIES(ogs ${PETSC_LIBRARIES}) ENDIF() INCLUDE(Tests.cmake) diff --git a/BaseLib/CMakeLists.txt b/BaseLib/CMakeLists.txt index 1fcbef437fa..4ccc1008d13 100644 --- a/BaseLib/CMakeLists.txt +++ b/BaseLib/CMakeLists.txt @@ -2,10 +2,6 @@ GET_SOURCE_FILES(SOURCES) -IF(NOT OGS_USE_PETSC) - list(REMOVE_ITEM SOURCES PETScWallClockTimer.h) -ENDIF() - LIST(APPEND SOURCES "${CMAKE_CURRENT_BINARY_DIR}/BuildInfo.cpp" BuildInfo.h) # Create the library diff --git a/BaseLib/PETScWallClockTimer.h b/BaseLib/PETScWallClockTimer.h deleted file mode 100644 index 018526a3d9c..00000000000 --- a/BaseLib/PETScWallClockTimer.h +++ /dev/null @@ -1,57 +0,0 @@ -/*! - \file PETScWallClockTimer.h - \author Wenqing Wang - \date 2014.08 - \brief Declare a class to record wall clock time in computation with PETSc. - - \copyright - Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - Distributed under a Modified BSD License. - See accompanying file LICENSE.txt or - http://www.opengeosys.org/project/license - -*/ - -#ifndef PETSC_WALL_CLOCK_TIMER_H -#define PETSC_WALL_CLOCK_TIMER_H - -#include <petsctime.h> - -namespace BaseLib -{ - -/// Count wall clock time for computations with PETSc. -class PETScWallClockTimer -{ - public: - /// Record the start time. - void start() - { -#if (PETSC_VERSION_NUMBER > 3020) - PetscTime(&_start_time); -#else - PetscGetTime(&_start_time); -#endif - } - - /// Return the elapsed time when this function is called. - PetscLogDouble elapsed() const - { - PetscLogDouble current_time; -#if (PETSC_VERSION_NUMBER > 3020) - PetscTime(¤t_time); -#else - PetscGetTime(¤t_time); -#endif - return current_time - _start_time; - } - - private: - /// Start time. - PetscLogDouble _start_time = 0.; -}; - -} // end namespace BaseLib - -#endif - diff --git a/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp b/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp index a10318d7e4c..a1a562dff93 100644 --- a/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp +++ b/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp @@ -15,7 +15,7 @@ */ #include "PETScLinearSolver.h" -#include "BaseLib/PETScWallClockTimer.h" +#include "BaseLib/RunTime.h" namespace MathLib { @@ -37,8 +37,8 @@ PETScLinearSolver::PETScLinearSolver(PETScMatrix &A, const std::string &prefix) bool PETScLinearSolver::solve(const PETScVector &b, PETScVector &x) { - BaseLib::PETScWallClockTimer ctimer; - ctimer.start(); + BaseLib::RunTime wtimer; + wtimer.start(); // define TEST_MEM_PETSC #ifdef TEST_MEM_PETSC @@ -106,7 +106,7 @@ bool PETScLinearSolver::solve(const PETScVector &b, PETScVector &x) PetscPrintf(PETSC_COMM_WORLD, "###Memory usage by solver. Before :%f After:%f Increase:%d\n", mem1, mem2, (int)(mem2 - mem1)); #endif - _elapsed_ctime += ctimer.elapsed(); + _elapsed_ctime += wtimer.elapsed(); return converged; } diff --git a/MathLib/LinAlg/PETSc/PETScLinearSolver.h b/MathLib/LinAlg/PETSc/PETScLinearSolver.h index d65efa41911..c908e914c93 100644 --- a/MathLib/LinAlg/PETSc/PETScLinearSolver.h +++ b/MathLib/LinAlg/PETSc/PETScLinearSolver.h @@ -68,7 +68,7 @@ class PETScLinearSolver } /// Get elapsed wall clock time. - PetscLogDouble getElapsedTime() const + double getElapsedTime() const { return _elapsed_ctime; } @@ -81,7 +81,7 @@ class PETScLinearSolver KSP _solver; ///< Solver type. PC _pc; ///< Preconditioner type. - PetscLogDouble _elapsed_ctime; ///< Clock time + double _elapsed_ctime; ///< Clock time }; } // end namespace diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake index ead7273033c..9a68e213ed6 100644 --- a/scripts/cmake/Find.cmake +++ b/scripts/cmake/Find.cmake @@ -116,6 +116,14 @@ IF(OGS_USE_LIS) FIND_PACKAGE( LIS REQUIRED ) ENDIF() +## Check MPI package +IF(OGS_USE_PETSC OR OGS_USE_MPI) + FIND_PACKAGE(MPI) + IF(NOT MPI_FOUND) + MESSAGE(FATAL_ERROR "MPI is required but was not found!") + ENDIF() +ENDIF() + IF(OGS_USE_PETSC) MESSAGE (STATUS "Configuring for PETSc" ) @@ -133,7 +141,6 @@ IF(OGS_USE_PETSC) include_directories( ${PETSC_INCLUDES} ) - FIND_PACKAGE(MPI REQUIRED) IF(WIN32) ADD_DEFINITIONS(/DPETSC_VERSION_NUMBER=PETSC_VERSION_MAJOR*1000+PETSC_VERSION_MINOR*10) @@ -144,6 +151,5 @@ IF(OGS_USE_PETSC) ENDIF() IF(OGS_USE_MPI) - FIND_PACKAGE( MPI REQUIRED ) INCLUDE_DIRECTORIES(SYSTEM ${MPI_CXX_INCLUDE_PATH}) ENDIF() -- GitLab