-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Offload] Add device UID #164391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Offload] Add device UID #164391
Changes from 10 commits
1e3bb90
7f8d296
957ca31
29e5560
7c753ef
34dd9dd
04ba6a5
30a3437
fff258a
c2464ee
a35b1be
4bcc7f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -791,6 +791,9 @@ struct GenericDeviceTy : public DeviceAllocatorTy { | |
| /// this id is not unique between different plugins; they may overlap. | ||
| int32_t getDeviceId() const { return DeviceId; } | ||
|
|
||
| /// Get the unique identifier of the device. | ||
| const char *getDeviceUid() const { return DeviceUid.c_str(); } | ||
ro-i marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// Set the context of the device if needed, before calling device-specific | ||
| /// functions. Plugins may implement this function as a no-op if not needed. | ||
| virtual Error setContext() = 0; | ||
|
|
@@ -989,9 +992,12 @@ struct GenericDeviceTy : public DeviceAllocatorTy { | |
| Error syncEvent(void *EventPtr); | ||
| virtual Error syncEventImpl(void *EventPtr) = 0; | ||
|
|
||
| /// Obtain information about the device. | ||
| Expected<InfoTreeNode> obtainInfo(); | ||
| virtual Expected<InfoTreeNode> obtainInfoImpl() = 0; | ||
|
|
||
| /// Print information about the device. | ||
| Error printInfo(); | ||
| virtual Expected<InfoTreeNode> obtainInfoImpl() = 0; | ||
|
|
||
| /// Return true if the device has work that is either queued or currently | ||
| /// running | ||
|
|
@@ -1204,6 +1210,14 @@ struct GenericDeviceTy : public DeviceAllocatorTy { | |
| /// global device id and is not the device id visible to the OpenMP user. | ||
| const int32_t DeviceId; | ||
|
|
||
| /// The unique identifier of the device. | ||
| /// Per default, the unique identifier of the device is set to the device id, | ||
| /// combined with the plugin name, since the offload device id may overlap | ||
| /// between different plugins. | ||
| std::string DeviceUid; | ||
| /// Construct the device UID from the vendor (U)UID. | ||
| void setDeviceUidFromVendorUid(StringRef VendorUid); | ||
ro-i marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// The default grid values used for this device. | ||
| llvm::omp::GV GridValues; | ||
|
|
||
|
|
@@ -1280,6 +1294,12 @@ struct GenericPluginTy { | |
|
|
||
| return *Devices[DeviceId]; | ||
| } | ||
| const GenericDeviceTy &getDevice(int32_t DeviceId) const { | ||
| assert(isValidDeviceId(DeviceId) && "Invalid device id"); | ||
| assert(Devices[DeviceId] && "Device is uninitialized"); | ||
|
|
||
| return *Devices[DeviceId]; | ||
| } | ||
|
|
||
| /// Get the number of active devices. | ||
| int32_t getNumDevices() const { return NumDevices; } | ||
|
|
@@ -1290,6 +1310,14 @@ struct GenericPluginTy { | |
| return UserDeviceIds.at(DeviceId); | ||
| } | ||
|
|
||
| /// Get the UID for the given device. | ||
| const char *getDeviceUid(int32_t DeviceId) const { | ||
|
||
| return getDevice(DeviceId).getDeviceUid(); | ||
| } | ||
|
|
||
| /// Get the UID for the host device. | ||
| static constexpr const char *getHostDeviceUid() { return "HOST"; } | ||
|
|
||
| /// Get the ELF code to recognize the binary image of this plugin. | ||
| virtual uint16_t getMagicElfBits() const = 0; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably call this UUID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it's not guaranteed to be a UUID (and doesn't need to be).
I don't think that all vendors can agree on UUIDs for their stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a UUID, as it's not necessarily what is understood with it. UUID is a 128-bit identifier, while the UID is vendor-specific string. E.g., ROCm has some thingy with
GPU-and a hex number.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's bothering me a little bit, btw, is that my formatting of the Nvidia (U)UID is different from the formatting in
nvidia-smi. But I don't know if it's smart to try to copy that format without a clear documentation of it. So ig it's better to just be consistent and to tell people to look up the UIDs withllvm-offload-device-info