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 #include <omp.h>
27 
28 namespace TBTK{
29 
31 public:
33  int getNumDevices();
34 
36  int allocateDevice();
37 
39  void freeDevice(int device);
40 
43 private:
46 
48  GPUResourceManager(const GPUResourceManager &gpuResourceManager) = delete;
49 
51  GPUResourceManager& operator=(const GPUResourceManager &gpuResourceManager) = delete;
52 
54  int numDevices;
55 
57  bool *busyDevices;
58 
60  omp_lock_t busyDevicesLock;
61 
63  void createDeviceTable();
64 
66  void destroyDeviceTable();
67 };
68 
70  return numDevices;
71 }
72 
73 }; //End of namespace TBTK
74 
75 #endif
int allocateDevice()
Definition: GPUResourceManager.cpp:42
static GPUResourceManager & getInstance()
Definition: GPUResourceManager.cpp:36
int getNumDevices()
Definition: GPUResourceManager.h:69
Definition: GPUResourceManager.h:30
Definition: AbstractOperator.h:26
void freeDevice(int device)
Definition: GPUResourceManager.cpp:72