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