1 //===-- Loader test to check the RPC interface with the loader ------------===//
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 "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"
14 using namespace LIBC_NAMESPACE
;
16 static void test_add_simple() {
17 uint32_t num_additions
=
18 10 + 10 * gpu::get_thread_id() + 10 * gpu::get_block_id();
20 for (uint32_t i
= 0; i
< num_additions
; ++i
) {
21 rpc::Client::Port port
= rpc::client
.open
<RPC_TEST_INCREMENT
>();
23 [=](rpc::Buffer
*buffer
) {
24 reinterpret_cast<uint64_t *>(buffer
->data
)[0] = cnt
;
26 [&](rpc::Buffer
*buffer
) {
27 cnt
= reinterpret_cast<uint64_t *>(buffer
->data
)[0];
31 ASSERT_TRUE(cnt
== num_additions
&& "Incorrect sum");
34 // Test to ensure that the RPC mechanism doesn't hang on divergence.
35 static void test_noop(uint8_t data
) {
36 rpc::Client::Port port
= rpc::client
.open
<RPC_NOOP
>();
37 port
.send([=](rpc::Buffer
*buffer
) { buffer
->data
[0] = data
; });
41 TEST_MAIN(int argc
, char **argv
, char **envp
) {
44 if (gpu::get_thread_id() % 2)