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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 757 - (show annotations)
Mon Jun 26 13:12:56 2006 UTC (13 years, 2 months ago) by woo409
File MIME type: text/plain
File size: 3959 byte(s)
+ Merge of intelc_win32 branch (revision 741:755) with trunk. Tested on iVEC altix (run_tests and py_tests all pass)

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26