1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
12 #include "omptarget.h"
16 #define __KAI_KMPC_CONVENTION __cdecl
18 #define __KMP_IMP __declspec(dllimport)
21 #define __KAI_KMPC_CONVENTION
31 /// TODO: Include the `omp.h` of the current build
32 /* OpenMP 5.1 interop */
33 typedef intptr_t omp_intptr_t
;
35 /* 0..omp_get_num_interop_properties()-1 are reserved for implementation-defined
37 typedef enum omp_interop_property
{
41 omp_ipr_vendor_name
= -4,
42 omp_ipr_device_num
= -5,
43 omp_ipr_platform
= -6,
45 omp_ipr_device_context
= -8,
46 omp_ipr_targetsync
= -9,
48 } omp_interop_property_t
;
50 #define omp_interop_none 0
52 typedef enum omp_interop_rc
{
56 omp_irc_out_of_range
= -2,
57 omp_irc_type_int
= -3,
58 omp_irc_type_ptr
= -4,
59 omp_irc_type_str
= -5,
63 typedef enum omp_interop_fr
{
65 omp_ifr_cuda_driver
= 2,
69 omp_ifr_level_zero
= 6,
73 typedef void *omp_interop_t
;
76 * The `omp_get_num_interop_properties` routine retrieves the number of
77 * implementation-defined properties available for an `omp_interop_t` object.
79 int __KAI_KMPC_CONVENTION
omp_get_num_interop_properties(const omp_interop_t
);
81 * The `omp_get_interop_int` routine retrieves an integer property from an
82 * `omp_interop_t` object.
84 omp_intptr_t __KAI_KMPC_CONVENTION
omp_get_interop_int(const omp_interop_t
,
85 omp_interop_property_t
,
88 * The `omp_get_interop_ptr` routine retrieves a pointer property from an
89 * `omp_interop_t` object.
91 void *__KAI_KMPC_CONVENTION
omp_get_interop_ptr(const omp_interop_t
,
92 omp_interop_property_t
, int *);
94 * The `omp_get_interop_str` routine retrieves a string property from an
95 * `omp_interop_t` object.
97 const char *__KAI_KMPC_CONVENTION
omp_get_interop_str(const omp_interop_t
,
98 omp_interop_property_t
,
101 * The `omp_get_interop_name` routine retrieves a property name from an
102 * `omp_interop_t` object.
104 const char *__KAI_KMPC_CONVENTION
omp_get_interop_name(const omp_interop_t
,
105 omp_interop_property_t
);
107 * The `omp_get_interop_type_desc` routine retrieves a description of the type
108 * of a property associated with an `omp_interop_t` object.
110 const char *__KAI_KMPC_CONVENTION
111 omp_get_interop_type_desc(const omp_interop_t
, omp_interop_property_t
);
113 * The `omp_get_interop_rc_desc` routine retrieves a description of the return
114 * code associated with an `omp_interop_t` object.
116 extern const char *__KAI_KMPC_CONVENTION
117 omp_get_interop_rc_desc(const omp_interop_t
, omp_interop_rc_t
);
119 typedef enum omp_interop_backend_type_t
{
121 omp_interop_backend_type_cuda_1
= 1,
122 } omp_interop_backend_type_t
;
124 typedef enum kmp_interop_type_t
{
125 kmp_interop_type_unknown
= -1,
126 kmp_interop_type_platform
,
127 kmp_interop_type_device
,
128 kmp_interop_type_tasksync
,
129 } kmp_interop_type_t
;
131 typedef enum omp_foreign_runtime_ids
{
138 } omp_foreign_runtime_ids_t
;
140 /// The interop value type, aka. the interop object.
141 typedef struct omp_interop_val_t
{
142 /// Device and interop-type are determined at construction time and fix.
143 omp_interop_val_t(intptr_t device_id
, kmp_interop_type_t interop_type
)
144 : interop_type(interop_type
), device_id(device_id
) {}
145 const char *err_str
= nullptr;
146 __tgt_async_info
*async_info
= nullptr;
147 __tgt_device_info device_info
;
148 const kmp_interop_type_t interop_type
;
149 const intptr_t device_id
;
150 const omp_foreign_runtime_ids_t vendor_id
= cuda
;
151 const intptr_t backend_type_id
= omp_interop_backend_type_cuda_1
;