Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
vite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
solverstack
vite
Commits
a6f33bcf
Commit
a6f33bcf
authored
Dec 16, 2009
by
Mathieu Faverge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ViTE memory trace (first version)
parent
3cded88c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
611 additions
and
5 deletions
+611
-5
src/CMakeLists.txt
src/CMakeLists.txt
+4
-0
src/common/Memory.cpp
src/common/Memory.cpp
+285
-0
src/common/Memory.hpp
src/common/Memory.hpp
+211
-0
src/common/Tools.cpp
src/common/Tools.cpp
+27
-0
src/common/Tools.hpp
src/common/Tools.hpp
+4
-0
src/common/common.hpp
src/common/common.hpp
+3
-1
src/common/trace.h
src/common/trace.h
+49
-0
src/main.cpp
src/main.cpp
+28
-4
No files found.
src/CMakeLists.txt
View file @
a6f33bcf
...
...
@@ -48,6 +48,8 @@ SET(VITE_HDRS
common/Tools.hpp
common/info.hpp
common/Session.hpp
common/trace.h
common/Memory.hpp
# Data structure headers
trace/values/Color.hpp
trace/values/Date.hpp
...
...
@@ -134,6 +136,7 @@ SET(VITE_SRCS
common/Tools.cpp
common/info.cpp
common/Session.cpp
common/Memory.cpp
# Data structure code files
trace/values/Color.cpp
trace/values/Date.cpp
...
...
@@ -216,6 +219,7 @@ IF(VITE_ENABLE_OTF)
ENDIF
(
VITE_ENABLE_OTF
)
# ADD_DEFINITIONS(-DMEMORY_USAGE -DMEMORY_TRACE)
QT4_AUTOMOC
(
${
VITE_SRCS
}
)
FOREACH
(
_hdrs_file
${
VITE_HDRS
}
)
...
...
src/common/Memory.cpp
0 → 100644
View file @
a6f33bcf
/* Copyright INRIA 2004
**
** This file is part of the Scotch distribution.
**
** The Scotch distribution is libre/free software; you can
** redistribute it and/or modify it under the terms of the
** GNU Lesser General Public License as published by the
** Free Software Foundation; either version 2.1 of the
** License, or (at your option) any later version.
**
** The Scotch distribution is distributed in the hope that
** it will be useful, but WITHOUT ANY WARRANTY; without even
** the implied warranty of MERCHANTABILITY or FITNESS FOR A
** PARTICULAR PURPOSE. See the GNU Lesser General Public
** License for more details.
**
** You should have received a copy of the GNU Lesser General
** Public License along with the Scotch distribution; if not,
** write to the Free Software Foundation, Inc.,
** 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
**
** $Id: common_memory.c 176 2004-10-12 13:53:26Z goureman $
*/
/*
File: common_memory.c
Part of a parallel direct block solver.
This module handles errors.
Authors:
Mathieu Faverge - faverge@labri.fr
Xavier LACOSTE - lacoste@labri.fr
Francois PELLEGRINI - .
Dates:
Version 0.0 - from 07 sep 2001
to 07 sep 2001
Version 0.1 - from 14 apr 2001
to 24 mar 2003
Version 1.3 - from 25 feb 2004
to 25 feb 2004
*/
/*
** The defines and includes.
*/
#ifdef MEMORY_USAGE
#include <pthread.h>
#include "common/common.hpp"
#include "common/trace.h"
/*
Group: Variables
The static variables.
int: memallocmutexflag
Boolean indicating if <memallocmutexdat> mutex has been initialized.
pthread_mutex_t: memallocmutexdat
mutex protecting <memalloccurrent>, <memallocmax>, <memalloctraceflag>,
<trace_file>, <trace_timestamp> and <trace_procnum>
ulong: memalloccurrent
Current memory allocated using <memAlloc_func>.
ulong: memallocmax
Maximum value of memalloccurrent since the program started.
int: memalloctraceflag
Boolean indicating if we want to trace allocation.
stream: trace_file
File into which to write traces.
double: time_stamp
Origin of traces.
int: trace_procnum
Processor tracing allocations.
*/
extern
"C"
{
static
int
memallocmutexflag
=
0
;
static
pthread_mutex_t
memallocmutexdat
;
/*+ Local mutex +*/
unsigned
long
memalloccurrent
=
0
;
unsigned
long
memallocmax
=
0
;
int
memalloctraceflag
=
0
;
#ifdef MEMORY_TRACE
static
FILE
*
trace_file
;
static
double
trace_timestamp
;
static
int
trace_procnum
;
/*
Function: memAllocTrace
Start tracing memory.
Initialize <memallocmutexdat> if not done.
Defines all tracing variables.
Parameters:
file - Stream where to write traces, opened in write mode.
timestamp - Traces origin.
procnum - Processor writting traces.
Returns:
void - In all cases.
*/
void
memAllocTrace
(
FILE
*
file
,
double
timestamp
,
int
procnum
)
{
if
(
memallocmutexflag
==
0
)
{
/* If memory mutex not yet initialized */
memallocmutexflag
=
1
;
pthread_mutex_init
(
&
memallocmutexdat
,
NULL
);
/* Initialize local mutex */
}
pthread_mutex_lock
(
&
memallocmutexdat
);
/* Lock local mutex */
memalloctraceflag
=
1
;
trace_file
=
file
;
trace_timestamp
=
timestamp
;
trace_procnum
=
procnum
;
pthread_mutex_unlock
(
&
memallocmutexdat
);
/* UnLock local mutex */
}
/*
Function: memAllocUntrace
Stop tracing allocations.
Returns:
void - in all cases.
*/
void
memAllocUntrace
()
{
pthread_mutex_lock
(
&
memallocmutexdat
);
/* Lock local mutex */
memalloctraceflag
=
0
;
pthread_mutex_unlock
(
&
memallocmutexdat
);
/* UnLock local mutex */
}
#endif
/*
Function: memAllocGetCurrent
Get the current memory allocated.
Returns:
<memalloccurrent> value.
*/
unsigned
long
memAllocGetCurrent
()
{
return
(
memalloccurrent
);
}
/*
Function: memAllocGetMax
Get the maximu memory allocated.
Returns:
<memallocmax> value.
*/
unsigned
long
memAllocGetMax
()
{
return
(
memallocmax
);
}
/*
Function: memAllocTraceReset
Restarts tracing allocation with reseting <memallocmax>.
Returns:
void - in all cases.
*/
void
memAllocTraceReset
()
{
if
(
memallocmutexflag
==
0
)
{
/* If memory mutex not yet initialized */
memallocmutexflag
=
1
;
pthread_mutex_init
(
&
memallocmutexdat
,
NULL
);
/* Initialize local mutex */
}
pthread_mutex_lock
(
&
memallocmutexdat
);
/* Lock local mutex */
memalloctraceflag
=
1
;
memallocmax
=
0
;
pthread_mutex_unlock
(
&
memallocmutexdat
);
/* UnLock local mutex */
}
}
/*
Function: memAlloc_func
This is a thread-safe memory allocation routine.
Parameters:
size - Memory size wanted.
filename - Used for error message, file where the function is called.
line - Used for erro message, line where the function is called.
Returns:
!NULL - pointer to memory block.
NULL - no array allocated.
*/
void
*
operator
new
(
std
::
size_t
size
)
throw
(
std
::
bad_alloc
)
{
double
*
memptr
;
fprintf
(
stderr
,
"toto %d
\n
"
,
memalloctraceflag
);
// #ifdef DEBUG_ALLOC
// if (size == 0)
// errorPrint("%s:%d allocating 0\n",filename,line);
// #endif
if
(
memallocmutexflag
==
0
)
{
/* If memory mutex not yet initialized */
memallocmutexflag
=
1
;
pthread_mutex_init
(
&
memallocmutexdat
,
NULL
);
/* Initialize local mutex */
}
pthread_mutex_lock
(
&
memallocmutexdat
);
/* Lock local mutex */
memptr
=
(
double
*
)
operator
new
(
size
+
sizeof
(
double
),
std
::
nothrow
);
/* Add a double containing the size of the array */
if
(
memptr
!=
NULL
)
{
memptr
[
0
]
=
(
double
)
size
;
memalloccurrent
+=
(
unsigned
long
)
size
;
memallocmax
=
MAX
(
memallocmax
,
memalloccurrent
);
memptr
++
;
#ifdef MEMORY_TRACE
if
(
memalloctraceflag
==
1
)
trace_malloc
(
trace_file
,
(
clockGet
()
-
trace_timestamp
),
trace_procnum
,
STATE_ALLOC
,
memalloccurrent
);
#endif
}
else
{
// fprintf (stderr, "File : %s:%d\nECHEC Occupe : %lu Demande : %lu\n",
// filename, line, memalloccurrent, (unsigned long)size);
fprintf
(
stderr
,
"ECHEC Occupe : %lu Demande : %lu
\n
"
,
memalloccurrent
,
(
unsigned
long
)
size
);
}
pthread_mutex_unlock
(
&
memallocmutexdat
);
/* Unlock local mutex */
return
((
void
*
)
memptr
);
}
/*
Function: operator delete
This is a thread-safe memory deallocation routine.
It returns:
void - in all cases
*/
void
operator
delete
(
void
*
memptr
)
{
double
*
newmemptr
;
fprintf
(
stderr
,
"tutu
\n
"
);
pthread_mutex_lock
(
&
memallocmutexdat
);
/* Lock local mutex */
if
(
!
(
memptr
==
NULL
)){
newmemptr
=
(
double
*
)
memptr
;
newmemptr
--
;
memalloccurrent
-=
(
unsigned
long
)
newmemptr
[
0
]
;
operator
delete
(
newmemptr
,
std
::
nothrow
);
#ifdef MEMORY_TRACE
if
(
memalloctraceflag
)
trace_malloc
(
trace_file
,
(
clockGet
()
-
trace_timestamp
),
trace_procnum
,
STATE_FREE
,
memalloccurrent
);
#endif
}
pthread_mutex_unlock
(
&
memallocmutexdat
);
/* Unlock local mutex */
}
#endif
/* MEMORY_USAGE */
src/common/Memory.hpp
0 → 100644
View file @
a6f33bcf
/* Copyright INRIA 2004
**
** This file is part of the Scotch distribution.
**
** The Scotch distribution is libre/free software; you can
** redistribute it and/or modify it under the terms of the
** GNU Lesser General Public License as published by the
** Free Software Foundation; either version 2.1 of the
** License, or (at your option) any later version.
**
** The Scotch distribution is distributed in the hope that
** it will be useful, but WITHOUT ANY WARRANTY; without even
** the implied warranty of MERCHANTABILITY or FITNESS FOR A
** PARTICULAR PURPOSE. See the GNU Lesser General Public
** License for more details.
**
** You should have received a copy of the GNU Lesser General
** Public License along with the Scotch distribution; if not,
** write to the Free Software Foundation, Inc.,
** 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
**
** $Id: common_memory.c 176 2004-10-12 13:53:26Z goureman $
*/
/*
File: common_memory.c
Part of a parallel direct block solver.
This module handles errors.
Authors:
Mathieu Faverge - faverge@labri.fr
Xavier LACOSTE - lacoste@labri.fr
Francois PELLEGRINI - .
Dates:
Version 0.0 - from 07 sep 2001
to 07 sep 2001
Version 0.1 - from 14 apr 2001
to 24 mar 2003
Version 1.3 - from 25 feb 2004
to 25 feb 2004
Version 2.0 (C++)
- from 16 dec 2009
- to 16 dec 2009
*/
/*
** The defines and includes.
*/
#ifndef MEMORY_HPP
#define MEMORY_HPP
#ifdef MEMORY_USAGE
#include <cstdlib>
#include <pthread.h>
/*
Group: Variables
The static variables.
int: memallocmutexflag
Boolean indicating if <memallocmutexdat> mutex has been initialized.
pthread_mutex_t: memallocmutexdat
mutex protecting <memalloccurrent>, <memallocmax>, <memalloctraceflag>,
<trace_file>, <trace_timestamp> and <trace_procnum>
ulong: memalloccurrent
Current memory allocated using <memAlloc_func>.
ulong: memallocmax
Maximum value of memalloccurrent since the program started.
int: memalloctraceflag
Boolean indicating if we want to trace allocation.
stream: trace_file
File into which to write traces.
double: time_stamp
Origin of traces.
int: trace_procnum
Processor tracing allocations.
*/
extern
"C"
{
#ifdef MEMORY_TRACE
/*
Function: memAllocTrace
Start tracing memory.
Initialize <memallocmutexdat> if not done.
Defines all tracing variables.
Parameters:
file - Stream where to write traces, opened in write mode.
timestamp - Traces origin.
procnum - Processor writting traces.
Returns:
void - In all cases.
*/
void
memAllocTrace
(
FILE
*
file
,
double
timestamp
,
int
procnum
);
/*
Function: memAllocUntrace
Stop tracing allocations.
Returns:
void - in all cases.
*/
void
memAllocUntrace
();
#endif
/*
Function: memAllocGetCurrent
Get the current memory allocated.
Returns:
<memalloccurrent> value.
*/
unsigned
long
memAllocGetCurrent
();
/*
Function: memAllocGetMax
Get the maximu memory allocated.
Returns:
<memallocmax> value.
*/
unsigned
long
memAllocGetMax
();
/*
Function: memAllocTraceReset
Restarts tracing allocation with reseting <memallocmax>.
Returns:
void - in all cases.
*/
void
memAllocTraceReset
();
};
/*
Function: operator new
This is a thread-safe memory allocation routine.
Parameters:
size - Memory size wanted.
filename - Used for error message, file where the function is called.
line - Used for erro message, line where the function is called.
Returns:
!NULL - pointer to memory block.
NULL - no array allocated.
*/
void
*
operator
new
(
std
::
size_t
size
)
throw
(
std
::
bad_alloc
);
/*
Function: operator new[]
This is a thread-safe memory allocation routine.
Parameters:
size - Memory size wanted.
filename - Used for error message, file where the function is called.
line - Used for erro message, line where the function is called.
Returns:
!NULL - pointer to memory block.
NULL - no array allocated.
*/
//void *operator new[](std::size_t size) throw(std::bad_alloc);
/*
Function: operator delete
This is a thread-safe memory deallocation routine.
It returns:
void - in all cases
*/
void
operator
delete
(
void
*
memptr
);
/*
Function: operator delete[]
This is a thread-safe memory deallocation routine.
It returns:
void - in all cases
*/
//void operator delete[](void *memptr);
#endif
/* MEMORY_USAGE */
#endif
/* MEMORY_HPP */
src/common/Tools.cpp
View file @
a6f33bcf
...
...
@@ -47,6 +47,7 @@
#include <QObject> // For translations
/* -- */
#include <locale.h> // For dots or commas separator in double numbers
#include <time.h>
/* -- */
#include "Tools.hpp"
/* -- */
...
...
@@ -91,3 +92,29 @@ double convert_to_double(const string arg){
}
}
/*
Function: clockGet
Timing routine.
Uses different timing routines depending on the machine architecture.
Returns:
Returns the time ellapsed since <clockStart>.
*/
double
clockGet
(
void
)
{
#if (defined X_ARCHalpha_compaq_osf1) || (defined X_ARCHi686_mac)
struct
rusage
data
;
getrusage
(
RUSAGE_SELF
,
&
data
);
return
(((
double
)
data
.
ru_utime
.
tv_sec
+
(
double
)
data
.
ru_stime
.
tv_sec
)
+
((
double
)
data
.
ru_utime
.
tv_usec
+
(
double
)
data
.
ru_stime
.
tv_usec
)
*
1.0e-6L
);
#else
struct
timespec
tp
;
clock_gettime
(
CLOCK_REALTIME
,
&
tp
);
/* Elapsed time */
return
((
double
)
tp
.
tv_sec
+
(
double
)
tp
.
tv_nsec
*
(
double
)
1.0e-9L
);
#endif
}
src/common/Tools.hpp
View file @
a6f33bcf
...
...
@@ -58,5 +58,9 @@
*/
double
convert_to_double
(
const
std
::
string
args
);
#define MIN(x,y) (((x)<(y))?(x):(y))
#define MAX(x,y) (((x)<(y))?(y):(x))
double
clockGet
(
void
);
#endif // TOOLS_HPP
src/common/common.hpp
View file @
a6f33bcf
...
...
@@ -58,8 +58,10 @@
#include <sstream>
/* -- */
/* -- */
#include "common/Errors.hpp"
/*
Message
management */
#include "common/Errors.hpp"
/*
Errors
management */
#include "common/Message.hpp"
/* Message management */
#include "common/Tools.hpp"
/* Tools */
#include "common/Memory.hpp"
/* Memory management */
/* Example:
* *Message::get_instance() << "Test:" << 45 << " and " << true << Message::endi;
* -> display as an informative message.
...
...
src/common/trace.h
0 → 100644
View file @
a6f33bcf
/*
File: trace.h
trace instruction for different format
Authors:
Mathieu Faverge - faverge@labri.fr
Dates:
Varsion 0.0 - from 12 apr 2008
to 12 apr 2008
*/
#ifndef TRACE_H
#define TRACE_H
typedef
enum
Trace_State
{
STATE_ALLOC
=
27
,
STATE_FREE
=
28
}
Trace_State_t
;
/*
* Common part :
* - TraceFmt_t fmt : Format de trace
* - FILE *file : fichier de trace
* - double time : timestamp
* - INT procnum
* - INT thrdnum
* State :
* - INT level : niveau de trace (+il est grand plus c'est dtaill)
* - Trace_State_T state : Etat dans lequel se retrouve le proc
* - INT id : identifiant de la tche
* Comm :
* - INT dest/src : destinataire ou source du message
* - Trace_Comm_t Type : type de communication
* - INT id : identifiant du message
* - INT size : taille du message
*/
#define trace_start(file, time, procnum, thrdnum) \
fprintf(file, "%9.9lf %ld %ld 0 -1 0\n", (double)time, (long)(procnum), (long)(thrdnum));
#define trace_finish(file, time, procnum, thrdnum) \
fprintf(file, "%9.9lf %ld %ld 0 -1 1\n", (double)time, (long)(procnum), (long)(thrdnum));
#define trace_malloc(file, time, procnum, state, memory) \
fprintf(file, "%9.9lf %ld 0 0 4 %ld %f\n", \
(double)time, (long)procnum, (long)state, (double)memory/(1<<20));
#endif
/* TRACE_H */
src/main.cpp
View file @
a6f33bcf
...
...
@@ -62,9 +62,13 @@
#include <QApplication>
#include <cstdio>
/* Global informations */
#include "common/common.hpp"
#ifdef MEMORY_TRACE
#include "common/trace.h"
#endif
/* -- */
#include "common/info.hpp"
...
...
@@ -81,12 +85,32 @@