mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
mem tracing - TraceMemorySwap helper function
This commit is contained in:
parent
6f98123e98
commit
f0152baacf
@ -701,7 +701,7 @@ namespace ngcore
|
|||||||
|
|
||||||
NETGEN_INLINE Array (Array && a2)
|
NETGEN_INLINE Array (Array && a2)
|
||||||
{
|
{
|
||||||
TraceMemoryChange(mem_tracing_id, sizeof(T)*(a2.allocsize-allocsize));
|
TraceMemorySwap(mem_tracing_id, sizeof(T)*allocsize, a2.mem_tracing_id, sizeof(T)*a2.allocsize);
|
||||||
|
|
||||||
size = a2.size;
|
size = a2.size;
|
||||||
data = a2.data;
|
data = a2.data;
|
||||||
@ -969,7 +969,7 @@ namespace ngcore
|
|||||||
/// steal array
|
/// steal array
|
||||||
NETGEN_INLINE Array & operator= (Array && a2)
|
NETGEN_INLINE Array & operator= (Array && a2)
|
||||||
{
|
{
|
||||||
TraceMemoryChange(mem_tracing_id, sizeof(T)*(a2.allocsize-allocsize));
|
TraceMemorySwap(mem_tracing_id, sizeof(T)*allocsize, a2.mem_tracing_id, sizeof(T)*a2.allocsize);
|
||||||
|
|
||||||
ngcore::Swap (size, a2.size);
|
ngcore::Swap (size, a2.size);
|
||||||
ngcore::Swap (data, a2.data);
|
ngcore::Swap (data, a2.data);
|
||||||
@ -1044,13 +1044,12 @@ namespace ngcore
|
|||||||
|
|
||||||
NETGEN_INLINE void Swap (Array & b)
|
NETGEN_INLINE void Swap (Array & b)
|
||||||
{
|
{
|
||||||
TraceMemoryChange(mem_tracing_id, sizeof(T)*(b.allocsize-allocsize));
|
TraceMemorySwap(mem_tracing_id, sizeof(T)*allocsize, b.mem_tracing_id, sizeof(T)*b.allocsize);
|
||||||
|
|
||||||
ngcore::Swap (size, b.size);
|
ngcore::Swap (size, b.size);
|
||||||
ngcore::Swap (data, b.data);
|
ngcore::Swap (data, b.data);
|
||||||
ngcore::Swap (allocsize, b.allocsize);
|
ngcore::Swap (allocsize, b.allocsize);
|
||||||
ngcore::Swap (mem_to_delete, b.mem_to_delete);
|
ngcore::Swap (mem_to_delete, b.mem_to_delete);
|
||||||
ngcore::Swap (mem_tracing_id, b.mem_tracing_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NETGEN_INLINE void SetMemoryTracing (int mem_id)
|
NETGEN_INLINE void SetMemoryTracing (int mem_id)
|
||||||
|
@ -433,6 +433,28 @@ namespace ngcore
|
|||||||
trace->ChangeMemory(mem_id, size);
|
trace->ChangeMemory(mem_id, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NETGEN_INLINE void TraceMemorySwap( int mem_id, size_t size, int mem_id2, size_t size2 )
|
||||||
|
{
|
||||||
|
if(!trace || (mem_id==0 && mem_id2==0))
|
||||||
|
return;
|
||||||
|
if(mem_id == 0)
|
||||||
|
return trace->ChangeMemory(mem_id2, size-size2);
|
||||||
|
if(mem_id2 == 0)
|
||||||
|
return trace->ChangeMemory(mem_id, size2-size);
|
||||||
|
|
||||||
|
// first decrease memory, otherwise have artificial/wrong high peak memory usage
|
||||||
|
if(size<size2)
|
||||||
|
{
|
||||||
|
trace->ChangeMemory(mem_id2, size-size2);
|
||||||
|
trace->ChangeMemory(mem_id, size2-size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trace->ChangeMemory(mem_id, size2-size);
|
||||||
|
trace->ChangeMemory(mem_id2, size-size2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ngcore
|
} // namespace ngcore
|
||||||
|
|
||||||
// Helper macro to easily add multiple timers in a function for profiling
|
// Helper macro to easily add multiple timers in a function for profiling
|
||||||
|
Loading…
Reference in New Issue
Block a user