TBTK
GPUResourceManager.h
Go to the documentation of this file.
1 /* Copyright 2016 Kristofer Bj√∂rnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_GPU_RESOURCE_MANAGER
24 #define COM_DAFER45_TBTK_GPU_RESOURCE_MANAGER
25 
26 #ifndef __APPLE__
27 # include <omp.h>
28 #endif
29 
30 namespace TBTK{
31 
33 public:
35  int getNumDevices();
36 
38  int allocateDevice();
39 
41  void freeDevice(int device);
42 
45 private:
48 
50  GPUResourceManager(const GPUResourceManager &gpuResourceManager) = delete;
51 
53  GPUResourceManager& operator=(const GPUResourceManager &gpuResourceManager) = delete;
54 
56  int numDevices;
57 
59  bool *busyDevices;
60 
61 #ifndef __APPLE__
62 
63  omp_lock_t busyDevicesLock;
64 #endif
65 
67  void createDeviceTable();
68 
70  void destroyDeviceTable();
71 };
72 
74  return numDevices;
75 }
76 
77 }; //End of namespace TBTK
78 
79 #endif
static GPUResourceManager & getInstance()
int getNumDevices()
Definition: GPUResourceManager.h:73
Definition: GPUResourceManager.h:32
Definition: ModelFactory.h:35
void freeDevice(int device)