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 "Communicator.h"
27 
28 #ifndef __APPLE__
29 # include <omp.h>
30 #endif
31 
32 namespace TBTK{
33 
35 public:
37  int getNumDevices();
38 
40  int allocateDevice();
41 
43  void freeDevice(int device);
44 
47 private:
50 
52  GPUResourceManager(const GPUResourceManager &gpuResourceManager) = delete;
53 
55  GPUResourceManager& operator=(const GPUResourceManager &gpuResourceManager) = delete;
56 
58  int numDevices;
59 
61  bool *busyDevices;
62 
63 #ifndef __APPLE__
64 
65  omp_lock_t busyDevicesLock;
66 #endif
67 
69  void createDeviceTable();
70 
72  void destroyDeviceTable();
73 };
74 
76  return numDevices;
77 }
78 
79 }; //End of namespace TBTK
80 
81 #endif
static GPUResourceManager & getInstance()
int getNumDevices()
Definition: GPUResourceManager.h:75
Definition: GPUResourceManager.h:34
Definition: ModelFactory.h:35
Base class that communicate their current status during execution.
void freeDevice(int device)
Definition: Communicator.h:28