13
13
14
14
#include " PluginInterface.h"
15
15
16
- // TODO: This should be included unconditionally and cleaned up.
17
- #if defined(LIBOMPTARGET_RPC_SUPPORT)
18
16
#include " shared/rpc.h"
19
17
#include " shared/rpc_opcodes.h"
20
- #endif
21
18
22
19
using namespace llvm ;
23
20
using namespace omp ;
@@ -63,7 +60,7 @@ rpc::Status handle_offload_opcodes(plugin::GenericDeviceTy &Device,
63
60
return rpc::UNHANDLED_OPCODE;
64
61
break ;
65
62
}
66
- return rpc::UNHANDLED_OPCODE ;
63
+ return rpc::SUCCESS ;
67
64
}
68
65
69
66
static rpc::Status handle_offload_opcodes (plugin::GenericDeviceTy &Device,
@@ -86,17 +83,12 @@ llvm::Expected<bool>
86
83
RPCServerTy::isDeviceUsingRPC (plugin::GenericDeviceTy &Device,
87
84
plugin::GenericGlobalHandlerTy &Handler,
88
85
plugin::DeviceImageTy &Image) {
89
- #ifdef LIBOMPTARGET_RPC_SUPPORT
90
86
return Handler.isSymbolInImage (Device, Image, " __llvm_rpc_client" );
91
- #else
92
- return false ;
93
- #endif
94
87
}
95
88
96
89
Error RPCServerTy::initDevice (plugin::GenericDeviceTy &Device,
97
90
plugin::GenericGlobalHandlerTy &Handler,
98
91
plugin::DeviceImageTy &Image) {
99
- #ifdef LIBOMPTARGET_RPC_SUPPORT
100
92
uint64_t NumPorts =
101
93
std::min (Device.requestedRPCPortCount (), rpc::MAX_PORT_COUNT);
102
94
void *RPCBuffer = Device.allocate (
@@ -119,13 +111,9 @@ Error RPCServerTy::initDevice(plugin::GenericDeviceTy &Device,
119
111
Buffers[Device.getDeviceId ()] = RPCBuffer;
120
112
121
113
return Error::success ();
122
-
123
- #endif
124
- return Error::success ();
125
114
}
126
115
127
116
Error RPCServerTy::runServer (plugin::GenericDeviceTy &Device) {
128
- #ifdef LIBOMPTARGET_RPC_SUPPORT
129
117
uint64_t NumPorts =
130
118
std::min (Device.requestedRPCPortCount (), rpc::MAX_PORT_COUNT);
131
119
rpc::Server Server (NumPorts, Buffers[Device.getDeviceId ()]);
@@ -135,23 +123,21 @@ Error RPCServerTy::runServer(plugin::GenericDeviceTy &Device) {
135
123
return Error::success ();
136
124
137
125
int Status = handle_offload_opcodes (Device, *Port, Device.getWarpSize ());
126
+
138
127
// Let the `libc` library handle any other unhandled opcodes.
128
+ #ifdef LIBOMPTARGET_RPC_SUPPORT
139
129
if (Status == rpc::UNHANDLED_OPCODE)
140
130
Status = handle_libc_opcodes (*Port, Device.getWarpSize ());
141
- Port-> close ();
131
+ # endif
142
132
133
+ Port->close ();
143
134
if (Status != rpc::SUCCESS)
144
135
return createStringError (" RPC server given invalid opcode!" );
145
136
146
- return Error::success ();
147
- #endif
148
137
return Error::success ();
149
138
}
150
139
151
140
Error RPCServerTy::deinitDevice (plugin::GenericDeviceTy &Device) {
152
- #ifdef LIBOMPTARGET_RPC_SUPPORT
153
141
Device.free (Buffers[Device.getDeviceId ()], TARGET_ALLOC_HOST);
154
142
return Error::success ();
155
- #endif
156
- return Error::success ();
157
143
}
0 commit comments