SkePU(integratedwithStarPU)  0.8.1
 All Classes Namespaces Files Functions Enumerations Friends Macros Groups Pages
environment.h
Go to the documentation of this file.
1 
5 #ifndef DEVICE_H
6 #define DEVICE_H
7 
8 #ifndef SKEPU_NUMGPU
9 #define SKEPU_NUMGPU 0
10 #endif
11 
12 #include <vector>
13 
14 #include "../globals.h"
15 
16 #ifdef SKEPU_OPENCL
17 #include "device_cl.h"
18 #include "device_mem_pointer_cl.h"
19 #endif
20 
21 #include <sstream>
22 
23 #include "skepu/vector.h"
24 
25 namespace skepu
26 {
27 
37 template <typename T>
39 
40 
41 
51 template <typename T>
53 {
54 
55 public:
56 
57 
62  GENERATE = 0,
63  MAP_UNARY,
64  MAP_BINARY,
65  MAP_TERNARY,
66  MAP_UNARY_MATRIX,
67  MAP_BINARY_MATRIX,
68  MAP_TERNARY_MATRIX,
69  MAPRED_UNARY,
70  MAPRED_BINARY,
71  MAPRED_TERNARY,
72  REDUCE,
73  MAP_ARRAY,
74  MAP_ARRAY_MATRIX,
75  MAP_OVERLAP,
76  MAP_OVERLAP_MAT_ROW,
77  MAP_OVERLAP_MAT_COL,
78  MAP_OVERLAP_MAT_CONVOL,
79  SCAN,
80  NUMBER_OF_SkelObjectType
81  };
82 
83  static Environment* getInstance();
84 
85  int objCounters[NUMBER_OF_SkelObjectType];
86 
87  #ifdef SKEPU_OPENCL
88  std::vector<Device_CL*> m_devices_CL;
89  #endif
90 
91  #ifdef SKEPU_CUDA
92 // std::vector<Device_CU*> m_devices_CU; // Not used in this translation
93  #endif
94 
95  void finishAll();
96 
97  protected:
98  Environment();
99 
100 virtual ~Environment();
101 
102  friend class EnvironmentDestroyer<T>; // To safely clean resources
103 
104 
105 
106 private:
107 
108  static EnvironmentDestroyer<T> _destroyer;
109 
110 
111  void init();
112 
113 private:
114  static Environment* instance;
115  struct starpu_conf conf;
116 
117 
118 public:
119  unsigned int getNextTagID()
120  {
121  int tagId = ++tagCounter;
122  m_tagIds.push_back(tagId);
123  return tagId;
124  }
125  unsigned int getCurrentTagID()
126  {
127  return tagCounter;
128  }
129 private:
130  unsigned int tagCounter;
131 
132 public:
133  std::vector<unsigned int> m_tagIds;
134  bool m_useTagIds;
135  bool m_isFarmCall;
136 
137 #ifdef USE_STARPU_HISTORY_MODEL // to store list of performance models pointers that are deallocated hereā€¦
138  std::vector<starpu_perfmodel *> perfModelList;
139 #endif
140 };
141 
142 
143 template <typename T>
144 EnvironmentDestroyer<T> Environment<T>::_destroyer;
145 
146 
150 template <typename T>
151 class EnvironmentDestroyer
152 {
153  public:
154  EnvironmentDestroyer(Environment<T>* = 0);
155  ~EnvironmentDestroyer();
156 
157  void SetEnvironment(Environment<T>* s);
158  private:
159  Environment<T>* _singleton;
160  };
161 
162 
163 
164 
165  template <typename T>
166  EnvironmentDestroyer<T>::EnvironmentDestroyer(Environment<T>* s) {
167  _singleton = s;
168  }
169 
170  template <typename T>
171  EnvironmentDestroyer<T>::~EnvironmentDestroyer () {
172  delete _singleton;
173  }
174 
175  template <typename T>
176  void EnvironmentDestroyer<T>::SetEnvironment (Environment<T>* s) {
177  _singleton = s;
178  }
179 
180 }
181 
182 #include "environment.inl"
183 
184 #endif
185 
Contains a class declaration for an object which represents an OpenCL device memory allocation...
virtual ~Environment()
Definition: environment.inl:82
SkelObjectType
Definition: environment.h:61
void finishAll()
Definition: environment.inl:119
Contains member function definitions for the Environment class.
Contains a class declaration for the object that represents an OpenCL device.
Definition: environment.h:38
Environment()
Definition: environment.inl:39
A class representing a execution environment.
Definition: environment.h:52
Contains a class declaration for the Vector container.
static Environment * getInstance()
Definition: environment.inl:25