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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1312 - (show annotations)
Mon Sep 24 06:18:44 2007 UTC (12 years ago) by ksteube
File MIME type: text/plain
File size: 3941 byte(s)
The MPI branch is hereby closed. All future work should be in trunk.

Previously in revision 1295 I merged the latest changes to trunk into trunk-mpi-branch.
In this revision I copied all files from trunk-mpi-branch over the corresponding
trunk files. I did not use 'svn merge', it was a copy.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26