/[escript]/trunk/escript/src/Taipan.h
ViewVC logotype

Diff of /trunk/escript/src/Taipan.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/esys2/escript/src/Data/Taipan.h revision 121 by jgs, Fri May 6 04:26:16 2005 UTC trunk/escript/src/Taipan.h revision 474 by jgs, Mon Jan 30 04:23:44 2006 UTC
# Line 15  Line 15 
15  #if !defined escript_Taipan_20050427_H  #if !defined escript_Taipan_20050427_H
16  #define escript_Taipan_20050427_H  #define escript_Taipan_20050427_H
17    
18    #include <iostream>
19    #include <cassert>
20    
21    #ifdef _OPENMP
22    #include <omp.h>
23    #endif
24    
25  namespace escript {  namespace escript {
26    
27  /**  /**
# Line 26  namespace escript { Line 33  namespace escript {
33     Taipan: data-array manager.     Taipan: data-array manager.
34    
35     The Taipan data-array manager holds a set of (dim x N) arrays distributed across a number of threads.     The Taipan data-array manager holds a set of (dim x N) arrays distributed across a number of threads.
36     If a (dim x N) array is requested via the Taipan allocator, the pool of managed arrays is searched for     If a (dim x N) array is requested via the Taipan allocator, the buffer of managed arrays is searched for
37     a free array of this size on the current number of threads. If none is available, a new one is allocated     a free array of this size on the current number of threads. If none is available, a new one is allocated
38     and added to the pool of managed arrays.     and added to the buffer of managed arrays.
39    
40     When a managed array is deallocated, the array is marked as free but not returned to the system as long     When a managed array is deallocated, the array is marked as free but not returned to the system as long
41     as at least one array with dimension N is in use. Otherwise all arrays with second dimsenion N are     as at least one array of N is in use. Otherwise all arrays of N are deallocated as it is assumed that
42     deallocated as it is assumed that arrays with second dimension N will not be used anymore.     these arrays not be used anymore. The exceptions to this strategy are arrays with N=0 or N=1, these
43       arrays are never deallocated, but are kept for possible reuse.
    Template Parameters:  
    For templates describe any conditions that the parameters used in the  
    template must satisfy  
44  */  */
45    
46  class Taipan {  class Taipan {
# Line 80  class Taipan { Line 84  class Taipan {
84       The parameter "dim" defines the contiguous "blocksize" within the array.       The parameter "dim" defines the contiguous "blocksize" within the array.
85       Where the array is allocated accross multiple threads, it will be split       Where the array is allocated accross multiple threads, it will be split
86       on block boundaries only. N defines the number of "blocks" in the array.       on block boundaries only. N defines the number of "blocks" in the array.
   
      Where escript Data objects are concerned, N corresponds to the number of samples,  
      and dim correesponds to the number of data-points per sample multiplied by the  
      number of entries in a data-point.  
87    */    */
88    double*    double*
89    new_array(int dim, int N);    new_array(int dim, int N);
# Line 124  class Taipan { Line 124  class Taipan {
124    */    */
125    long    long
126    num_elements();    num_elements();
127    
128      /**
129         \brief
130         Print out statistics on the memory under management.
131      */
132      void
133      dump_stats();
134    
135      /**
136         \brief
137         Clear record of statistics on the memory under management.
138      */
139      void
140      clear_stats();
141    
142   protected:   protected:
143    
144   private:   private:
145    
146      typedef struct Taipan_StatTable {
147        int requests;
148        int frees;
149        int allocations;
150        int deallocations;
151        long allocated_elements;
152        long deallocated_elements;
153        long max_tab_size;
154      } Taipan_StatTable;
155    
156      Taipan_StatTable* statTable;
157    
158    typedef struct Taipan_MemTable {    typedef struct Taipan_MemTable {
159      double* array;      double* array;
160      int dim;      int dim;

Legend:
Removed from v.121  
changed lines
  Added in v.474

  ViewVC Help
Powered by ViewVC 1.1.26