Summary: This was originally kept separate so it didn't pollute the name space, but now I'm thinking it's just easier to bundle it in with the default interface. This means that we'll have a bit of extra code for people using the server.h file to handle libc opcodes, but it's minimal (3 functions) and it simplifies this. I'm doing this because I'm hoping to move the GPU tester binary to liboffload which handles `libc` opcodes internally except these. This is the easier option compared to adding a hook to register custom handlers there.
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
//===-- Loader test to check the RPC interface with the loader ------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "src/__support/GPU/utils.h"
|
|
#include "src/__support/RPC/rpc_client.h"
|
|
#include "test/IntegrationTest/test.h"
|
|
|
|
using namespace LIBC_NAMESPACE;
|
|
|
|
static void test_add() {
|
|
uint64_t cnt = gpu::get_lane_id();
|
|
LIBC_NAMESPACE::rpc::Client::Port port =
|
|
LIBC_NAMESPACE::rpc::client.open<LIBC_TEST_INCREMENT>();
|
|
port.send_and_recv(
|
|
[=](LIBC_NAMESPACE::rpc::Buffer *buffer, uint32_t) {
|
|
reinterpret_cast<uint64_t *>(buffer->data)[0] = cnt;
|
|
},
|
|
[&](LIBC_NAMESPACE::rpc::Buffer *buffer, uint32_t) {
|
|
cnt = reinterpret_cast<uint64_t *>(buffer->data)[0];
|
|
});
|
|
port.close();
|
|
EXPECT_EQ(cnt, gpu::get_lane_id() + 1);
|
|
EXPECT_EQ(gpu::get_thread_id(), gpu::get_lane_id());
|
|
}
|
|
|
|
TEST_MAIN(int, char **, char **) {
|
|
test_add();
|
|
|
|
return 0;
|
|
}
|