1 | //===-- Loader test to check the RPC interface with the loader ------------===// |
---|---|
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 "include/llvm-libc-types/test_rpc_opcodes_t.h" |
10 | #include "src/__support/GPU/utils.h" |
11 | #include "src/__support/RPC/rpc_client.h" |
12 | #include "test/IntegrationTest/test.h" |
13 | |
14 | using namespace LIBC_NAMESPACE; |
15 | |
16 | static void test_add() { |
17 | uint64_t cnt = gpu::get_lane_id(); |
18 | LIBC_NAMESPACE::rpc::Client::Port port = |
19 | LIBC_NAMESPACE::rpc::client.open<RPC_TEST_INCREMENT>(); |
20 | port.send_and_recv( |
21 | [=](LIBC_NAMESPACE::rpc::Buffer *buffer, uint32_t) { |
22 | reinterpret_cast<uint64_t *>(buffer->data)[0] = cnt; |
23 | }, |
24 | [&](LIBC_NAMESPACE::rpc::Buffer *buffer, uint32_t) { |
25 | cnt = reinterpret_cast<uint64_t *>(buffer->data)[0]; |
26 | }); |
27 | port.close(); |
28 | EXPECT_EQ(cnt, gpu::get_lane_id() + 1); |
29 | EXPECT_EQ(gpu::get_thread_id(), gpu::get_lane_id()); |
30 | } |
31 | |
32 | TEST_MAIN(int argc, char **argv, char **envp) { |
33 | test_add(); |
34 | |
35 | return 0; |
36 | } |
37 |