23int Memoire::step=4096;
25static int max_sz_mem=0;
26static int min_sz_mem=0;
34 if (_instance == 0) _instance =
new Memoire;
45 for(
int i=prems; i<size; i++)
56 assert(_instance != 0);
61 assert(data[num].libre());
78 Cerr <<
"Not enough memory " << finl;
82 for(i=0; i<old_size; i++)
87 newdata[old_size]=newptr;
88 for(i=old_size; i<size; i++)
108 assert(!data[num].libre());
109 data[num].next=prems;
113#ifndef _COMPILE_AVEC_PGCC
114 if((size>4*compteur)&&(size>step))
169 for(
int i=0; i<size; i++)
171 if( !( x->
libre() ) )
172 if ( ((x->
obj()).que_suis_je()==type) &&
173 ((x->
obj()).le_nom()==nom) )
189 for(
int i=0; i<size; i++)
190 if( !( x->
libre() ) )
192 if (((x->
obj()).le_nom())==nom)
210 assert(!data[num].libre());
211 Objet_U& objet = data[num].obj();
212 const int num_obj = objet.
numero();
215 Cerr <<
"Error in Objet_U & Memoire::objet_u(int num) " << finl;
216 Cerr <<
" num = " << num << finl;
217 std::cerr <<
" data[num].o_ptr = " << &objet << std::endl;
218 Cerr <<
" data[num].o_ptr->numero() = " << num_obj << finl;
236 assert(!data[num].libre());
237 Objet_U& objet = data[num].obj();
238 const int num_obj = objet.
numero();
241 Cerr <<
"Error in const Objet_U & Memoire::objet_u(int num) " << finl;
242 Cerr <<
" num = " << num << finl;
243 std::cerr <<
" data[num].o_ptr = " << &objet << std::endl;
244 Cerr <<
" data[num].o_ptr->numero() = " << num_obj << finl;
262 assert(!data[num].libre());
263 Objet_U& objet = data[num].obj();
264 const int num_obj = objet.
numero();
267 Cerr <<
"Error in Objet_U * Memoire::objet_u(int num) " << finl;
268 Cerr <<
" num = " << num << finl;
269 std::cerr <<
" data[num].o_ptr = " << &objet << std::endl;
270 Cerr <<
" data[num].o_ptr->numero() = " << num_obj << finl;
288 assert(!data[num].libre());
289 Objet_U& objet = data[num].obj();
290 const int num_obj = objet.
numero();
293 Cerr <<
"Error in const Objet_U * Memoire::objet_u(int num) " << finl;
294 Cerr <<
" num = " << num << finl;
295 std::cerr <<
" data[num].o_ptr = " << &objet << std::endl;
296 Cerr <<
" data[num].o_ptr->numero() = " << num_obj << finl;
309 int* newnum=
new int[size];
312 Cerr <<
"Not enough memory " << finl;
315 for(i=0; i<size; i++)
320 for(i=0; i<size; i++)
328 Cerr <<
"Not enough memory " << finl;
331 for(i=0; i< size; i++)
333 newdata[newnum[i]]=data[i];
338 for(i=0; i<size; i++)
349 assert(prems <=size);
351 for(i=0; i<size; i++)
352 if(! data[i].libre()) tmp++;
353 Cerr <<
"\n There are " << size <<
" memory squares";
354 Cerr <<
"\n of which " << tmp <<
" ==(const char*)" << compteur <<
" are used" << finl;
355 for(i=0; i<size; i++)
357 Cerr << i <<
" :: " << flush;
358 if(! (data[i].libre()) )
360 const Objet_U& obj=data[i].obj();
365 Cerr <<
"TYPE :" << obj.
le_type()<< flush;
369 Cerr <<
" key: " << x << flush;
372 Cerr <<
" NAME : " << obj.
le_nom() << flush;
373 Cerr <<
" address : " << (long)(&(obj))<< flush;
374 Cerr <<
" SIZE : " << (int)(obj.
taille_memoire())<<
" bytes"<< flush;
390 assert(prems <=size);
391 for(
int i=0; i<size; i++)
393 if(! (data[i].libre()) )
395 if ((data[i].obj()).numero() != i)
397 Cerr <<
"ERROR at the square " << i << finl;
418 for(i=0; i<mem.size; i++)
419 if(! mem.data[i].
libre()) tmp++;
420 os <<
"\n There are " << mem.size <<
" memory slots";
421 os <<
"\n of which " << tmp <<
" ==(const char*)" << compteur <<
" are used" << finl;
422 for(i=0; i<mem.size; i++)
423 if(! mem.data[i].
libre())
428 os <<
"TYPE :" << obj.
le_type();
429 if(sub_type(
Nom,obj)) os <<
" NAME : " << obj.
le_nom() ;
430 os <<
" address : " << (long)(&(obj));
432 const ArrOfInt* intA =
dynamic_cast<const ArrOfInt*
>(&obj);
433 const ArrOfDouble* intAD =
dynamic_cast<const ArrOfDouble*
>(&obj);
436 const ArrOfInt& toto = *intA;
438 os <<
" SIZE ArrOfInt:" << tmp<<
" bytes";
440 const IntVect* intV =
dynamic_cast<const IntVect*
>(&obj);
443 const IntVect& titi = *intV;
445 os <<
" of which:" << (tmp-tmp1) <<
" virtual bytes ";
451 const ArrOfDouble& toto = *intAD;
453 os <<
" SIZE ArrOfDouble:" << tmp<<
" bytes";
465 const ArrOfFloat* intAF =
dynamic_cast<const ArrOfFloat*
>(&obj);
468 const ArrOfFloat& toto = *intAF;
470 os <<
" SIZE ArrOfFloat:" << tmp<<
" bytes";
481 os <<
"Max memory size (MB): " << max_sz_mem << finl;
482 os <<
"Min memory size (MB): " << min_sz_mem << finl;
483 os <<
"Used memory size (MB): " << (max_sz_mem-min_sz_mem)/1024/1024 << finl;
485 return os <<
"Total occupied memory size (MB): " << total/1024/1024 << finl;
Pointer within the TRUST memory for an Objet_U.
void set(Objet_U *ptr)
Assigns an Objet_U to a memory pointer.
Objet_U & obj()
Returns a reference to the Objet_U pointed to by the memory pointer.
int libre() const
Indicates whether the memory pointer is free, i.e. whether it points to a non-null Objet_U.
int rang(const Nom &type, const Nom &nom) const
Returns the index in memory of the object with the given type and name.
Objet_U & objet_u(int)
Returns a reference to the Objet_U at index num in memory.
int verifie() const
Verifies the content of all memory slots.
Objet_U * objet_u_ptr(int)
Returns a pointer to the Objet_U at index num in memory.
void compacte()
Compacts memory. This compaction is performed automatically when it becomes necessary.
static Memoire & Instance()
Returns a pointer to the memory instance. Creates a new memory object if no instance has been created...
int suppr(int)
Removes from memory the Objet_U with index num. The Objet_U itself is not deleted; only its pointer i...
Memoire()
Constructor. Initializes a working area for Objet_U, "double", and "int" objects.
int imprime() const
Prints a memory state summary to the error output stream.
int add(Objet_U *)
Adds an Objet_U to the TRUST memory.
class Nom: a character string for naming TRUST objects.
Base class for TRUST objects (Objet_U).
virtual unsigned taille_memoire() const =0
int numero() const
Returns the index of the object in Memoire::data.
virtual int change_num(const int *const)
Changes the internal number of the Objet_U.
const char * le_type() const
Returns the type name of the Objet_U.
virtual const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.
_SIZE_ size_array() const