mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
clean up memory tracing
This commit is contained in:
parent
1a93fb3fa5
commit
f143995f27
@ -446,14 +446,13 @@ namespace ngcore
|
|||||||
const int container_jobs = paje.CreateContainer( container_type_jobs, container_task_manager, "Jobs" );
|
const int container_jobs = paje.CreateContainer( container_type_jobs, container_task_manager, "Jobs" );
|
||||||
|
|
||||||
int variable_type_memory = 0;
|
int variable_type_memory = 0;
|
||||||
|
const int container_memory = paje.CreateContainer( container_type_memory, container_task_manager, "Memory" );
|
||||||
if(mem_tracing_enabled)
|
if(mem_tracing_enabled)
|
||||||
{
|
{
|
||||||
variable_type_memory = paje.DefineVariableType( container_type_task_manager, "Memory [MB]" );
|
variable_type_memory = paje.DefineVariableType( container_type_task_manager, "Memory [MB]" );
|
||||||
paje.SetVariable( 0, variable_type_memory, container_type_memory, 0.0 );
|
paje.SetVariable( 0, variable_type_memory, container_memory, 0.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
const int container_memory = paje.CreateContainer( container_type_memory, container_task_manager, "Memory" );
|
|
||||||
|
|
||||||
|
|
||||||
int num_nodes = 1; //task_manager ? task_manager->GetNumNodes() : 1;
|
int num_nodes = 1; //task_manager ? task_manager->GetNumNodes() : 1;
|
||||||
std::vector <int> thread_aliases;
|
std::vector <int> thread_aliases;
|
||||||
@ -526,10 +525,11 @@ namespace ngcore
|
|||||||
|
|
||||||
for(const auto & m : memory_events)
|
for(const auto & m : memory_events)
|
||||||
{
|
{
|
||||||
|
double size = 1.0*m.size/(1024*1024);
|
||||||
if(m.is_alloc)
|
if(m.is_alloc)
|
||||||
paje.AddVariable( m.time, variable_type_memory, container_memory, 1.0*m.size / (1024*1024));
|
paje.AddVariable( m.time, variable_type_memory, container_memory, size);
|
||||||
else
|
else
|
||||||
paje.SubVariable( m.time, variable_type_memory, container_memory, 1.0*m.size / (1024*1024));
|
paje.SubVariable( m.time, variable_type_memory, container_memory, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<int> timer_ids;
|
std::set<int> timer_ids;
|
||||||
|
@ -316,7 +316,6 @@ namespace ngcore
|
|||||||
NGCORE_API static std::map< int, std::vector<int> > tree;
|
NGCORE_API static std::map< int, std::vector<int> > tree;
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
std::vector<std::function<void()>> tracks;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -345,7 +344,6 @@ namespace ngcore
|
|||||||
int child_id = GetId(name);
|
int child_id = GetId(name);
|
||||||
tree[id].push_back(child_id);
|
tree[id].push_back(child_id);
|
||||||
obj.SetMemoryTracing(child_id);
|
obj.SetMemoryTracing(child_id);
|
||||||
tracks.push_back( [&obj] () { obj.SetMemoryTracing(0); } );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -356,22 +354,10 @@ namespace ngcore
|
|||||||
tree[id].push_back(child_id);
|
tree[id].push_back(child_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopTracking()
|
|
||||||
{
|
|
||||||
for(auto & f : tracks)
|
|
||||||
f();
|
|
||||||
tracks.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string GetName(int id)
|
static std::string GetName(int id)
|
||||||
{
|
{
|
||||||
return names[id];
|
return names[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
~MemoryTracer()
|
|
||||||
{
|
|
||||||
StopTracking();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NETGEN_INLINE void TraceMemoryAlloc( int mem_id, size_t size )
|
NETGEN_INLINE void TraceMemoryAlloc( int mem_id, size_t size )
|
||||||
|
Loading…
Reference in New Issue
Block a user