Skip to content

Commit

Permalink
Closes #1313
Browse files Browse the repository at this point in the history
added submodule google/benchmark
added first benchmark for feel++ on mesh (loadmesh and updateForUse)
  • Loading branch information
prudhomm committed Apr 15, 2019
1 parent 144a640 commit 23e9e9e
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
[submodule "contrib/viewer"]
path = contrib/viewer
url = https://github.com/feelpp/viewer.git
[submodule "benchmarks/benchmark"]
path = benchmarks/benchmark
url = https://github.com/feelpp/benchmark
7 changes: 4 additions & 3 deletions benchmarks/ATTIC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ macro(feel_add_bench examplename)
add_dependencies( benchmarks ${targetname} )
endmacro(feel_add_bench)

foreach( DIR navierstokes darcy curl perf wrapper/python python compilation magnetostatic hdg mesh)
add_subdirectory( ${DIR} )
endforeach()
add_subdirectory(benchmark)
#foreach( DIR navierstokes darcy curl perf wrapper/python python compilation magnetostatic hdg mesh)
# add_subdirectory( ${DIR} )
#endforeach()
48 changes: 48 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
### CMakeLists.txt; coding: utf-8 ---

# Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
# Date: 07 Apr 2019
#
# Copyright (C) 2019 Feel++ Consortium
#
# Distributed under the GPL(GNU Public License):
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#


cmake_minimum_required(VERSION 3.7.2)

project(benchmarks)
set(PROJECT_SHORTNAME "bench")

# with this it is possible to compile applications/models from an installed
# version of feel++. This is useful also for staged compilation for docker
if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} )
find_package(Feel++ PATHS ${FEELPP_DIR}/share/feelpp/feel/cmake/modules $ENV{FEELPP_DIR}/share/feelpp/feel/cmake/modules /usr/share/feelpp/feel/cmake/modules /usr/local/share/feelpp/feel/cmake/modules )
if(NOT FEELPP_FOUND)
message(FATAL_ERROR "Feel++ was not found on your system. Make sure to install it and specify the FEELPP_DIR to reference the installation directory.")
endif()
else()
feelpp_get_environment()
# usefull for pyfeelpp-toolboxes
set(FEELPP_DIR ${CMAKE_INSTALL_PREFIX})
endif()

feelppGitSubmodulePrepare( benchmark )
include_directories(${CMAKE_SOURCE_DIR}/benchmarks/benchmark/include)
set( BENCHMARK_ENABLE_GTEST_TESTS OFF)
add_subdirectory(benchmark)
add_subdirectory(feelpp)
1 change: 1 addition & 0 deletions benchmarks/benchmark
Submodule benchmark added at 415835
26 changes: 26 additions & 0 deletions benchmarks/feelpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
### CMakeLists.txt; coding: utf-8 ---

# Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
# Date: 07 Apr 2019
#
# Copyright (C) 2019 Feel++ Consortium
#
# Distributed under the GPL(GNU Public License):
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#

feelpp_add_application( env SRCS env.cpp LINK_LIBRARIES benchmark )
feelpp_add_application( mesh SRCS mesh.cpp LINK_LIBRARIES benchmark )
45 changes: 45 additions & 0 deletions benchmarks/feelpp/env.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//! -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=cpp:et:sw=4:ts=4:sts=4
//!
//! This file is part of the Feel++ library
//!
//! This library is free software; you can redistribute it and/or
//! modify it under the terms of the GNU Lesser General Public
//! License as published by the Free Software Foundation; either
//! version 2.1 of the License, or (at your option) any later version.
//!
//! This library is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//! Lesser General Public License for more details.
//!
//! You should have received a copy of the GNU Lesser General Public
//! License along with this library; if not, write to the Free Software
//! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//!
//! @file
//! @author Christophe Prud'homme <christophe.prudhomme@feelpp.org>
//! @date 07 Apr 2019
//! @copyright 2019 Feel++ Consortium
//!

#include <benchmark/benchmark.h>
#include <feel/feelcore/environment.hpp>

// loadmesh

static void BM_env(benchmark::State& st)
{
using namespace Feel;
for (auto _ : st)
{
}
};
BENCHMARK(BM_env)->Arg(8)->Arg(64)->Arg(512)->Arg(1<<10)->Arg(8<<10);
//benchmark::internal::Benchmark* dummy1 = benchmark::RegisterBenchmark(
// "BM_env_registration", BM_env);

int main(int argc, char** argv)
{
benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
}
131 changes: 131 additions & 0 deletions benchmarks/feelpp/mesh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
//! -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=cpp:et:sw=4:ts=4:sts=4
//!
//! This file is part of the Feel++ library
//!
//! This library is free software; you can redistribute it and/or
//! modify it under the terms of the GNU Lesser General Public
//! License as published by the Free Software Foundation; either
//! version 2.1 of the License, or (at your option) any later version.
//!
//! This library is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//! Lesser General Public License for more details.
//!
//! You should have received a copy of the GNU Lesser General Public
//! License along with this library; if not, write to the Free Software
//! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//!
//! @file
//! @author Christophe Prud'homme <christophe.prudhomme@feelpp.org>
//! @date 07 Apr 2019
//! @copyright 2019 Feel++ Consortium
//!

#include <benchmark/benchmark.h>
#include <feel/feelfilters/loadmesh.hpp>

using namespace Feel;
// loadmesh
void BM_Loadmesh3D( benchmark::State& state )
{
using namespace Feel;
size_type nitems;
for (auto _ : state)
{
using mesh_t = Mesh<Simplex<3>>;
auto m = loadMesh( _mesh=new mesh_t,
_filename="hypercube-"+std::to_string(state.range(0))+".msh",
_savehdf5=false,_verbose=false,
_update=0, _h=1./state.range(0) );
nitems=m->numElements();
}
state.SetItemsProcessed( nitems );
}
BENCHMARK(BM_Loadmesh3D)->Unit(benchmark::kMillisecond)->Arg(4)->Arg(8)->Arg(16);//->Arg(32);

// loadmesh
template<typename MeshT>
void BM_updateForUse( benchmark::State& state )
{
using namespace Feel;
using mesh_t = MeshT;
const int nDim = mesh_t::nDim;

size_type nitems;
for (auto _ : state)
{
state.PauseTiming();
auto m = loadMesh( _mesh=new mesh_t,
_filename="feel-"+std::to_string(nDim)+"d-"+std::to_string(state.range(0))+".msh",
_savehdf5=false,_verbose=false,
_update=0, _h=1./state.range(0) );
state.ResumeTiming();
m->components().reset();
m->components().set( state.range(1) );
m->updateForUse();
nitems=m->numElements();
}
state.SetItemsProcessed( state.iterations()*nitems );
state.SetLabel( std::to_string(nDim)+"D h=1/"+std::to_string(state.range(0))+" update="+std::to_string(state.range(1)) + " nelts=" + std::to_string(nitems) );
}
BENCHMARK_TEMPLATE(BM_updateForUse,Mesh<Simplex<2>>)->Unit(benchmark::kMillisecond)
->Args({4,0})
->Args({4,MESH_NO_UPDATE_MEASURES})
->Args({4,MESH_UPDATE_FACES})
->Args({4,MESH_UPDATE_EDGES})
->Args({4,MESH_UPDATE_ELEMENTS_ADJACENCY})
->Args({4,MESH_UPDATE_FACES_MINIMAL})
->Args({8,0})
->Args({8,MESH_NO_UPDATE_MEASURES})
->Args({8,MESH_UPDATE_FACES})
->Args({8,MESH_UPDATE_EDGES})
->Args({8,MESH_UPDATE_ELEMENTS_ADJACENCY})
->Args({8,MESH_UPDATE_FACES_MINIMAL})
->Args({16,0})
->Args({16,MESH_NO_UPDATE_MEASURES})
->Args({16,MESH_UPDATE_FACES})
->Args({16,MESH_UPDATE_EDGES})
->Args({16,MESH_UPDATE_ELEMENTS_ADJACENCY})
->Args({16,MESH_UPDATE_FACES_MINIMAL})
->Args({32,0})
->Args({32,MESH_NO_UPDATE_MEASURES})
->Args({32,MESH_UPDATE_FACES})
->Args({32,MESH_UPDATE_EDGES})
->Args({32,MESH_UPDATE_ELEMENTS_ADJACENCY})
->Args({32,MESH_UPDATE_FACES_MINIMAL});
BENCHMARK_TEMPLATE(BM_updateForUse,Mesh<Simplex<3>>)->Unit(benchmark::kMillisecond)
->Args({4,0})
->Args({4,MESH_NO_UPDATE_MEASURES})
->Args({4,MESH_UPDATE_FACES})
->Args({4,MESH_UPDATE_EDGES})
->Args({4,MESH_UPDATE_ELEMENTS_ADJACENCY})
->Args({4,MESH_UPDATE_FACES_MINIMAL})
->Args({8,0})
->Args({8,MESH_NO_UPDATE_MEASURES})
->Args({8,MESH_UPDATE_FACES})
->Args({8,MESH_UPDATE_EDGES})
->Args({8,MESH_UPDATE_ELEMENTS_ADJACENCY})
->Args({8,MESH_UPDATE_FACES_MINIMAL})
->Args({16,0})
->Args({16,MESH_NO_UPDATE_MEASURES})
->Args({16,MESH_UPDATE_FACES})
->Args({16,MESH_UPDATE_EDGES})
->Args({16,MESH_UPDATE_ELEMENTS_ADJACENCY})
->Args({16,MESH_UPDATE_FACES_MINIMAL});


int main(int argc, char** argv)
{
using namespace Feel;
Environment env( _argc=argc, _argv=argv,
_about=about(_name="feelpp_bench_mesh",
_author="Feel++ Consortium",
_email="feelpp-devel@feelpp.org"));

//benchmark::FLAGS_benchmark_out = "feelpp_bench_mesh.json";
benchmark::Initialize(&argc, argv);
//benchmark::ConsoleReporter cr;
//benchmark::JSONReporter jr;
benchmark::RunSpecifiedBenchmarks();
}
39 changes: 39 additions & 0 deletions feelpp/cmake/modules/feelpp.macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,45 @@ macro( feelppContribPrepare contribname )
endif()
endmacro( feelppContribPrepare )

# feelppGitSubmodulePrepare( submodulename )
# Clone/Update a submodule hold on feel++ repository
macro( feelppGitSubmodulePrepare contribname )
set( FEELPP_PREPARE_SUCCEED FALSE )
set( FEELPP_SUBMODULE_UPDATED FALSE )
message(STATUS "[feelpp] ${contribname} : ${CMAKE_CURRENT_SOURCE_DIR}/${contribname}")
# Count files number in <name>.
file(GLOB CONTRIB_LIST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${contribname}/*")
list(LENGTH CONTRIB_LIST_FILES CONTRIB_NFILES)
if ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${contribname} )
# Update submodule if the contrib/<name> directory is empty. User should run
# `git submodule update --init --recursive` in other cases.
if ( GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git/ AND CONTRIB_NFILES EQUAL 0 )
execute_process(
COMMAND git submodule update --init --recursive ${CMAKE_CURRENT_SOURCE_DIR}/${contribname}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_FILE ${FEELPP_BUILD_DIR}/git.${contribname}.log
ERROR_FILE ${FEELPP_BUILD_DIR}/git.${contribname}.log
RESULT_VARIABLE ERROR_CODE
)
if(ERROR_CODE EQUAL "0")
message( STATUS "[feelpp] ${contribname}: submodule updated!`")
set( FEELPP_PREPARE_SUCCEED TRUE )
else()
MESSAGE(WARNING "Git submodule ${contribname} failed to be updated (error: ${ERROR_CODE}). Possible cause: No internet access, firewalls ...")
endif()
else()
if ( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${contribname})
message( WARNING "Please make sure that git submodule ${CMAKE_CURRENT_SOURCE_DIR}/${contribname} is available")
message( WARNING " run `git submodule update --init --recursive ${CMAKE_CURRENT_SOURCE_DIR}/${contribname}`")
else()
message( STATUS "[feelpp] ${CMAKE_CURRENT_SOURCE_DIR}/${contribname}: submodule hold!")
set( FEELPP_PREPARE_SUCCEED TRUE )
set( FEELPP_SUBMODULE_UPDATED TRUE ) # Diplay message info."$Feel++ submodules are not updated automatically. Please be sure to run `git submodule update --init --recurse` in the source directory beforehand!"
endif()
endif()
endif()
endmacro( feelppGitSubmodulePrepare )


# Colorized cmake message.
macro( feelpp_message )
Expand Down

0 comments on commit 23e9e9e

Please sign in to comment.