Poplar and PopLibs
Device.hpp
1// Copyright (c) 2016 Graphcore Ltd. All rights reserved.
2
3#ifndef poplar_Device_hpp
4#define poplar_Device_hpp
5#include <map>
6#include <memory>
7#include <poplar/OptionFlags.hpp>
8#include <poplar/Target.hpp>
9
10#include <graphcore_target_access/IPUAttributes.h>
11
12#include <string>
13#include <vector>
14
15namespace poplar {
16namespace core {
17class Device;
18}
26class Device {
27public:
28 Device();
29 Device(Device &&) noexcept;
30 virtual ~Device();
31
32 Device &operator=(Device &&) noexcept;
33
34 // A Device can not be copied or assigned in order to preserve the
35 // attach/detach state of underlying hardware.
36 Device(const Device &) = delete;
37 Device &operator=(const Device &) = delete;
38
40 unsigned getId() const;
41
43 const Target &getTarget() const;
44
46 bool attach() const;
47
49 void detach() const;
50
54 void getDriverVersion(unsigned &major, unsigned &minor,
55 unsigned &point) const;
56
61
67 bool hasGateway() const;
68
70 GC_DEPRECATED std::map<std::string, std::string> getAttributes() const;
71
73 std::string getAttribute(IPUAttributes::AttributeId attributeId) const;
74
76 std::vector<int> getNumaTopology() const;
77
93 std::vector<int> getNumaNodesUsedForIPUs() const;
94
96 std::vector<unsigned> getDriverIDs() const;
97
99 void reset() const;
100
108 Device createVirtualDevice(unsigned tilesPerIPU);
109
122 static Device createCPUDevice(unsigned numOfIPUs = 1);
123
124 // Internal use only.
125 static Device createSimulatorDevice(const Target &target,
126 const OptionFlags &options = {});
127
128 // Implementation
129 Device(std::unique_ptr<core::Device>);
130 core::Device &getImpl() const { return *impl; }
131
132private:
133 Target target;
134 std::unique_ptr<core::Device> impl;
135};
136
137} // namespace poplar
138
139#endif // poplar_Device_hpp
A device refers to a physical entity that can execute code.
Definition: Device.hpp:26
const Target & getTarget() const
Get the target description of the device.
std::vector< int > getNumaNodesUsedForIPUs() const
Get the NUMA nodes that Poplar will use to execute code that communicates with each IPU that makes up...
void reset() const
Reset the device's state.
bool hasGateway() const
Retrieve IPU-Gateway (such as in an IPU-M2000) availability from the attached device.
std::string getAttribute(IPUAttributes::AttributeId attributeId) const
Retrieve a device attribute string value keyed by attributeId.
std::map< std::string, std::string > getAttributes() const
Device createVirtualDevice(unsigned tilesPerIPU)
Create a virtual device with a restricted number of tiles per IPU.
bool attach() const
Try and acquire this device and lock it to the current process.
void getDriverVersion(unsigned &major, unsigned &minor, unsigned &point) const
Retrieve driver version of the attached device.
unsigned getId() const
Get the numerical ID of this device as known by the DeviceManager.
void detach() const
Release this device to other processes.
std::vector< unsigned > getDriverIDs() const
Get the list of driver device IDs that make up this device.
bool supportsRemoteBuffers() const
Retrieve availability of remote buffers from the attached device.
static Device createCPUDevice(unsigned numOfIPUs=1)
Create a device that executes vertex code on the host CPU.
std::vector< int > getNumaTopology() const
Get the NUMA node of each IPU that makes up this device.
A set of option/value string flags to be used in various APIs.
Definition: OptionFlags.hpp:24
A target representation.
Definition: Target.hpp:69
Poplar classes and functions.
Definition: ArrayRef.hpp:14