Skip to content
Snippets Groups Projects
Commit f53f2cb6 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

- start FPE Management

- set of dirty CLI tests
- signal management dirty tests
parent 4afeb622
Branches
Tags
No related merge requests found
delpinos@u-sterne.bruyeres.cea.fr.23888:1521446211
\ No newline at end of file
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
build/ build/
CMakeFiles/ CMakeFiles/
CMakeCache.txt CMakeCache.txt
.\#*
...@@ -14,6 +14,7 @@ project (Pastis ...@@ -14,6 +14,7 @@ project (Pastis
VERSION 0.0.2) VERSION 0.0.2)
set(PASTIS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(PASTIS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(PASTIS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
# Rang (colors? Useless thus necessary!) # Rang (colors? Useless thus necessary!)
include_directories(${PASTIS_SOURCE_DIR}/packages/rang/include) include_directories(${PASTIS_SOURCE_DIR}/packages/rang/include)
...@@ -34,6 +35,17 @@ include_directories(utils) ...@@ -34,6 +35,17 @@ include_directories(utils)
include(GetKokkosCompilerFlags) include(GetKokkosCompilerFlags)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# ---------------- Checks for includes ----------------
# Checks for FPE
include(CheckIncludeFile)
check_include_file(fenv.h PASTIS_HAS_FENV_H)
# Generates pastis_config.hpp
configure_file("${PASTIS_SOURCE_DIR}/pastis_config.hpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/pastis_config.hpp"
@ONLY)
# ------------------- Source files -------------------- # ------------------- Source files --------------------
# Pastis binary # Pastis binary
add_executable( add_executable(
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <Kokkos_Core.hpp> #include <Kokkos_Core.hpp>
#include <RevisionInfo.hpp> #include <RevisionInfo.hpp>
#include <rang.hpp> #include <rang.hpp>
#include <FPEManager.hpp>
#include <CLI/CLI.hpp> #include <CLI/CLI.hpp>
...@@ -113,17 +114,54 @@ void computeExplicitFluxes(const Kokkos::View<double*>& xr, ...@@ -113,17 +114,54 @@ void computeExplicitFluxes(const Kokkos::View<double*>& xr,
}); });
} }
#warning clean-up and add warning message when release version is run
#include <csignal>
void signal_handler(int s) {
std::cerr << rang::style::reset
<< rang::fg::reset
<< rang::style::bold;
std::cerr << "to attach gdb to this process run\n";
std::cerr << "\tgdb -pid "
<< rang::fg::red
<< getpid()
<< rang::fg::reset
<< '\n';
std::cerr << "else press Control-C to exit\n";
std::cerr << rang::style::reset;
::sigset_t sig;
::sigaddset(&sig,SIGSTOP);
::sigsuspend(&sig);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
CLI::App app{"Pastis help"}; CLI::App app{"Pastis help"};
long number = 1000; long unsigned number = 0;
app.add_option("-n,--number", number, "A big integer"); app.add_option("number,-n,--number", number, "Number of cells");//->required();
bool disable_fpe = false;
app.add_flag("--disable-fpe", disable_fpe=false, "Traps floating point exceptions");
int threads=-1; int threads=-1;
app.add_option("--threads", threads, "Number of Kokkos threads"); app.add_option("--threads", threads, "Number of Kokkos threads");
CLI11_PARSE(app, argc, argv); std::cerr << "disable_fpe=" << disable_fpe << '\n' << std::flush;
// signal_handler(SIGFPE);
std::atexit([](){std::cout << rang::style::reset;});
try {
app.parse(argc, argv);
} catch (const CLI::ParseError &e) {
std::cout << (e.get_exit_code()==0 ? rang::fg::blue : rang::fg::red);
return app.exit(e);
}
if (disable_fpe) {
FPEManager::disable();
} else {
FPEManager::enable();
}
std::cout << "Code version: " std::cout << "Code version: "
<< rang::style::bold << RevisionInfo::version() << rang::style::reset << '\n'; << rang::style::bold << RevisionInfo::version() << rang::style::reset << '\n';
...@@ -229,6 +267,9 @@ int main(int argc, char *argv[]) ...@@ -229,6 +267,9 @@ int main(int argc, char *argv[])
int iteration=0; int iteration=0;
while((t<tmax) and (iteration<itermax)) { while((t<tmax) and (iteration<itermax)) {
double test=3;
test /= t;
std::cout << test << '\n';
double dt = 0.4*acoustic_dt(Vj, cj); double dt = 0.4*acoustic_dt(Vj, cj);
if (t+dt<tmax) { if (t+dt<tmax) {
t+=dt; t+=dt;
......
#ifndef PASTIS_CONFIG_HPP
#define PASTIS_CONFIG_HPP
#cmakedefine PASTIS_HAS_FENV_H
#endif // PASTIS_CONFIG_HPP
...@@ -5,6 +5,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) ...@@ -5,6 +5,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_library( add_library(
PastisUtils PastisUtils
FPEManager.cpp
RevisionInfo.cpp) RevisionInfo.cpp)
# --------------- get git revision info --------------- # --------------- get git revision info ---------------
...@@ -61,9 +62,12 @@ list( ...@@ -61,9 +62,12 @@ list(
SOURCES SOURCES
${CMAKE_CURRENT_BINARY_DIR}/pastis_git_revision.hpp ${CMAKE_CURRENT_BINARY_DIR}/pastis_git_revision.hpp
${CMAKE_CURRENT_BINARY_DIR}/pastis_version.hpp ${CMAKE_CURRENT_BINARY_DIR}/pastis_version.hpp
${PASTIS_BINARY_DIR}/pastis_config.hpp
) )
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${PASTIS_BINARY_DIR})
include_directories(${PASTIS_SOURCE_DIR}/packages/rang/include)
# Additional dependencies # Additional dependencies
add_dependencies( add_dependencies(
......
#include <FPEManager.hpp>
#include <pastis_config.hpp>
#include <rang.hpp>
#ifdef PASTIS_HAS_FENV_H
#include <fenv.h>
#define MANAGED_FPE (FE_DIVBYZERO|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW)
void FPEManager::enable()
{
std::cout << "FE management: "
<< rang::style::bold
<< rang::fgB::green
<< "enabled"
<< rang::fg::reset
<< rang::style::reset << '\n';
::feenableexcept(MANAGED_FPE);
}
void FPEManager::disable()
{
std::cout << "FE management: "
<< rang::style::bold
<< rang::fgB::red
<< "disabled"
<< rang::fg::reset
<< rang::style::reset << '\n';
::fedisableexcept(MANAGED_FPE);
}
#else // PASTIS_HAS_FENV_H
void FPEManager::enable()
{
std::cout << "FE management: enabled "
<< rang::fg::red
<< "[not supported]"
<< rang::fg::reset << '\n';
}
void FPEManager::disable()
{
std::cout << "FE management: disable "
<< rang::fg::red
<< "[not supported]"
<< rang::fg::reset << '\n';
}
#endif // PASTIS_HAS_FENV_H
#ifndef FPEMANAGER_HPP
#define FPEMANAGER_HPP
struct FPEManager
{
static void enable();
static void disable();
};
#endif // FPEMANAGER_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment