Files
clang-p2996/libc/test/integration/startup/gpu/rpc_test.cpp
Joseph Huber 50445dff43 [libc] Add more utility functions for the GPU
This patch adds extra intrinsics for the GPU. Some of these are unused
for now but will be used later. We use these currently to update the
`RPC` handling. Currently, every thread can update the RPC client, which
isn't correct. This patch adds code neccesary to allow a single thread
to perfrom the write while the others wait.

Feedback is welcome for the naming of these functions. I'm copying the
OpenMP nomenclature where we call an AMD `wavefront` or NVIDIA `warp` a
`lane`.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D148810
2023-04-24 15:47:53 -05:00

37 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 __llvm_libc;
static void test_add_simple() {
uint32_t num_additions = 1000 + 10 * gpu::get_block_id_x();
uint64_t cnt = 0;
for (uint32_t i = 0; i < num_additions; ++i) {
rpc::Port port = rpc::client.open(rpc::TEST_INCREMENT);
port.send_and_recv(
[=](rpc::Buffer *buffer) {
reinterpret_cast<uint64_t *>(buffer->data)[0] = cnt;
},
[&](rpc::Buffer *buffer) {
cnt = reinterpret_cast<uint64_t *>(buffer->data)[0];
});
port.close();
}
ASSERT_TRUE(cnt == num_additions && "Incorrect sum");
}
TEST_MAIN(int argc, char **argv, char **envp) {
test_add_simple();
return 0;
}