mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
Remove old profiler.hpp
This commit is contained in:
parent
baca4a57a0
commit
c6a401e066
@ -1,4 +1,4 @@
|
||||
Checks: '*,-clang-analyzer-alpha.*,-*braces-around-statements,-fuchsia-*,-google-runtime-references,-readability-implicit-bool-conversion,-google-explicit-constructor,-hicpp-explicit-conversions,-google-runtime-int,-llvm-header-guard,-modernize-pass-by-value,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic'
|
||||
Checks: '*,-clang-analyzer-alpha.*,-*braces-around-statements,-fuchsia-*,-google-runtime-references,-readability-implicit-bool-conversion,-google-explicit-constructor,-hicpp-explicit-conversions,-google-runtime-int,-llvm-header-guard,-modernize-pass-by-value'
|
||||
CheckOptions:
|
||||
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
|
||||
value: 1
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "archive.hpp"
|
||||
#include "exception.hpp"
|
||||
#include "logging.hpp"
|
||||
#include "profiler.hpp"
|
||||
#include "symboltable.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
namespace ngcore
|
||||
{
|
||||
std::array<NgProfiler::TimerVal,NgProfiler::SIZE> NgProfiler::timers; // NOLINT
|
||||
std::vector<NgProfiler::TimerVal> NgProfiler::timers(NgProfiler::SIZE); // NOLINT
|
||||
|
||||
std::string NgProfiler::filename;
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace ngcore
|
||||
int usedcounter = 0;
|
||||
};
|
||||
|
||||
NGCORE_API static std::array<TimerVal,SIZE> timers;
|
||||
NGCORE_API static std::vector<TimerVal> timers;
|
||||
|
||||
NGCORE_API static TTimePoint * thread_times;
|
||||
NGCORE_API static TTimePoint * thread_flops;
|
||||
@ -69,17 +69,17 @@ namespace ngcore
|
||||
|
||||
static void StartThreadTimer (size_t nr, size_t tid)
|
||||
{
|
||||
thread_times[tid*SIZE+nr] -= GetTimeCounter();
|
||||
thread_times[tid*SIZE+nr] -= GetTimeCounter(); // NOLINT
|
||||
}
|
||||
|
||||
static void StopThreadTimer (size_t nr, size_t tid)
|
||||
{
|
||||
thread_times[tid*SIZE+nr] += GetTimeCounter();
|
||||
thread_times[tid*SIZE+nr] += GetTimeCounter(); // NOLINT
|
||||
}
|
||||
|
||||
static void AddThreadFlops (size_t nr, size_t tid, size_t flops)
|
||||
{
|
||||
thread_flops[tid*SIZE+nr] += flops;
|
||||
thread_flops[tid*SIZE+nr] += flops; // NOLINT
|
||||
}
|
||||
|
||||
/// if you know number of flops, provide them to obtain the MFlop - rate
|
||||
@ -123,6 +123,22 @@ namespace ngcore
|
||||
static std::string GetName (int nr) { return timers[nr].name; }
|
||||
/// print profile
|
||||
NGCORE_API static void Print (FILE * ost);
|
||||
|
||||
class RegionTimer
|
||||
{
|
||||
int nr;
|
||||
public:
|
||||
/// start timer
|
||||
RegionTimer (int anr) : nr(anr) { NgProfiler::StartTimer(nr); }
|
||||
/// stop timer
|
||||
~RegionTimer () { NgProfiler::StopTimer(nr); }
|
||||
|
||||
RegionTimer() = delete;
|
||||
RegionTimer(const RegionTimer &) = delete;
|
||||
RegionTimer(RegionTimer &&) = delete;
|
||||
void operator=(const RegionTimer &) = delete;
|
||||
void operator=(RegionTimer &&) = delete;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -184,8 +200,8 @@ namespace ngcore
|
||||
~RegionTimer () { timer.Stop(); }
|
||||
|
||||
RegionTimer() = delete;
|
||||
RegionTimer(RegionTimer &&) = delete;
|
||||
RegionTimer(const RegionTimer &) = delete;
|
||||
RegionTimer(RegionTimer &&) = delete;
|
||||
void operator=(const RegionTimer &) = delete;
|
||||
void operator=(RegionTimer &&) = delete;
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
add_definitions(-DNGINTERFACE_EXPORTS)
|
||||
add_library(gen OBJECT
|
||||
array.cpp bitarray.cpp dynamicmem.cpp flags.cpp
|
||||
hashtabl.cpp mystring.cpp ngexception.cpp optmem.cpp parthreads.cpp
|
||||
profiler.cpp seti.cpp sort.cpp spbita2d.cpp table.cpp
|
||||
hashtabl.cpp mystring.cpp optmem.cpp parthreads.cpp
|
||||
seti.cpp sort.cpp spbita2d.cpp table.cpp
|
||||
mpi_interface.cpp gzstream.cpp
|
||||
)
|
||||
|
||||
@ -12,13 +12,11 @@ endif(NOT WIN32)
|
||||
|
||||
set_target_properties( gen PROPERTIES POSITION_INDEPENDENT_CODE ON )
|
||||
|
||||
install( FILES ngexception.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel )
|
||||
|
||||
install(FILES
|
||||
array.hpp autodiff.hpp autoptr.hpp bitarray.hpp
|
||||
dynamicmem.hpp flags.hpp hashtabl.hpp mpi_interface.hpp myadt.hpp
|
||||
ngsimd.hpp mystring.hpp netgenout.hpp ngexception.hpp ngpython.hpp
|
||||
optmem.hpp parthreads.hpp profiler.hpp seti.hpp sort.hpp
|
||||
ngsimd.hpp mystring.hpp netgenout.hpp ngpython.hpp
|
||||
optmem.hpp parthreads.hpp seti.hpp sort.hpp
|
||||
spbita2d.hpp stack.hpp table.hpp template.hpp
|
||||
gzstream.h
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/general COMPONENT netgen_devel
|
||||
|
@ -21,8 +21,8 @@
|
||||
namespace netgen
|
||||
{
|
||||
using namespace ngcore;
|
||||
using NgException = Exception;
|
||||
}
|
||||
#include "ngexception.hpp"
|
||||
#include "parthreads.hpp"
|
||||
// #include "moveablemem.hpp"
|
||||
#include "dynamicmem.hpp"
|
||||
@ -43,7 +43,6 @@ namespace netgen
|
||||
#include "sort.hpp"
|
||||
#include "stack.hpp"
|
||||
#include "mystring.hpp"
|
||||
#include "profiler.hpp"
|
||||
|
||||
#include "mpi_interface.hpp"
|
||||
#include "netgenout.hpp"
|
||||
|
@ -1,33 +0,0 @@
|
||||
/**************************************************************************/
|
||||
/* File: ngexception.cpp */
|
||||
/* Author: Joachim Schoeberl */
|
||||
/* Date: 16. Jan. 02 */
|
||||
/**************************************************************************/
|
||||
|
||||
#include <myadt.hpp>
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
//using namespace netgen;
|
||||
|
||||
|
||||
|
||||
NgException :: NgException (const string & s)
|
||||
: m_what(s)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
NgException :: ~NgException ()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
/// append string to description
|
||||
void NgException :: Append (const string & s)
|
||||
{
|
||||
m_what += s;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
#ifndef FILE_NGEXCEPTION
|
||||
#define FILE_NGEXCEPTION
|
||||
|
||||
/**************************************************************************/
|
||||
/* File: ngexception.hpp */
|
||||
/* Author: Joachim Schoeberl */
|
||||
/* Date: 16. Jan. 2002 */
|
||||
/**************************************************************************/
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
|
||||
/// Base class for all ng exceptions
|
||||
class NgException : public std::exception
|
||||
{
|
||||
/// verbal description of exception
|
||||
string m_what;
|
||||
public:
|
||||
///
|
||||
DLL_HEADER NgException (const string & s);
|
||||
///
|
||||
DLL_HEADER virtual ~NgException ();
|
||||
|
||||
/// append string to description
|
||||
DLL_HEADER void Append (const string & s);
|
||||
// void Append (const char * s);
|
||||
|
||||
/// verbal description of exception
|
||||
const string & What() const { return m_what; }
|
||||
virtual const char* what() const noexcept override { return m_what.c_str(); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,131 +0,0 @@
|
||||
/**************************************************************************/
|
||||
/* File: profiler.cpp */
|
||||
/* Author: Joachim Schoeberl */
|
||||
/* Date: 19. Apr. 2002 */
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
#include <myadt.hpp>
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
//using namespace netgen;
|
||||
|
||||
long int NgProfiler::tottimes[SIZE];
|
||||
long int NgProfiler::starttimes[SIZE];
|
||||
long int NgProfiler::counts[SIZE];
|
||||
string NgProfiler::names[SIZE];
|
||||
int NgProfiler::usedcounter[SIZE];
|
||||
|
||||
|
||||
NgProfiler :: NgProfiler()
|
||||
{
|
||||
for (int i = 0; i < SIZE; i++)
|
||||
{
|
||||
tottimes[i] = 0;
|
||||
usedcounter[i] = 0;
|
||||
}
|
||||
|
||||
total_timer = CreateTimer ("total CPU time");
|
||||
StartTimer (total_timer);
|
||||
}
|
||||
|
||||
NgProfiler :: ~NgProfiler()
|
||||
{
|
||||
#ifndef PARALLEL
|
||||
StopTimer (total_timer);
|
||||
#endif
|
||||
|
||||
//ofstream prof;
|
||||
//prof.open("ng.prof");
|
||||
|
||||
// ofstream-constructor may be called after STL-stuff is destructed,
|
||||
// which leads to an "order of destruction"-problem,
|
||||
// thus we use the C-variant:
|
||||
|
||||
if (getenv ("NGPROFILE"))
|
||||
{
|
||||
char filename[100];
|
||||
#ifdef PARALLEL
|
||||
sprintf (filename, "netgen.prof.%d", id);
|
||||
#else
|
||||
sprintf (filename, "netgen.prof");
|
||||
#endif
|
||||
|
||||
if (id == 0) printf ("write profile to file netgen.prof\n");
|
||||
FILE *prof = fopen(filename,"w");
|
||||
Print (prof);
|
||||
fclose(prof);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// void NgProfiler :: Print (ostream & prof)
|
||||
// {
|
||||
// for (int i = 0; i < SIZE; i++)
|
||||
// if (counts[i] != 0 || usedcounter[i] != 0)
|
||||
// {
|
||||
// prof.setf (ios::fixed, ios::floatfield);
|
||||
// prof.setf (ios::showpoint);
|
||||
|
||||
// prof // << "job " << setw(3) << i
|
||||
// << "calls " << setw(8) << counts[i]
|
||||
// << ", time " << setprecision(2) << setw(6) << double(tottimes[i]) / CLOCKS_PER_SEC << " sec";
|
||||
|
||||
// if (usedcounter[i])
|
||||
// prof << " " << names[i];
|
||||
// else
|
||||
// prof << " " << i;
|
||||
|
||||
// prof << endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
void NgProfiler :: Print (FILE * prof)
|
||||
{
|
||||
for (int i = 0; i < SIZE; i++)
|
||||
if (counts[i] != 0 || usedcounter[i] != 0)
|
||||
{
|
||||
//fprintf(prof,"job %3i calls %8i, time %6.2f sec",i,counts[i],double(tottimes[i]) / CLOCKS_PER_SEC);
|
||||
#ifndef USE_TSC
|
||||
fprintf(prof,"calls %8li, time %6.2f sec",counts[i],double(tottimes[i]) / CLOCKS_PER_SEC);
|
||||
#else
|
||||
fprintf(prof,"calls %8li, time %6.2f sec",counts[i],double(tottimes[i]) / 2.7e9);
|
||||
#endif
|
||||
if(usedcounter[i])
|
||||
fprintf(prof," %s",names[i].c_str());
|
||||
else
|
||||
fprintf(prof," %i",i);
|
||||
fprintf(prof,"\n");
|
||||
}
|
||||
}
|
||||
|
||||
int NgProfiler :: CreateTimer (const string & name)
|
||||
{
|
||||
for (int i = SIZE-1; i > 0; i--)
|
||||
if(names[i] == name)
|
||||
return i;
|
||||
|
||||
for (int i = SIZE-1; i > 0; i--)
|
||||
if (!usedcounter[i])
|
||||
{
|
||||
usedcounter[i] = 1;
|
||||
names[i] = name;
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void NgProfiler :: ClearTimers ()
|
||||
{
|
||||
for (int i = 0; i < SIZE; i++)
|
||||
{
|
||||
tottimes[i] = 0;
|
||||
counts[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
NgProfiler prof;
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
#ifndef FILE_NG_PROFILER
|
||||
#define FILE_NG_PROFILER
|
||||
|
||||
/**************************************************************************/
|
||||
/* File: profiler.hpp */
|
||||
/* Author: Joachim Schoeberl */
|
||||
/* Date: 5. Jan. 2005 */
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifdef VTRACE
|
||||
#include "vt_user.h"
|
||||
#else
|
||||
#define VT_USER_START(n)
|
||||
#define VT_USER_END(n)
|
||||
#define VT_TRACER(n)
|
||||
#endif
|
||||
|
||||
|
||||
// #define USE_TSC
|
||||
#ifdef USE_TSC
|
||||
#include <x86intrin.h> // for __rdtsc() CPU time step counter
|
||||
#endif
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
|
||||
class NgProfiler
|
||||
{
|
||||
enum { SIZE = 1000 };
|
||||
|
||||
static long int tottimes[SIZE];
|
||||
static long int starttimes[SIZE];
|
||||
static long int counts[SIZE];
|
||||
static string names[SIZE];
|
||||
static int usedcounter[SIZE];
|
||||
|
||||
int total_timer;
|
||||
public:
|
||||
NgProfiler();
|
||||
~NgProfiler();
|
||||
static int CreateTimer (const string & name);
|
||||
#ifndef USE_TSC
|
||||
static void StartTimer (int nr)
|
||||
{
|
||||
starttimes[nr] = clock(); counts[nr]++;
|
||||
// VT_USER_START (const_cast<char*> (names[nr].c_str()));
|
||||
VT_USER_START ( (char * const) (names[nr].c_str()));
|
||||
}
|
||||
static void StopTimer (int nr)
|
||||
{
|
||||
tottimes[nr] += clock()-starttimes[nr];
|
||||
VT_USER_END (const_cast<char*> (names[nr].c_str()));
|
||||
}
|
||||
#else
|
||||
static void StartTimer (int nr)
|
||||
{
|
||||
starttimes[nr] = __rdtsc(); counts[nr]++;
|
||||
// VT_USER_START (const_cast<char*> (names[nr].c_str()));
|
||||
// VT_USER_START ( (char * const) (names[nr].c_str()));
|
||||
}
|
||||
static void StopTimer (int nr)
|
||||
{
|
||||
tottimes[nr] += __rdtsc()-starttimes[nr];
|
||||
VT_USER_END (const_cast<char*> (names[nr].c_str()));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//static void Print (ostream & ost);
|
||||
static void Print (FILE * prof);
|
||||
|
||||
static void ClearTimers ();
|
||||
|
||||
class RegionTimer
|
||||
{
|
||||
int nr;
|
||||
public:
|
||||
RegionTimer (int anr) : nr(anr)
|
||||
{ StartTimer (nr); }
|
||||
~RegionTimer () { StopTimer (nr); }
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -598,7 +598,6 @@ void STLSurfaceMeshing1 (STLGeometry & geom,
|
||||
|
||||
for (int fnr = 1; fnr <= mesh.GetNFD(); fnr++)
|
||||
{
|
||||
if (fnr == 100) NgProfiler::ClearTimers();
|
||||
if (!opensegsperface[fnr]) continue;
|
||||
if (multithread.terminate) return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user