xref: /llvm-project/offload/liboffload/API/Platform.td (revision fd3907ccb583df99e9c19d2fe84e4e7c52d75de9)
1*fd3907ccSCallum Fare//===-- Platform.td - Platform 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 Platform handle
10*fd3907ccSCallum Fare//
11*fd3907ccSCallum Fare//===----------------------------------------------------------------------===//
12*fd3907ccSCallum Faredef : Function {
13*fd3907ccSCallum Fare  let name = "olGetPlatform";
14*fd3907ccSCallum Fare  let desc = "Retrieves all available platforms";
15*fd3907ccSCallum Fare  let details = [
16*fd3907ccSCallum Fare    "Multiple calls to this function will return identical platforms handles, in the same order.",
17*fd3907ccSCallum Fare  ];
18*fd3907ccSCallum Fare  let params = [
19*fd3907ccSCallum Fare    Param<"uint32_t", "NumEntries",
20*fd3907ccSCallum Fare      "The number of platforms to be added to Platforms. NumEntries must be "
21*fd3907ccSCallum Fare      "greater than zero.",
22*fd3907ccSCallum Fare      PARAM_IN>,
23*fd3907ccSCallum Fare    RangedParam<"ol_platform_handle_t*", "Platforms",
24*fd3907ccSCallum Fare      "Array of handle of platforms. If NumEntries is less than the number of "
25*fd3907ccSCallum Fare      "platforms available, then olGetPlatform shall only retrieve that "
26*fd3907ccSCallum Fare      "number of platforms.",
27*fd3907ccSCallum Fare      PARAM_OUT, Range<"0", "NumEntries">>
28*fd3907ccSCallum Fare  ];
29*fd3907ccSCallum Fare  let returns = [
30*fd3907ccSCallum Fare    Return<"OL_ERRC_INVALID_SIZE", [
31*fd3907ccSCallum Fare      "`NumEntries == 0`"
32*fd3907ccSCallum Fare    ]>
33*fd3907ccSCallum Fare  ];
34*fd3907ccSCallum Fare}
35*fd3907ccSCallum Fare
36*fd3907ccSCallum Faredef : Function {
37*fd3907ccSCallum Fare  let name = "olGetPlatformCount";
38*fd3907ccSCallum Fare  let desc = "Retrieves the number of available platforms";
39*fd3907ccSCallum Fare  let params = [
40*fd3907ccSCallum Fare    Param<"uint32_t*",
41*fd3907ccSCallum Fare      "NumPlatforms", "returns the total number of platforms available.",
42*fd3907ccSCallum Fare      PARAM_OUT>
43*fd3907ccSCallum Fare  ];
44*fd3907ccSCallum Fare  let returns = [];
45*fd3907ccSCallum Fare}
46*fd3907ccSCallum Fare
47*fd3907ccSCallum Faredef : Enum {
48*fd3907ccSCallum Fare  let name = "ol_platform_info_t";
49*fd3907ccSCallum Fare  let desc = "Supported platform info";
50*fd3907ccSCallum Fare  let is_typed = 1;
51*fd3907ccSCallum Fare  let etors = [
52*fd3907ccSCallum Fare    TaggedEtor<"NAME", "char[]", "The string denoting name of the platform. The size of the info needs to be dynamically queried.">,
53*fd3907ccSCallum Fare    TaggedEtor<"VENDOR_NAME", "char[]", "The string denoting name of the vendor of the platform. The size of the info needs to be dynamically queried.">,
54*fd3907ccSCallum Fare    TaggedEtor<"VERSION", "char[]", "The string denoting the version of the platform. The size of the info needs to be dynamically queried.">,
55*fd3907ccSCallum Fare    TaggedEtor<"BACKEND", "ol_platform_backend_t", "The native backend of the platform.">
56*fd3907ccSCallum Fare  ];
57*fd3907ccSCallum Fare}
58*fd3907ccSCallum Fare
59*fd3907ccSCallum Faredef : Enum {
60*fd3907ccSCallum Fare  let name = "ol_platform_backend_t";
61*fd3907ccSCallum Fare  let desc = "Identifies the native backend of the platform";
62*fd3907ccSCallum Fare  let etors =[
63*fd3907ccSCallum Fare    Etor<"UNKNOWN", "The backend is not recognized">,
64*fd3907ccSCallum Fare    Etor<"CUDA", "The backend is CUDA">,
65*fd3907ccSCallum Fare    Etor<"AMDGPU", "The backend is AMDGPU">,
66*fd3907ccSCallum Fare  ];
67*fd3907ccSCallum Fare}
68*fd3907ccSCallum Fare
69*fd3907ccSCallum Faredef : Function {
70*fd3907ccSCallum Fare  let name = "olGetPlatformInfo";
71*fd3907ccSCallum Fare  let desc = "Queries the given property of the platform";
72*fd3907ccSCallum Fare  let details = [
73*fd3907ccSCallum Fare    "`olGetPlatformInfoSize` can be used to query the storage size "
74*fd3907ccSCallum Fare    "required for the given query."
75*fd3907ccSCallum Fare  ];
76*fd3907ccSCallum Fare  let params = [
77*fd3907ccSCallum Fare    Param<"ol_platform_handle_t", "Platform", "handle of the platform", PARAM_IN>,
78*fd3907ccSCallum Fare    Param<"ol_platform_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
79*fd3907ccSCallum Fare    Param<"size_t", "PropSize", "the number of bytes pointed to by pPlatformInfo.", PARAM_IN>,
80*fd3907ccSCallum Fare    TypeTaggedParam<"void*", "PropValue", "array of bytes holding the info. "
81*fd3907ccSCallum Fare      "If Size is not equal to or greater to the real number of bytes needed to return the info "
82*fd3907ccSCallum Fare      "then the OL_ERRC_INVALID_SIZE error is returned and pPlatformInfo is not used.", PARAM_OUT,
83*fd3907ccSCallum Fare      TypeInfo<"PropName" , "PropSize">>
84*fd3907ccSCallum Fare  ];
85*fd3907ccSCallum Fare  let returns = [
86*fd3907ccSCallum Fare    Return<"OL_ERRC_UNSUPPORTED_ENUMERATION", [
87*fd3907ccSCallum Fare      "If `PropName` is not supported by the platform."
88*fd3907ccSCallum Fare    ]>,
89*fd3907ccSCallum Fare    Return<"OL_ERRC_INVALID_SIZE", [
90*fd3907ccSCallum Fare      "`PropSize == 0`",
91*fd3907ccSCallum Fare      "If `PropSize` is less than the real number of bytes needed to return the info."
92*fd3907ccSCallum Fare    ]>,
93*fd3907ccSCallum Fare    Return<"OL_ERRC_INVALID_PLATFORM">
94*fd3907ccSCallum Fare  ];
95*fd3907ccSCallum Fare}
96*fd3907ccSCallum Fare
97*fd3907ccSCallum Faredef : Function {
98*fd3907ccSCallum Fare  let name = "olGetPlatformInfoSize";
99*fd3907ccSCallum Fare  let desc = "Returns the storage size of the given platform query";
100*fd3907ccSCallum Fare  let details = [];
101*fd3907ccSCallum Fare  let params = [
102*fd3907ccSCallum Fare    Param<"ol_platform_handle_t", "Platform", "handle of the platform", PARAM_IN>,
103*fd3907ccSCallum Fare    Param<"ol_platform_info_t", "PropName", "type of the info to query", PARAM_IN>,
104*fd3907ccSCallum Fare    Param<"size_t*", "PropSizeRet", "pointer to the number of bytes required to store the query", PARAM_OUT>
105*fd3907ccSCallum Fare  ];
106*fd3907ccSCallum Fare  let returns = [
107*fd3907ccSCallum Fare    Return<"OL_ERRC_UNSUPPORTED_ENUMERATION", [
108*fd3907ccSCallum Fare      "If `PropName` is not supported by the platform."
109*fd3907ccSCallum Fare    ]>,
110*fd3907ccSCallum Fare    Return<"OL_ERRC_INVALID_PLATFORM">
111*fd3907ccSCallum Fare  ];
112*fd3907ccSCallum Fare}
113