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