diff --git a/libsrc/core/profiler.cpp b/libsrc/core/profiler.cpp index f738fd55..29a69182 100644 --- a/libsrc/core/profiler.cpp +++ b/libsrc/core/profiler.cpp @@ -35,6 +35,17 @@ namespace ngcore fclose(prof); // NOLINT } + if (getenv ("NGPROFILE")) + { + std::string filename = "netgen.prof"; +#ifdef PARALLEL + filename += "."+ToString(id); +#endif + if (id == 0) logger->info( "write profile to file {}", filename ); + FILE *prof = fopen(filename.c_str(),"w"); // NOLINT + Print (prof); + fclose(prof); // NOLINT + } } void NgProfiler :: Print (FILE * prof) diff --git a/libsrc/core/utils.cpp b/libsrc/core/utils.cpp index 82fcfb31..0347d244 100644 --- a/libsrc/core/utils.cpp +++ b/libsrc/core/utils.cpp @@ -8,6 +8,9 @@ namespace ngcore { + // parallel netgen + int id = 0, ntasks = 1; + #ifdef WIN32 // windows does demangling in typeid(T).name() NGCORE_API std::string Demangle(const char* typeinfo) { return typeinfo; } diff --git a/libsrc/core/utils.hpp b/libsrc/core/utils.hpp index c8dc1e9e..da90e1d3 100644 --- a/libsrc/core/utils.hpp +++ b/libsrc/core/utils.hpp @@ -15,6 +15,9 @@ namespace ngcore { + // MPI rank, nranks TODO: Rename + extern NGCORE_API int id, ntasks; + NGCORE_API std::string Demangle(const char* typeinfo); #if defined(__GNUC__) diff --git a/libsrc/general/mpi_interface.hpp b/libsrc/general/mpi_interface.hpp index c45494b6..91cb0af3 100644 --- a/libsrc/general/mpi_interface.hpp +++ b/libsrc/general/mpi_interface.hpp @@ -14,9 +14,8 @@ namespace netgen { - - extern DLL_HEADER int id, ntasks; - + using ngcore::id; + using ngcore::ntasks; #ifdef PARALLEL diff --git a/libsrc/general/netgenout.hpp b/libsrc/general/netgenout.hpp index fafe495e..076a6df1 100644 --- a/libsrc/general/netgenout.hpp +++ b/libsrc/general/netgenout.hpp @@ -4,14 +4,11 @@ // #include // #include // #include +#include "mpi_interface.hpp" namespace netgen { -#ifdef PARALLEL -extern int id; -extern int ntasks; -#endif DLL_HEADER extern int printmessage_importance; DLL_HEADER extern int printdots; diff --git a/libsrc/meshing/global.cpp b/libsrc/meshing/global.cpp index df6bcece..e5036cde 100644 --- a/libsrc/meshing/global.cpp +++ b/libsrc/meshing/global.cpp @@ -50,10 +50,6 @@ namespace netgen string ngdir = "."; - // parallel netgen - int id = 0, ntasks = 1; - - void Ng_PrintDest(const char * s) { if (id == 0)