1313
1414#include " PluginInterface.h"
1515
16- // TODO: This should be included unconditionally and cleaned up.
17- #if defined(LIBOMPTARGET_RPC_SUPPORT)
1816#include " shared/rpc.h"
1917#include " shared/rpc_opcodes.h"
20- #endif
2118
2219using namespace llvm ;
2320using namespace omp ;
@@ -63,7 +60,7 @@ rpc::Status handle_offload_opcodes(plugin::GenericDeviceTy &Device,
6360 return rpc::UNHANDLED_OPCODE;
6461 break ;
6562 }
66- return rpc::UNHANDLED_OPCODE ;
63+ return rpc::SUCCESS ;
6764}
6865
6966static rpc::Status handle_offload_opcodes (plugin::GenericDeviceTy &Device,
@@ -86,17 +83,12 @@ llvm::Expected<bool>
8683RPCServerTy::isDeviceUsingRPC (plugin::GenericDeviceTy &Device,
8784 plugin::GenericGlobalHandlerTy &Handler,
8885 plugin::DeviceImageTy &Image) {
89- #ifdef LIBOMPTARGET_RPC_SUPPORT
9086 return Handler.isSymbolInImage (Device, Image, " __llvm_rpc_client" );
91- #else
92- return false ;
93- #endif
9487}
9588
9689Error RPCServerTy::initDevice (plugin::GenericDeviceTy &Device,
9790 plugin::GenericGlobalHandlerTy &Handler,
9891 plugin::DeviceImageTy &Image) {
99- #ifdef LIBOMPTARGET_RPC_SUPPORT
10092 uint64_t NumPorts =
10193 std::min (Device.requestedRPCPortCount (), rpc::MAX_PORT_COUNT);
10294 void *RPCBuffer = Device.allocate (
@@ -119,13 +111,9 @@ Error RPCServerTy::initDevice(plugin::GenericDeviceTy &Device,
119111 Buffers[Device.getDeviceId ()] = RPCBuffer;
120112
121113 return Error::success ();
122-
123- #endif
124- return Error::success ();
125114}
126115
127116Error RPCServerTy::runServer (plugin::GenericDeviceTy &Device) {
128- #ifdef LIBOMPTARGET_RPC_SUPPORT
129117 uint64_t NumPorts =
130118 std::min (Device.requestedRPCPortCount (), rpc::MAX_PORT_COUNT);
131119 rpc::Server Server (NumPorts, Buffers[Device.getDeviceId ()]);
@@ -135,23 +123,21 @@ Error RPCServerTy::runServer(plugin::GenericDeviceTy &Device) {
135123 return Error::success ();
136124
137125 int Status = handle_offload_opcodes (Device, *Port, Device.getWarpSize ());
126+
138127 // Let the `libc` library handle any other unhandled opcodes.
128+ #ifdef LIBOMPTARGET_RPC_SUPPORT
139129 if (Status == rpc::UNHANDLED_OPCODE)
140130 Status = handle_libc_opcodes (*Port, Device.getWarpSize ());
141- Port-> close ();
131+ # endif
142132
133+ Port->close ();
143134 if (Status != rpc::SUCCESS)
144135 return createStringError (" RPC server given invalid opcode!" );
145136
146- return Error::success ();
147- #endif
148137 return Error::success ();
149138}
150139
151140Error RPCServerTy::deinitDevice (plugin::GenericDeviceTy &Device) {
152- #ifdef LIBOMPTARGET_RPC_SUPPORT
153141 Device.free (Buffers[Device.getDeviceId ()], TARGET_ALLOC_HOST);
154142 return Error::success ();
155- #endif
156- return Error::success ();
157143}
0 commit comments