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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 149 - (hide annotations)
Thu Sep 1 03:31:39 2005 UTC (14 years, 5 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/Taipan.h
File MIME type: text/plain
File size: 4442 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-01

1 jgs 121 /*
2     ******************************************************************************
3     * *
4     * COPYRIGHT ACcESS 2004 - All Rights Reserved *
5     * *
6     * This software is the property of ACcESS. No part of this code *
7     * may be copied in any form or by any means without the expressed written *
8     * consent of ACcESS. Copying, use or modification of this software *
9     * by any unauthorised person is illegal unless that person has a software *
10     * license agreement with ACcESS. *
11     * *
12     ******************************************************************************
13     */
14    
15     #if !defined escript_Taipan_20050427_H
16     #define escript_Taipan_20050427_H
17    
18     namespace escript {
19    
20     /**
21     \brief
22     Taipan array manager, C++ version.
23     Based on TaipanMemManager C module by Lutz Gross.
24    
25     Description:
26     Taipan: data-array manager.
27    
28     The Taipan data-array manager holds a set of (dim x N) arrays distributed across a number of threads.
29     If a (dim x N) array is requested via the Taipan allocator, the pool of managed arrays is searched for
30     a free array of this size on the current number of threads. If none is available, a new one is allocated
31     and added to the pool of managed arrays.
32    
33     When a managed array is deallocated, the array is marked as free but not returned to the system as long
34     as at least one array with dimension N is in use. Otherwise all arrays with second dimsenion N are
35     deallocated as it is assumed that arrays with second dimension N will not be used anymore.
36    
37     Template Parameters:
38     For templates describe any conditions that the parameters used in the
39     template must satisfy
40     */
41    
42     class Taipan {
43    
44     public:
45    
46     /**
47     \brief
48     Default constructor for Taipan data-array manager.
49    
50     Description:
51     Default constructor for Taipan data-array manager.
52    
53     Preconditions:
54     Describe any preconditions
55    
56     Throws:
57     Describe any exceptions thrown
58     */
59     Taipan();
60    
61     /**
62     \brief
63     Default destructor for Taipan data-array manager.
64    
65     Description:
66     Default destructor for Taipan data-array manager.
67    
68     Preconditions:
69     Describe any preconditions
70    
71     Throws:
72     Describe any exceptions thrown
73     */
74     ~Taipan();
75    
76     /**
77     \brief
78     Taipan data-array allocator.
79    
80     The parameter "dim" defines the contiguous "blocksize" within the array.
81     Where the array is allocated accross multiple threads, it will be split
82     on block boundaries only. N defines the number of "blocks" in the array.
83    
84     Where escript Data objects are concerned, N corresponds to the number of samples,
85     and dim correesponds to the number of data-points per sample multiplied by the
86     number of entries in a data-point.
87     */
88     double*
89     new_array(int dim, int N);
90    
91     /**
92     \brief
93     Taipan data-array deallocator.
94    
95     The parameter "array" should be an array object that was returned by Taipan::new_array.
96     */
97     void
98     delete_array(double* array);
99    
100     /**
101     \brief
102     Calculate the total number of arrays currently under management.
103     */
104     int
105     num_arrays();
106    
107     /**
108     \brief
109     Calculate the total number of arrays of N blocks currently under management.
110     */
111     int
112     num_arrays(int N);
113    
114     /**
115     \brief
116     Calculate the total number of free arrays of N blocks currently under management.
117     */
118     int
119     num_free(int N);
120    
121     /**
122     \brief
123     Return the total number of array elements currently under management.
124     */
125     long
126     num_elements();
127 jgs 149
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 jgs 121
142     protected:
143    
144     private:
145    
146 jgs 149 typedef struct Taipan_StatTable {
147     int allocs;
148     int deallocs;
149     int arrays;
150     int dearrays;
151     long elements;
152     long deelements;
153     } Taipan_StatTable;
154    
155     Taipan_StatTable* statTable;
156    
157 jgs 121 typedef struct Taipan_MemTable {
158     double* array;
159     int dim;
160     int N;
161     int numThreads;
162     bool free;
163     struct Taipan_MemTable* next;
164     } Taipan_MemTable;
165    
166     Taipan_MemTable* memTable_Root;
167    
168     long totalElements;
169    
170     };
171    
172     } // end of namespace
173    
174     #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26