171 lines · c
1//===-- OpenMP/omp.h - Copies of OpenMP user facing types and APIs - C++ -===//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 copies some OpenMP user facing types and APIs for easy reach within the10// implementation.11//12//===----------------------------------------------------------------------===//13 14#ifndef OMPTARGET_OPENMP_OMP_H15#define OMPTARGET_OPENMP_OMP_H16 17#include <cstdint>18 19#if defined(_WIN32)20#define __KAI_KMPC_CONVENTION __cdecl21#ifndef __KMP_IMP22#define __KMP_IMP __declspec(dllimport)23#endif24#else25#define __KAI_KMPC_CONVENTION26#ifndef __KMP_IMP27#define __KMP_IMP28#endif29#endif30 31extern "C" {32 33/// Definitions34///{35 36// See definition in OpenMP (omp.h.var/omp_lib.(F90|h).var)37#define omp_invalid_device -238 39///}40 41/// Type declarations42///{43 44typedef void *omp_depend_t;45 46///}47 48/// API declarations49///{50 51int omp_get_default_device(void);52 53///}54 55/// InteropAPI56///57///{58 59/// TODO: Include the `omp.h` of the current build60/* OpenMP 5.1 interop */61typedef intptr_t omp_intptr_t;62 63/* 0..omp_get_num_interop_properties()-1 are reserved for implementation-defined64 * properties */65typedef enum omp_interop_property {66 omp_ipr_fr_id = -1,67 omp_ipr_fr_name = -2,68 omp_ipr_vendor = -3,69 omp_ipr_vendor_name = -4,70 omp_ipr_device_num = -5,71 omp_ipr_platform = -6,72 omp_ipr_device = -7,73 omp_ipr_device_context = -8,74 omp_ipr_targetsync = -9,75 omp_ipr_first = -976} omp_interop_property_t;77 78#define omp_interop_none 079 80typedef enum omp_interop_rc {81 omp_irc_no_value = 1,82 omp_irc_success = 0,83 omp_irc_empty = -1,84 omp_irc_out_of_range = -2,85 omp_irc_type_int = -3,86 omp_irc_type_ptr = -4,87 omp_irc_type_str = -5,88 omp_irc_other = -689} omp_interop_rc_t;90 91/* Foreign runtime values from OpenMP Additional Definitions document v2.1 */92typedef enum tgt_foreign_runtime_id_t {93 tgt_fr_none = 0,94 tgt_fr_cuda = 1,95 tgt_fr_cuda_driver = 2,96 tgt_fr_opencl = 3,97 tgt_fr_sycl = 4,98 tgt_fr_hip = 5,99 tgt_fr_level_zero = 6,100 tgt_fr_hsa = 7,101 tgt_fr_last = 8102} tgt_foreign_runtime_id_t;103 104typedef void *omp_interop_t;105 106/*!107 * The `omp_get_num_interop_properties` routine retrieves the number of108 * implementation-defined properties available for an `omp_interop_t` object.109 */110int __KAI_KMPC_CONVENTION omp_get_num_interop_properties(const omp_interop_t);111/*!112 * The `omp_get_interop_int` routine retrieves an integer property from an113 * `omp_interop_t` object.114 */115omp_intptr_t __KAI_KMPC_CONVENTION116omp_get_interop_int(const omp_interop_t, omp_interop_property_t, int *);117/*!118 * The `omp_get_interop_ptr` routine retrieves a pointer property from an119 * `omp_interop_t` object.120 */121void *__KAI_KMPC_CONVENTION omp_get_interop_ptr(const omp_interop_t,122 omp_interop_property_t, int *);123/*!124 * The `omp_get_interop_str` routine retrieves a string property from an125 * `omp_interop_t` object.126 */127const char *__KAI_KMPC_CONVENTION128omp_get_interop_str(const omp_interop_t, omp_interop_property_t, int *);129/*!130 * The `omp_get_interop_name` routine retrieves a property name from an131 * `omp_interop_t` object.132 */133const char *__KAI_KMPC_CONVENTION omp_get_interop_name(const omp_interop_t,134 omp_interop_property_t);135/*!136 * The `omp_get_interop_type_desc` routine retrieves a description of the type137 * of a property associated with an `omp_interop_t` object.138 */139const char *__KAI_KMPC_CONVENTION140omp_get_interop_type_desc(const omp_interop_t, omp_interop_property_t);141/*!142 * The `omp_get_interop_rc_desc` routine retrieves a description of the return143 * code associated with an `omp_interop_t` object.144 */145extern const char *__KAI_KMPC_CONVENTION146omp_get_interop_rc_desc(const omp_interop_t, omp_interop_rc_t);147 148/* Vendor defined values from OpenMP Additional Definitions document v2.1*/149typedef enum omp_vendor_id {150 omp_vendor_unknown = 0,151 omp_vendor_amd = 1,152 omp_vendor_arm = 2,153 omp_vendor_bsc = 3,154 omp_vendor_fujitsu = 4,155 omp_vendor_gnu = 5,156 omp_vendor_hpe = 6,157 omp_vendor_ibm = 7,158 omp_vendor_intel = 8,159 omp_vendor_llvm = 9,160 omp_vendor_nec = 10,161 omp_vendor_nvidia = 11,162 omp_vendor_ti = 12,163 omp_vendor_last = 13164} omp_vendor_id_t;165 166///} InteropAPI167 168} // extern "C"169 170#endif // OMPTARGET_OPENMP_OMP_H171