1 //===---------- GPU implementation of the external RPC call function ------===// 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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "src/gpu/rpc_host_call.h" 10 11 #include "src/__support/GPU/utils.h" 12 #include "src/__support/RPC/rpc_client.h" 13 #include "src/__support/common.h" 14 15 namespace LIBC_NAMESPACE { 16 17 // This calls the associated function pointer on the RPC server with the given 18 // arguments. We expect that the pointer here is a valid pointer on the server. 19 LLVM_LIBC_FUNCTION(void, rpc_host_call, (void *fn, void *data, size_t size)) { 20 rpc::Client::Port port = rpc::client.open<RPC_HOST_CALL>(); 21 port.send_n(data, size); __anon31fbf8960102(rpc::Buffer *buffer) 22 port.send([=](rpc::Buffer *buffer) { 23 buffer->data[0] = reinterpret_cast<uintptr_t>(fn); 24 }); __anon31fbf8960202(rpc::Buffer *) 25 port.recv([](rpc::Buffer *) {}); 26 port.close(); 27 } 28 29 } // namespace LIBC_NAMESPACE 30