Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Posix_Profile.h
Go to the documentation of this file.
1 /* ############################ MALP License ############################## */
2 /* # Fri Jan 18 14:00:00 CET 2013 # */
3 /* # Copyright or (C) or Copr. Commissariat a l'Energie Atomique # */
4 /* # # */
5 /* # This software is governed by the CeCILL-C license under French law # */
6 /* # and abiding by the rules of distribution of free software. You can # */
7 /* # use, modify and/ or redistribute the software under the terms of # */
8 /* # the CeCILL-C license as circulated by CEA, CNRS and INRIA at the # */
9 /* # following URL http://www.cecill.info. # */
10 /* # # */
11 /* # The fact that you are presently reading this means that you have # */
12 /* # had knowledge of the CeCILL-C license and that you accept its # */
13 /* # terms. # */
14 /* # # */
15 /* # Authors: # */
16 /* # - BESNARD Jean-Baptiste jean-baptiste.besnard@cea.fr # */
17 /* # # */
18 /* ######################################################################## */
19 #ifndef POSIX_PROFILE_H
20 #define POSIX_PROFILE_H
21 
22 #define _GNU_SOURCE
23 #include <dlfcn.h>
24 
25 #include "Wrapped_Symbols.h"
26 
27 #include <stdint.h>
28 #include <string.h>
29 
30 #include "Spinlock.h"
31 
33 {
35 
36  uint64_t hits;
37  uint64_t time;
38  int64_t size;
39 
41 };
42 
44 
45 void Profile_Entry_init( struct Profile_Entry *ent, Wrapped_symbol id );
46 void Profile_Entry_release( struct Profile_Entry *ent );
47 
48 
49 void POSIX_profile_init();
54 
55 
57 {
58  if( (0 <= id) && (id < T_POSIX_COUNT) )
59  {
60  return &__POSIX_Profile_entries[id];
61  }
62 
63  return NULL;
64 }
65 
66 
67 static inline POSIX_profile_hit( Wrapped_symbol id, uint64_t duration, int64_t size )
68 {
69  struct Profile_Entry * ent = POSIX_profile_get_entry( id );
70 
71  if( !ent )
72  {
73  return;
74  }
75 
76  MALP_Spinlock_lock(&ent->lock);
77 
78  ent->hits++;
79  ent->time += duration;
80  ent->size += size;
81 
83 }
84 
85 
86 #endif /* POSIX_PROFILE_H */
void POSIX_profile_render()
static POSIX_profile_hit(Wrapped_symbol id, uint64_t duration, int64_t size)
Definition: Posix_Profile.h:67
void POSIX_profile_init()
Definition: Posix_Profile.c:45
static struct Profile_Entry * POSIX_profile_get_entry(Wrapped_symbol id)
Definition: Posix_Profile.h:56
uint64_t hits
Definition: Posix_Profile.h:36
int MALP_Spinlock_unlock(MALP_Spinlock *mutex)
Unlocks the given MALP_Spinlock.
Definition: Spinlock.c:41
Definition: Posix_Profile.h:32
void Profile_Entry_init(struct Profile_Entry *ent, Wrapped_symbol id)
Definition: Posix_Profile.c:34
Wrapped_symbol
enum indicating which symbols are wrapped
void POSIX_profile_release()
Definition: Posix_Profile.c:58
int MALP_Spinlock_lock(MALP_Spinlock *mutex)
Locks the given MALP_Spinlock.
Definition: Spinlock.c:29
Wrapped_symbol id
Definition: Posix_Profile.h:34
volatile unsigned int MALP_Spinlock
The type of spinlocks in MALP.
Definition: Spinlock.h:63
uint64_t time
Definition: Posix_Profile.h:37
void POSIX_profile_reduce()
Definition: Posix_Profile.c:67
struct Profile_Entry __POSIX_Profile_entries[T_POSIX_COUNT]
Definition: Posix_Profile.c:31
MALP_Spinlock lock
Definition: Posix_Profile.h:40
void Profile_Entry_release(struct Profile_Entry *ent)
Definition: Posix_Profile.c:40
void POSIX_profile_serialize()
int64_t size
Definition: Posix_Profile.h:38