MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
scratch.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#include "scratch.h"
8
9using namespace std;
10
12size_t Scratch::m_number_of_elements; // = 100;
13
15char* Scratch::m_totalScratch; // = new MInt[Scratch::m_number_of_elements];;
21
22#if defined(MAIA_CLANG_COMPILER)
23#pragma GCC diagnostic push
24#pragma GCC diagnostic ignored "-Wcast-align"
25#endif
26
28 m_number_of_cells = Cells;
33
35 ASSERT((((uintptr_t)m_nextfree) % ALIGNMENT_BOUNDARY == 0), "Scratch memory is not aligned");
36
38}
39
40
49 stringstream begin, end, nextfree, number, total, totalmb, used, usedmb, available, availablemb, maxmem, maxmemmb;
50 const MFloat bytesInAMegaByte = 1048576.0;
51 begin << (MInt*)m_totalScratch;
52 end << (MInt*)getEndPointer();
53 nextfree << (MInt*)m_nextfree;
54 number << m_number_of_elements;
55 total << getTotalMemory();
56 totalmb << (MFloat)getTotalMemory() / bytesInAMegaByte;
57 used << m_usedmemsize;
58 usedmb << (MFloat)m_usedmemsize / bytesInAMegaByte;
59 available << getAvailableMemory();
60 availablemb << (MFloat)getAvailableMemory() / bytesInAMegaByte;
61 maxmem << (m_maxused - m_totalScratch);
62 maxmemmb << (MFloat)(m_maxused - m_totalScratch) / bytesInAMegaByte;
63
64 string message = "\n\nScratch:";
65 message += "\n-----------------------------\n";
66 message += "Bytes allocated:\t\t";
67 message += number.str();
68 message += "\nTotal memory:\t\t\t";
69 message += total.str();
70 message += "\t(";
71 message += totalmb.str();
72 message += "MB)";
73 message += "\nUsed memory:\t\t\t";
74 message += used.str();
75 message += "\t(";
76 message += usedmb.str();
77 message += "MB)";
78 message += "\nFree memory:\t\t\t";
79 message += available.str();
80 message += "\t(";
81 message += availablemb.str();
82 message += "MB)";
83 message += "\nMax memory:\t\t\t";
84 message += maxmem.str();
85 message += "\t(";
86 message += maxmemmb.str();
87 message += "MB)";
88 message += "\nScratch start pointer:\t\t";
89 message += begin.str();
90 message += "\nScratch end pointer:\t\t";
91 message += end.str();
92 message += "\nNext free pointer:\t\t";
93 message += nextfree.str();
94 message += "\n\n";
95
96 return message;
97}
98
107 string message = printSelfScratch();
108 ScratchList::iterator iter;
109
110 for(iter = Scratch::m_scratchSpaces.begin(); iter != Scratch::m_scratchSpaces.end(); iter++) {
111 message += (*iter)->printSelf();
112 message += "\n";
113 }
114
115 message += "\n\n";
116 return message;
117}
118
130 string message = m_report;
131 message += "\n\n";
132 return message;
133}
134
135#if defined(MAIA_CLANG_COMPILER)
136#pragma GCC diagnostic pop
137#endif
static size_t getAvailableMemory()
Returns the amount of available memory in scratch.
Definition: scratch.h:148
static MString m_report
Definition: scratch.h:171
static ScratchList m_scratchSpaces
Definition: scratch.h:169
static MString printSelfReport()
Returns a shortened string summing up the scratch space state information.
Definition: scratch.cpp:129
static const uintptr_t ALIGNMENT_BOUNDARY
Definition: scratch.h:94
static size_t m_number_of_elements
Definition: scratch.h:164
static MString printSelf()
Returns a string summing up the scratch state information and all scratch space elements information.
Definition: scratch.cpp:106
Scratch(MFloat size, MInt Cells)
Constructor.
Definition: scratch.cpp:27
static char * getEndPointer()
Returns a pointer to the end of the scratch.
Definition: scratch.h:137
static char * m_nextfree
Definition: scratch.h:168
static MString printSelfScratch()
Returns a string summing up the scratch state information.
Definition: scratch.cpp:48
static size_t getTotalMemory()
Returns the amount of total available memory in scratch.
Definition: scratch.h:157
static size_t m_number_of_cells
Definition: scratch.h:163
static char * m_maxused
Definition: scratch.h:170
static char * m_totalScratch
Definition: scratch.h:166
static MInt m_object_id
Definition: scratch.h:165
static size_t m_usedmemsize
Definition: scratch.h:167
const MString const MString & message
Definition: functions.h:37
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
std::list< ScratchSpaceBase * > ScratchList
Definition: scratch.h:80