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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 121 - (hide annotations)
Fri May 6 04:26:16 2005 UTC (14 years, 9 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/Taipan.h
File MIME type: text/plain
File size: 4026 byte(s)
Merge of development branch back to main trunk on 2005-05-06

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    
128     protected:
129    
130     private:
131    
132     typedef struct Taipan_MemTable {
133     double* array;
134     int dim;
135     int N;
136     int numThreads;
137     bool free;
138     struct Taipan_MemTable* next;
139     } Taipan_MemTable;
140    
141     Taipan_MemTable* memTable_Root;
142    
143     long totalElements;
144    
145     };
146    
147     } // end of namespace
148    
149     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26