brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.2 KiB · 6ada191 Raw
134 lines · plain
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file contains Offload API definitions related to the Device handle10//11//===----------------------------------------------------------------------===//12 13def ol_device_type_t : Enum {14  let desc = "Supported device types.";15  let etors =[16    Etor<"DEFAULT", "The default device type as preferred by the runtime">,17    Etor<"ALL", "Devices of all types">,18    Etor<"GPU", "GPU device type">,19    Etor<"CPU", "CPU device type">,20    Etor<"Host", "Host device type">,21  ];22}23 24def ol_device_info_t : Enum {25  let desc = "Supported device info.";26  let is_typed = 1;27  list<TaggedEtor> basic_etors =[28    TaggedEtor<"TYPE", "ol_device_type_t", "type of the device">,29    TaggedEtor<"PLATFORM", "ol_platform_handle_t", "the platform associated with the device">,30    TaggedEtor<"NAME", "char[]", "Device name">,31    TaggedEtor<"PRODUCT_NAME", "char[]", "Device user-facing marketing name">,32    TaggedEtor<"UID", "char[]", "Device UID">,33    TaggedEtor<"VENDOR", "char[]", "Device vendor">,34    TaggedEtor<"DRIVER_VERSION", "char[]", "Driver version">,35    TaggedEtor<"MAX_WORK_GROUP_SIZE", "uint32_t", "Maximum total work group size in work items">,36    TaggedEtor<"MAX_WORK_GROUP_SIZE_PER_DIMENSION", "ol_dimensions_t", "Maximum work group size in each dimension">,37    TaggedEtor<"MAX_WORK_SIZE", "uint32_t", "Maximum total work items">,38    TaggedEtor<"MAX_WORK_SIZE_PER_DIMENSION", "ol_dimensions_t", "Maximum work items in each dimension">,39    TaggedEtor<"VENDOR_ID", "uint32_t", "A unique vendor device identifier assigned by PCI-SIG">,40    TaggedEtor<"NUM_COMPUTE_UNITS", "uint32_t", "The number of parallel compute units available to the device">,41    TaggedEtor<"MAX_CLOCK_FREQUENCY", "uint32_t", "The maximum configured clock frequency of this device in MHz">,42    TaggedEtor<"MEMORY_CLOCK_RATE", "uint32_t", "Memory clock frequency in MHz">,43    TaggedEtor<"ADDRESS_BITS", "uint32_t", "Number of bits used to represent an address in device memory">,44    TaggedEtor<"MAX_MEM_ALLOC_SIZE", "uint64_t", "The maximum size of memory object allocation in bytes">,45    TaggedEtor<"GLOBAL_MEM_SIZE", "uint64_t", "The size of global device memory in bytes">,46    TaggedEtor<"WORK_GROUP_LOCAL_MEM_SIZE", "uint64_t", "The maximum size of local shared memory per work group in bytes">,47  ];48  list<TaggedEtor> fp_configs = !foreach(type, ["Single", "Double", "Half"], TaggedEtor<type # "_FP_CONFIG", "ol_device_fp_capability_flags_t", type # " precision floating point capability">);49  list<TaggedEtor> native_vec_widths = !foreach(type, ["char","short","int","long","float","double","half"], TaggedEtor<"NATIVE_VECTOR_WIDTH_" # type, "uint32_t", "Native vector width for " # type>);50  let etors = !listconcat(basic_etors, fp_configs, native_vec_widths);51}52 53def ol_device_fp_capability_flag_t : Enum {54  let desc = "Device floating-point capability flags";55  let is_bit_field = 1;56  let etors =[57    Etor<"CORRECTLY_ROUNDED_DIVIDE_SQRT", "Support correctly rounded divide and sqrt">,58    Etor<"ROUND_TO_NEAREST", "Support round to nearest">,59    Etor<"ROUND_TO_ZERO", "Support round to zero">,60    Etor<"ROUND_TO_INF", "Support round to infinity">,61    Etor<"INF_NAN", "Support INF to NAN">,62    Etor<"DENORM", "Support denorm">,63    Etor<"FMA", "Support fused multiply-add">,64    Etor<"SOFT_FLOAT", "Basic floating point operations implemented in software">,65  ];66}67 68def ol_device_fp_capability_flags_t : Typedef {69  let desc = "Device floating-point capability flags";70  let value = "uint32_t";71}72 73def ol_device_iterate_cb_t : FptrTypedef {74  let desc = "User-provided function to be used with `olIterateDevices`";75  let params = [76    Param<"ol_device_handle_t", "Device", "the device handle of the current iteration", PARAM_IN>,77    Param<"void*", "UserData", "optional user data", PARAM_IN_OPTIONAL>78  ];79  let return = "bool";80}81 82def olIterateDevices : Function {83  let desc = "Iterates over all available devices, calling the callback for each device.";84  let details = [85    "If the user-provided callback returns `false`, the iteration is stopped."86  ];87  let params = [88    Param<"ol_device_iterate_cb_t", "Callback", "User-provided function called for each available device", PARAM_IN>,89    Param<"void*", "UserData", "Optional user data to pass to the callback", PARAM_IN_OPTIONAL>90  ];91  let returns = [92    Return<"OL_ERRC_INVALID_DEVICE">93  ];94}95 96def olGetDeviceInfo : Function {97  let desc = "Queries the given property of the device.";98  let details = [];99  let params = [100    Param<"ol_device_handle_t", "Device", "handle of the device instance", PARAM_IN>,101    Param<"ol_device_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,102    Param<"size_t", "PropSize", "the number of bytes pointed to by PropValue.", PARAM_IN>,103    TypeTaggedParam<"void*", "PropValue", "array of bytes holding the info. If PropSize is not equal to or greater than the real "104                    "number of bytes needed to return the info then the OL_ERRC_INVALID_SIZE error is returned and "105                    "PropValue is not used.", PARAM_OUT, TypeInfo<"PropName" , "PropSize">>106  ];107  let returns = [108    Return<"OL_ERRC_UNSUPPORTED_ENUMERATION", [109      "If `PropName` is not supported by the device."110    ]>,111    Return<"OL_ERRC_INVALID_SIZE", [112      "`PropSize == 0`",113      "If `PropSize` is less than the real number of bytes needed to return the info."114    ]>,115    Return<"OL_ERRC_INVALID_DEVICE">116  ];117}118 119def olGetDeviceInfoSize : Function {120  let desc = "Returns the storage size of the given device query.";121  let details = [];122  let params = [123    Param<"ol_device_handle_t", "Device", "handle of the device instance", PARAM_IN>,124    Param<"ol_device_info_t", "PropName", "type of the info to retrieve", PARAM_IN>,125    Param<"size_t*", "PropSizeRet", "pointer to the number of bytes required to store the query", PARAM_OUT>126  ];127  let returns = [128    Return<"OL_ERRC_UNSUPPORTED_ENUMERATION", [129      "If `PropName` is not supported by the device."130    ]>,131    Return<"OL_ERRC_INVALID_DEVICE">132  ];133}134