xref: /llvm-project/offload/liboffload/API/Device.td (revision fd3907ccb583df99e9c19d2fe84e4e7c52d75de9)
1//===-- Device.td - Device definitions for Offload ---------*- tablegen -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains Offload API definitions related to the Device handle
10//
11//===----------------------------------------------------------------------===//
12
13def : Enum {
14  let name = "ol_device_type_t";
15  let desc = "Supported device types";
16  let etors =[
17    Etor<"DEFAULT", "The default device type as preferred by the runtime">,
18    Etor<"ALL", "Devices of all types">,
19    Etor<"GPU", "GPU device type">,
20    Etor<"CPU", "CPU device type">,
21  ];
22}
23
24def : Enum {
25  let name = "ol_device_info_t";
26  let desc = "Supported device info";
27  let is_typed = 1;
28  let etors =[
29    TaggedEtor<"TYPE", "ol_device_type_t", "type of the device">,
30    TaggedEtor<"PLATFORM", "ol_platform_handle_t", "the platform associated with the device">,
31    TaggedEtor<"NAME", "char[]", "Device name">,
32    TaggedEtor<"VENDOR", "char[]", "Device vendor">,
33    TaggedEtor<"DRIVER_VERSION", "char[]", "Driver version">
34  ];
35}
36
37def : Function {
38  let name = "olGetDeviceCount";
39  let desc = "Retrieves the number of available devices within a platform";
40  let params = [
41    Param<"ol_platform_handle_t", "Platform", "handle of the platform instance", PARAM_IN>,
42    Param<"uint32_t*", "NumDevices", "pointer to the number of devices.", PARAM_OUT>
43  ];
44  let returns = [];
45}
46
47def : Function {
48  let name = "olGetDevice";
49  let desc = "Retrieves devices within a platform";
50  let details = [
51    "Multiple calls to this function will return identical device handles, in the same order.",
52  ];
53  let params = [
54    Param<"ol_platform_handle_t", "Platform", "handle of the platform instance", PARAM_IN>,
55    Param<"uint32_t", "NumEntries", "the number of devices to be added to phDevices, which must be greater than zero", PARAM_IN>,
56    RangedParam<"ol_device_handle_t*", "Devices", "Array of device handles. "
57        "If NumEntries is less than the number of devices available, then this function shall only retrieve that number of devices.", PARAM_OUT,
58        Range<"0", "NumEntries">>
59  ];
60  let returns = [
61    Return<"OL_ERRC_INVALID_SIZE", [
62      "`NumEntries == 0`"
63    ]>
64  ];
65}
66
67def : Function {
68  let name = "olGetDeviceInfo";
69  let desc = "Queries the given property of the device";
70  let details = [];
71  let params = [
72    Param<"ol_device_handle_t", "Device", "handle of the device instance", PARAM_IN>,
73    Param<"ol_device_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
74    Param<"size_t", "PropSize", "the number of bytes pointed to by PropValue.", PARAM_IN>,
75    TypeTaggedParam<"void*", "PropValue", "array of bytes holding the info. If PropSize is not equal to or greater than the real "
76                    "number of bytes needed to return the info then the OL_ERRC_INVALID_SIZE error is returned and "
77                    "PropValue is not used.", PARAM_OUT, TypeInfo<"PropName" , "PropSize">>
78  ];
79  let returns = [
80    Return<"OL_ERRC_UNSUPPORTED_ENUMERATION", [
81      "If `PropName` is not supported by the device."
82    ]>,
83    Return<"OL_ERRC_INVALID_SIZE", [
84      "`PropSize == 0`",
85      "If `PropSize` is less than the real number of bytes needed to return the info."
86    ]>,
87    Return<"OL_ERRC_INVALID_DEVICE">
88  ];
89}
90
91def : Function {
92  let name = "olGetDeviceInfoSize";
93  let desc = "Returns the storage size of the given device query";
94  let details = [];
95  let params = [
96    Param<"ol_device_handle_t", "Device", "handle of the device instance", PARAM_IN>,
97    Param<"ol_device_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
98    Param<"size_t*", "PropSizeRet", "pointer to the number of bytes required to store the query", PARAM_OUT>
99  ];
100  let returns = [
101    Return<"OL_ERRC_UNSUPPORTED_ENUMERATION", [
102      "If `PropName` is not supported by the device."
103    ]>,
104    Return<"OL_ERRC_INVALID_DEVICE">
105  ];
106}
107