Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
Teuchos_Details_Allocator.cpp
1
// @HEADER
2
// *****************************************************************************
3
// Teuchos: Common Tools Package
4
//
5
// Copyright 2004 NTESS and the Teuchos contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#include <
Teuchos_Details_Allocator.hpp
>
11
#include <sstream>
12
13
namespace
Teuchos
{
14
namespace
Details {
15
16
void
17
AllocationLogger::
18
logAllocation
(std::ostream& out,
19
const
size_type
numEntries,
20
const
size_type
numBytes,
21
const
char
typeName
[],
22
const
bool
verbose)
23
{
24
using
std::endl;
25
curAllocInBytes_ += numBytes;
26
if
(curAllocInBytes_ > maxAllocInBytes_) {
27
maxAllocInBytes_ = curAllocInBytes_;
28
}
29
30
if
(verbose) {
31
// Identify this as a Teuchos allocation.
32
out <<
"Teuchos,alloc,"
<< numEntries <<
","
<<
typeName
<<
","
<< numBytes << endl;
33
}
34
}
35
36
void
37
AllocationLogger::
38
logDeallocation
(std::ostream& out,
39
const
size_type
numEntries,
40
const
size_type
numBytes,
41
const
char
typeName
[],
42
const
bool
verbose)
43
{
44
using
std::endl;
45
curAllocInBytes_ -= numBytes;
46
47
if
(verbose) {
48
// First field identifies this as a Teuchos allocation. Use the
49
// same number of characters for "deall"(ocation) as
50
// "alloc"(ation) above, so that the columns line up nicely for
51
// human reading. Print deallocations as negative allocations.
52
// This makes it easy for a sed or awk script to compute totals.
53
out <<
"Teuchos,deall,-"
<< numEntries <<
","
<<
typeName
54
<<
",-"
<< numBytes << endl;
55
}
56
}
57
58
AllocationLogger::size_type
59
AllocationLogger::curAllocInBytes
() {
return
curAllocInBytes_; }
60
61
AllocationLogger::size_type
62
AllocationLogger::maxAllocInBytes
() {
return
maxAllocInBytes_; }
63
64
void
65
AllocationLogger::resetAllocationCounts
()
66
{
67
curAllocInBytes_ = 0;
68
maxAllocInBytes_ = 0;
69
}
70
71
AllocationLogger::size_type
AllocationLogger::curAllocInBytes_ = 0;
72
AllocationLogger::size_type
AllocationLogger::maxAllocInBytes_ = 0;
73
74
}
// namespace Details
75
}
// namespace Teuchos
Teuchos_Details_Allocator.hpp
Declaration of Teuchos::Details::Allocator, a tracking and logging implementation of the C++ Standard...
Teuchos::Details::AllocationLogger::resetAllocationCounts
static void resetAllocationCounts()
Reset the current and max total allocation numbers to zero.
Definition
Teuchos_Details_Allocator.cpp:65
Teuchos::Details::AllocationLogger::curAllocInBytes
static size_type curAllocInBytes()
Current total allocation in bytes.
Definition
Teuchos_Details_Allocator.cpp:59
Teuchos::Details::AllocationLogger::logAllocation
static void logAllocation(std::ostream &out, const size_type numEntries, const size_type numBytes, const char typeName[], const bool verbose)
Log an allocation.
Definition
Teuchos_Details_Allocator.cpp:18
Teuchos::Details::AllocationLogger::maxAllocInBytes
static size_type maxAllocInBytes()
Max total allocation ("high water mark") in bytes.
Definition
Teuchos_Details_Allocator.cpp:62
Teuchos::Details::AllocationLogger::size_type
std::size_t size_type
Type of the size of an allocation or deallocation.
Definition
Teuchos_Details_Allocator.hpp:48
Teuchos::Details::AllocationLogger::logDeallocation
static void logDeallocation(std::ostream &out, const size_type numEntries, const size_type numBytes, const char typeName[], const bool verbose)
Log a deallocation, that was previously logged using logAllocation().
Definition
Teuchos_Details_Allocator.cpp:38
Teuchos::typeName
std::string typeName(const T &t)
Template function for returning the concrete type name of a passed-in object.
Definition
Teuchos_TypeNameTraits.hpp:83
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Generated by
1.17.0