Skip to content

Commit a8a901f

Browse files
committed
Implement filtered device/platform discovery, demote platforms
1 parent 833af6e commit a8a901f

23 files changed

+542
-489
lines changed

offload/liboffload/API/APIDefs.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class Typedef : APIObject { string value; }
199199

200200
class FptrTypedef : APIObject {
201201
list<Param> params;
202-
list<Return> returns;
202+
string return;
203203
}
204204

205205
class Macro : APIObject {

offload/liboffload/API/Device.td

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,20 @@ def : Enum {
3636

3737
def : Function {
3838
let name = "olGetDeviceCount";
39-
let desc = "Retrieves the number of available devices within a platform.";
39+
let desc = "Retrieves the number of available devices.";
4040
let params = [
41-
Param<"ol_platform_handle_t", "Platform", "handle of the platform instance", PARAM_IN>,
4241
Param<"uint32_t*", "NumDevices", "pointer to the number of devices.", PARAM_OUT>
4342
];
4443
let returns = [];
4544
}
4645

4746
def : Function {
48-
let name = "olGetDevice";
49-
let desc = "Retrieves devices within a platform.";
47+
let name = "olGetDevices";
48+
let desc = "Retrieves devices.";
5049
let details = [
5150
"Multiple calls to this function will return identical device handles, in the same order.",
5251
];
5352
let params = [
54-
Param<"ol_platform_handle_t", "Platform", "handle of the platform instance", PARAM_IN>,
5553
Param<"uint32_t", "NumEntries", "the number of devices to be added to phDevices, which must be greater than zero", PARAM_IN>,
5654
RangedParam<"ol_device_handle_t*", "Devices", "Array of device handles. "
5755
"If NumEntries is less than the number of devices available, then this function shall only retrieve that number of devices.", PARAM_OUT,
@@ -64,6 +62,58 @@ def : Function {
6462
];
6563
}
6664

65+
def : FptrTypedef {
66+
let name = "ol_platform_filter_cb_t";
67+
let desc = "User-provided function to determine whether a platform is selected.";
68+
let params = [
69+
Param<"ol_platform_backend_t", "Backend", "the backend of the platform which is selected for filtering", PARAM_IN>,
70+
Param<"const char*", "Name", "the name of the platform which is selected for filtering", PARAM_IN>
71+
];
72+
let return = "bool";
73+
}
74+
75+
def : FptrTypedef {
76+
let name = "ol_device_filter_cb_t";
77+
let desc = "User-provided function to determine whether a device is selected.";
78+
let params = [
79+
Param<"ol_device_type_t", "Type", "the type of the device which is selected for filtering", PARAM_IN>
80+
];
81+
let return = "bool";
82+
}
83+
84+
def : Function {
85+
let name = "olGetFilteredDevices";
86+
let desc = "Retrieve a subset of the available devices";
87+
let details = [
88+
"Platforms and devices are lazily initialized when they are first filtered",
89+
"Use MaxNumDevices to stop device and platform discovery after a fixed number of devices",
90+
"Multiple calls to this function will return identical device handles, in the same order.",
91+
];
92+
let params = [
93+
Param<"uint32_t", "MaxNumDevices", "the maximum number of devices to be added to phDevices, which must be greater than zero", PARAM_IN>,
94+
Param<"ol_platform_filter_cb_t", "PlatformFilter", "the callback used to decide whether a platform is included", PARAM_IN>,
95+
Param<"ol_device_filter_cb_t", "DeviceFilter", "the callback used to decide whether a platform is included", PARAM_IN>,
96+
Param<"ol_device_handle_t*", "FilteredDevices", "output pointer for the selected devices", PARAM_OUT>,
97+
];
98+
let returns = [];
99+
}
100+
101+
def : Function {
102+
let name = "olGetFilteredDevicesCount";
103+
let desc = "Retrieve the number of devices that would be returned by olGetFilteredDevices with the given filters.";
104+
let details = [
105+
"Platforms and devices are lazily initialized when they are first filtered",
106+
"Use MaxNumDevices to stop device and platform discovery after a fixed number of devices",
107+
];
108+
let params = [
109+
Param<"uint32_t", "MaxNumDevices", "the maximum number of devices to be added to phDevices; a value of 0 implies no limit.", PARAM_IN>,
110+
Param<"ol_platform_filter_cb_t", "PlatformFilter", "the callback used to decide whether a platform is included", PARAM_IN>,
111+
Param<"ol_device_filter_cb_t", "DeviceFilter", "the callback used to decide whether a platform is included", PARAM_IN>,
112+
Param<"uint32_t*", "NumFilteredDevices", "output pointer for the number of selected devices", PARAM_OUT>
113+
];
114+
let returns = [];
115+
}
116+
67117
def : Function {
68118
let name = "olGetDeviceInfo";
69119
let desc = "Queries the given property of the device.";

offload/liboffload/API/Platform.td

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,6 @@
99
// This file contains Offload API definitions related to the Platform handle
1010
//
1111
//===----------------------------------------------------------------------===//
12-
def : Function {
13-
let name = "olGetPlatform";
14-
let desc = "Retrieves all available platforms.";
15-
let details = [
16-
"Multiple calls to this function will return identical platforms handles, in the same order.",
17-
];
18-
let params = [
19-
Param<"uint32_t", "NumEntries",
20-
"The number of platforms to be added to Platforms. NumEntries must be "
21-
"greater than zero.",
22-
PARAM_IN>,
23-
RangedParam<"ol_platform_handle_t*", "Platforms",
24-
"Array of handle of platforms. If NumEntries is less than the number of "
25-
"platforms available, then olGetPlatform shall only retrieve that "
26-
"number of platforms.",
27-
PARAM_OUT, Range<"0", "NumEntries">>
28-
];
29-
let returns = [
30-
Return<"OL_ERRC_INVALID_SIZE", [
31-
"`NumEntries == 0`"
32-
]>
33-
];
34-
}
35-
36-
def : Function {
37-
let name = "olGetPlatformCount";
38-
let desc = "Retrieves the number of available platforms.";
39-
let params = [
40-
Param<"uint32_t*",
41-
"NumPlatforms", "returns the total number of platforms available.",
42-
PARAM_OUT>
43-
];
44-
let returns = [];
45-
}
4612

4713
def : Enum {
4814
let name = "ol_platform_info_t";

0 commit comments

Comments
 (0)