-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGraphicsCardSupplyDepot.h
61 lines (44 loc) · 1.36 KB
/
GraphicsCardSupplyDepot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* GraphicsCardSupplyDepot.h
*
* Created on: Feb 1, 2021
* Author: tugrul
*/
#ifndef GRAPHICSCARDSUPPLYDEPOT_H_
#define GRAPHICSCARDSUPPLYDEPOT_H_
#include<vector>
#include<memory>
#include"ClPlatform.h"
#include"ClDevice.h"
// prepares a list of graphics card found in system
// is not needed to be spanning VirtualMultiArray. Once VirtualMultiArray is constructed, it contains its own resource managemennt
class GraphicsCardSupplyDepot
{
public:
// prepares a list of all graphics cards in system.
// debug=true: writes names and vram sizes of graphics cards on std::cout
GraphicsCardSupplyDepot(const bool debug=false)
{
platformPtr = std::make_shared<ClPlatform>();
deviceVecPtr = std::make_shared<std::vector<ClDevice>>();
unsigned int n = platformPtr->size();
for(unsigned int i=0;i<n;i++)
{
ClDevice dev(platformPtr->id(i),debug);
auto dl = dev.generate();
for(auto e:dl)
deviceVecPtr->push_back(e);
}
}
// gets list of already-prepared graphics cards
// can be used for multiple VirtualMultiArray instances
// ClDevices share same raw device-pointer under the hood
std::vector<ClDevice> requestGpus(){ return *deviceVecPtr; }
~GraphicsCardSupplyDepot()
{
}
private:
std::shared_ptr<ClPlatform> platformPtr;
std::shared_ptr<std::vector<ClDevice>> deviceVecPtr;
};
#endif /* GRAPHICSCARDSUPPLYDEPOT_H_ */