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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2881 - (show annotations)
Thu Jan 28 02:03:15 2010 UTC (9 years, 6 months ago) by jfenwick
File MIME type: text/plain
File size: 4224 byte(s)
Don't panic.
Updating copyright stamps

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #if !defined escript_Taipan_20050427_H
16 #define escript_Taipan_20050427_H
17 #include "system_dep.h"
18
19 namespace escript {
20
21 /**
22 \brief
23 Taipan array manager, C++ version.
24 Based on TaipanMemManager C module by Lutz Gross.
25
26 Description:
27 Taipan: data-array manager.
28
29 The Taipan data-array manager holds a set of (dim x N) arrays distributed across a number of threads.
30 If a (dim x N) array is requested via the Taipan allocator, the buffer of managed arrays is searched for
31 a free array of this size on the current number of threads. If none is available, a new one is allocated
32 and added to the buffer of managed arrays.
33
34 When a managed array is deallocated, the array is marked as free but not returned to the system as long
35 as at least one array of N is in use. Otherwise all arrays of N are deallocated as it is assumed that
36 these arrays not be used anymore. The exceptions to this strategy are arrays with N=0 or N=1, these
37 arrays are never deallocated, but are kept for possible reuse.
38 */
39
40 class ESCRIPT_DLL_API Taipan {
41
42 public:
43
44 typedef long size_type; // needs to be parallelised by openmp. It should not take negative values.
45 // do not assume that it is unsigned though
46
47 /**
48 \brief
49 Default constructor for Taipan data-array manager.
50
51 Description:
52 Default constructor for Taipan data-array manager.
53
54 Preconditions:
55 Describe any preconditions
56
57 Throws:
58 Describe any exceptions thrown
59 */
60 Taipan();
61
62 /**
63 \brief
64 Default destructor for Taipan data-array manager.
65
66 Description:
67 Default destructor for Taipan data-array manager.
68
69 Preconditions:
70 Describe any preconditions
71
72 Throws:
73 Describe any exceptions thrown
74 */
75 ~Taipan();
76
77 /**
78 \brief
79 Taipan data-array allocator.
80
81 The parameter "dim" defines the contiguous "blocksize" within the array.
82 Where the array is allocated accross multiple threads, it will be split
83 on block boundaries only. N defines the number of "blocks" in the array.
84 */
85 double*
86 new_array(size_type dim, size_type N);
87
88 /**
89 \brief
90 Taipan data-array deallocator.
91
92 The parameter "array" should be an array object that was returned by Taipan::new_array.
93 */
94 void
95 delete_array(double* array);
96
97 /**
98 \brief
99 frees all arrays that are currently unused.
100
101 */
102 void
103 release_unused_arrays();
104
105 /**
106 \brief
107 Calculate the total number of arrays currently under management.
108 */
109 int
110 num_arrays();
111
112 /**
113 \brief
114 Calculate the total number of arrays of N blocks currently under management.
115 */
116 int
117 num_arrays(size_type N);
118
119 /**
120 \brief
121 Calculate the total number of free arrays of N blocks currently under management.
122 */
123 int
124 num_free(size_type N);
125
126 /**
127 \brief
128 Return the total number of array elements currently under management.
129 */
130 long
131 num_elements();
132
133 /**
134 \brief
135 Print out statistics on the memory under management.
136 */
137 void
138 dump_stats();
139
140 /**
141 \brief
142 Clear record of statistics on the memory under management.
143 */
144 void
145 clear_stats();
146
147 protected:
148
149 private:
150 /**
151 Declared (private) as a precaution to ensure that noone tries to copy instances.
152 */
153 void operator=(const Taipan& c){}
154
155 typedef struct Taipan_StatTable {
156 int requests;
157 int frees;
158 int allocations;
159 int deallocations;
160 long allocated_elements;
161 long deallocated_elements;
162 long max_tab_size;
163 } Taipan_StatTable;
164
165 Taipan_StatTable* statTable;
166
167 typedef struct Taipan_MemTable {
168 double* array;
169 size_type dim;
170 size_type N;
171 int numThreads;
172 bool free;
173 struct Taipan_MemTable* next;
174 } Taipan_MemTable;
175
176 Taipan_MemTable* memTable_Root;
177
178 long totalElements;
179
180 };
181
182 } // end of namespace
183
184 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26