1 //===---------- GPU implementation of the external RPC call function ------===//
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 //===----------------------------------------------------------------------===//
9 #include "src/gpu/rpc_host_call.h"
11 #include "src/__support/GPU/utils.h"
12 #include "src/__support/RPC/rpc_client.h"
13 #include "src/__support/common.h"
15 namespace LIBC_NAMESPACE
{
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
);
22 port
.send([=](rpc::Buffer
*buffer
) {
23 buffer
->data
[0] = reinterpret_cast<uintptr_t>(fn
);
25 port
.recv([](rpc::Buffer
*) {});
29 } // namespace LIBC_NAMESPACE