xref: /llvm-project/offload/liboffload/API/Platform.td (revision fd3907ccb583df99e9c19d2fe84e4e7c52d75de9)
1//===-- Platform.td - Platform 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 Platform handle
10//
11//===----------------------------------------------------------------------===//
12def : 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
36def : 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}
46
47def : Enum {
48  let name = "ol_platform_info_t";
49  let desc = "Supported platform info";
50  let is_typed = 1;
51  let etors = [
52    TaggedEtor<"NAME", "char[]", "The string denoting name of the platform. The size of the info needs to be dynamically queried.">,
53    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    TaggedEtor<"VERSION", "char[]", "The string denoting the version of the platform. The size of the info needs to be dynamically queried.">,
55    TaggedEtor<"BACKEND", "ol_platform_backend_t", "The native backend of the platform.">
56  ];
57}
58
59def : Enum {
60  let name = "ol_platform_backend_t";
61  let desc = "Identifies the native backend of the platform";
62  let etors =[
63    Etor<"UNKNOWN", "The backend is not recognized">,
64    Etor<"CUDA", "The backend is CUDA">,
65    Etor<"AMDGPU", "The backend is AMDGPU">,
66  ];
67}
68
69def : Function {
70  let name = "olGetPlatformInfo";
71  let desc = "Queries the given property of the platform";
72  let details = [
73    "`olGetPlatformInfoSize` can be used to query the storage size "
74    "required for the given query."
75  ];
76  let params = [
77    Param<"ol_platform_handle_t", "Platform", "handle of the platform", PARAM_IN>,
78    Param<"ol_platform_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,
79    Param<"size_t", "PropSize", "the number of bytes pointed to by pPlatformInfo.", PARAM_IN>,
80    TypeTaggedParam<"void*", "PropValue", "array of bytes holding the info. "
81      "If Size is not equal to or greater to the real number of bytes needed to return the info "
82      "then the OL_ERRC_INVALID_SIZE error is returned and pPlatformInfo is not used.", PARAM_OUT,
83      TypeInfo<"PropName" , "PropSize">>
84  ];
85  let returns = [
86    Return<"OL_ERRC_UNSUPPORTED_ENUMERATION", [
87      "If `PropName` is not supported by the platform."
88    ]>,
89    Return<"OL_ERRC_INVALID_SIZE", [
90      "`PropSize == 0`",
91      "If `PropSize` is less than the real number of bytes needed to return the info."
92    ]>,
93    Return<"OL_ERRC_INVALID_PLATFORM">
94  ];
95}
96
97def : Function {
98  let name = "olGetPlatformInfoSize";
99  let desc = "Returns the storage size of the given platform query";
100  let details = [];
101  let params = [
102    Param<"ol_platform_handle_t", "Platform", "handle of the platform", PARAM_IN>,
103    Param<"ol_platform_info_t", "PropName", "type of the info to query", PARAM_IN>,
104    Param<"size_t*", "PropSizeRet", "pointer to the number of bytes required to store the query", PARAM_OUT>
105  ];
106  let returns = [
107    Return<"OL_ERRC_UNSUPPORTED_ENUMERATION", [
108      "If `PropName` is not supported by the platform."
109    ]>,
110    Return<"OL_ERRC_INVALID_PLATFORM">
111  ];
112}
113