Skip to content

Commit 9f1d7db

Browse files
committed
Revert "[OFFLOAD][OPENMP] 6.0 compatible interop interface (llvm#143491)"
This reverts commit 66d1c37. This patch is the runtime library part of a 2-patch piece of work. The second piece to this is codegen work. For the codegen part, there currently is no clear timeline. However, without the codegen part, this patch breaks interop and does not make sense. I propose to revert this patch for now and clarify the path forward.
1 parent 9df1099 commit 9f1d7db

File tree

16 files changed

+174
-826
lines changed

16 files changed

+174
-826
lines changed

offload/include/OpenMP/InteropAPI.h

Lines changed: 5 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -13,69 +13,17 @@
1313

1414
#include "omp.h"
1515

16-
#include "PerThreadTable.h"
1716
#include "omptarget.h"
1817

1918
extern "C" {
2019

2120
typedef enum kmp_interop_type_t {
2221
kmp_interop_type_unknown = -1,
23-
kmp_interop_type_target,
24-
kmp_interop_type_targetsync,
22+
kmp_interop_type_platform,
23+
kmp_interop_type_device,
24+
kmp_interop_type_tasksync,
2525
} kmp_interop_type_t;
2626

27-
struct interop_attrs_t {
28-
bool inorder : 1;
29-
int reserved : 31;
30-
31-
/// Check if the supported attributes are compatible with the current
32-
/// attributes. Only if an attribute is supported can the value be true,
33-
/// otherwise it needs to be false
34-
bool checkSupportedOnly(interop_attrs_t supported) const {
35-
return supported.inorder || (!supported.inorder && !inorder);
36-
}
37-
};
38-
39-
struct interop_spec_t {
40-
int32_t fr_id;
41-
interop_attrs_t attrs; // Common attributes
42-
int64_t impl_attrs; // Implementation specific attributes (recognized by each
43-
// plugin)
44-
};
45-
46-
struct interop_flags_t {
47-
bool implicit : 1; // dispatch (true) or interop (false)
48-
bool nowait : 1; // has nowait flag
49-
int reserved : 30;
50-
};
51-
52-
struct interop_ctx_t {
53-
uint32_t version; // version of the interface (current is 0)
54-
interop_flags_t flags;
55-
int gtid;
56-
};
57-
58-
struct dep_pack_t {
59-
int32_t ndeps;
60-
int32_t ndeps_noalias;
61-
kmp_depend_info_t *deplist;
62-
kmp_depend_info_t *noalias_deplist;
63-
};
64-
65-
struct omp_interop_val_t;
66-
67-
typedef void ompx_interop_cb_t(omp_interop_val_t *interop, void *data);
68-
69-
struct omp_interop_cb_instance_t {
70-
ompx_interop_cb_t *cb;
71-
void *data;
72-
73-
omp_interop_cb_instance_t(ompx_interop_cb_t *cb, void *data)
74-
: cb(cb), data(data) {}
75-
76-
void operator()(omp_interop_val_t *interop) { cb(interop, data); }
77-
};
78-
7927
/// The interop value type, aka. the interop object.
8028
typedef struct omp_interop_val_t {
8129
/// Device and interop-type are determined at construction time and fix.
@@ -86,98 +34,10 @@ typedef struct omp_interop_val_t {
8634
__tgt_device_info device_info;
8735
const kmp_interop_type_t interop_type;
8836
const intptr_t device_id;
89-
omp_vendor_id_t vendor_id = omp_vendor_llvm;
90-
tgt_foreign_runtime_id_t fr_id = tgt_fr_none;
91-
interop_attrs_t attrs{false, 0}; // Common prefer specification attributes
92-
int64_t impl_attrs = 0; // Implementation prefer specification attributes
93-
94-
// Constants
95-
static constexpr int no_owner = -1; // This interop has no current owner
96-
97-
void *rtl_property = nullptr; // Plugin dependent information
98-
// For implicitly created Interop objects (e.g., from a dispatch construct)
99-
// who owns the object
100-
int owner_gtid = no_owner;
101-
// Marks whether the object was requested since the last time it was synced
102-
bool clean = true;
103-
104-
typedef llvm::SmallVector<omp_interop_cb_instance_t> callback_list_t;
105-
106-
callback_list_t completion_cbs;
107-
108-
void reset() {
109-
owner_gtid = no_owner;
110-
markClean();
111-
clearCompletionCbs();
112-
}
113-
114-
llvm::Expected<DeviceTy &> getDevice() const;
115-
116-
bool hasOwner() const { return owner_gtid != no_owner; }
117-
118-
void setOwner(int gtid) { owner_gtid = gtid; }
119-
bool isOwnedBy(int gtid) { return owner_gtid == gtid; }
120-
bool isCompatibleWith(int32_t InteropType, const interop_spec_t &Spec);
121-
bool isCompatibleWith(int32_t InteropType, const interop_spec_t &Spec,
122-
int64_t DeviceNum, int gtid);
123-
void markClean() { clean = true; }
124-
void markDirty() { clean = false; }
125-
bool isClean() const { return clean; }
126-
127-
int32_t flush(DeviceTy &Device);
128-
int32_t sync_barrier(DeviceTy &Device);
129-
int32_t async_barrier(DeviceTy &Device);
130-
int32_t release(DeviceTy &Device);
131-
132-
void addCompletionCb(ompx_interop_cb_t *cb, void *data) {
133-
completion_cbs.push_back(omp_interop_cb_instance_t(cb, data));
134-
}
135-
136-
int numCompletionCbs() const { return completion_cbs.size(); }
137-
void clearCompletionCbs() { completion_cbs.clear(); }
138-
139-
void runCompletionCbs() {
140-
for (auto &cbInstance : completion_cbs)
141-
cbInstance(this);
142-
clearCompletionCbs();
143-
}
37+
const omp_foreign_runtime_ids_t vendor_id = cuda;
38+
const intptr_t backend_type_id = omp_interop_backend_type_cuda_1;
14439
} omp_interop_val_t;
14540

14641
} // extern "C"
14742

148-
struct InteropTableEntry {
149-
using ContainerTy = typename std::vector<omp_interop_val_t *>;
150-
using iterator = typename ContainerTy::iterator;
151-
152-
ContainerTy Interops;
153-
154-
static constexpr int reservedEntriesPerThread =
155-
20; // reserve some entries to avoid reallocation
156-
157-
void add(omp_interop_val_t *obj) {
158-
if (Interops.capacity() == 0)
159-
Interops.reserve(reservedEntriesPerThread);
160-
Interops.push_back(obj);
161-
}
162-
163-
template <class ClearFuncTy> void clear(ClearFuncTy f) {
164-
for (auto &Obj : Interops) {
165-
f(Obj);
166-
}
167-
}
168-
169-
/// vector interface
170-
int size() const { return Interops.size(); }
171-
iterator begin() { return Interops.begin(); }
172-
iterator end() { return Interops.end(); }
173-
iterator erase(iterator it) { return Interops.erase(it); }
174-
};
175-
176-
struct InteropTblTy
177-
: public PerThreadTable<InteropTableEntry, omp_interop_val_t *> {
178-
void clear();
179-
};
180-
181-
void syncImplicitInterops(int gtid, void *event);
182-
18343
#endif // OMPTARGET_OPENMP_INTEROP_API_H

offload/include/OpenMP/omp.h

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,15 @@ typedef enum omp_interop_rc {
8080
omp_irc_other = -6
8181
} omp_interop_rc_t;
8282

83-
/* Foreign runtime values from OpenMP Additional Definitions document v2.1 */
84-
typedef enum tgt_foreign_runtime_id_t {
85-
tgt_fr_none = 0,
86-
tgt_fr_cuda = 1,
87-
tgt_fr_cuda_driver = 2,
88-
tgt_fr_opencl = 3,
89-
tgt_fr_sycl = 4,
90-
tgt_fr_hip = 5,
91-
tgt_fr_level_zero = 6,
92-
tgt_fr_hsa = 7,
93-
tgt_fr_last = 8
94-
} tgt_foreign_runtime_id_t;
83+
typedef enum omp_interop_fr {
84+
omp_ifr_cuda = 1,
85+
omp_ifr_cuda_driver = 2,
86+
omp_ifr_opencl = 3,
87+
omp_ifr_sycl = 4,
88+
omp_ifr_hip = 5,
89+
omp_ifr_level_zero = 6,
90+
omp_ifr_last = 7
91+
} omp_interop_fr_t;
9592

9693
typedef void *omp_interop_t;
9794

@@ -137,23 +134,19 @@ omp_get_interop_type_desc(const omp_interop_t, omp_interop_property_t);
137134
extern const char *__KAI_KMPC_CONVENTION
138135
omp_get_interop_rc_desc(const omp_interop_t, omp_interop_rc_t);
139136

140-
/* Vendor defined values from OpenMP Additional Definitions document v2.1*/
141-
typedef enum omp_vendor_id {
142-
omp_vendor_unknown = 0,
143-
omp_vendor_amd = 1,
144-
omp_vendor_arm = 2,
145-
omp_vendor_bsc = 3,
146-
omp_vendor_fujitsu = 4,
147-
omp_vendor_gnu = 5,
148-
omp_vendor_hpe = 6,
149-
omp_vendor_ibm = 7,
150-
omp_vendor_intel = 8,
151-
omp_vendor_llvm = 9,
152-
omp_vendor_nec = 10,
153-
omp_vendor_nvidia = 11,
154-
omp_vendor_ti = 12,
155-
omp_vendor_last = 13
156-
} omp_vendor_id_t;
137+
typedef enum omp_interop_backend_type_t {
138+
// reserve 0
139+
omp_interop_backend_type_cuda_1 = 1,
140+
} omp_interop_backend_type_t;
141+
142+
typedef enum omp_foreign_runtime_ids {
143+
cuda = 1,
144+
cuda_driver = 2,
145+
opencl = 3,
146+
sycl = 4,
147+
hip = 5,
148+
level_zero = 6,
149+
} omp_foreign_runtime_ids_t;
157150

158151
///} InteropAPI
159152

offload/include/PerThreadTable.h

Lines changed: 0 additions & 114 deletions
This file was deleted.

offload/include/PluginManager.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
#include <mutex>
3636
#include <string>
3737

38-
#include "OpenMP/InteropAPI.h"
39-
4038
using GenericPluginTy = llvm::omp::target::plugin::GenericPluginTy;
4139

4240
/// Struct for the data required to handle plugins
@@ -90,9 +88,6 @@ struct PluginManager {
9088
HostPtrToTableMapTy HostPtrToTableMap;
9189
std::mutex TblMapMtx; ///< For HostPtrToTableMap
9290

93-
/// Table of cached implicit interop objects
94-
InteropTblTy InteropTbl;
95-
9691
// Work around for plugins that call dlopen on shared libraries that call
9792
// tgt_register_lib during their initialisation. Stash the pointers in a
9893
// vector until the plugins are all initialised and then register them.
@@ -190,6 +185,5 @@ void initRuntime();
190185
void deinitRuntime();
191186

192187
extern PluginManager *PM;
193-
extern std::atomic<bool> RTLAlive; // Indicates if the RTL has been initialized
194-
extern std::atomic<int> RTLOngoingSyncs; // Counts ongoing external syncs
188+
195189
#endif // OMPTARGET_PLUGIN_MANAGER_H

offload/include/Shared/APITypes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ struct __tgt_device_image {
3737
struct __tgt_device_info {
3838
void *Context = nullptr;
3939
void *Device = nullptr;
40-
void *Platform = nullptr;
4140
};
4241

4342
/// This struct is a record of all the host code that may be offloaded to a

0 commit comments

Comments
 (0)