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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 615 - (show annotations)
Wed Mar 22 02:12:00 2006 UTC (13 years, 5 months ago) by elspeth
File MIME type: text/plain
File size: 3919 byte(s)
More copyright information.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26