[libc] Test the RPC interface with multiple blocks
authorJoseph Huber <jhuber6@vols.utk.edu>
Mon, 17 Apr 2023 12:09:59 +0000 (07:09 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 20 Apr 2023 01:02:33 +0000 (20:02 -0500)
The RPC interface can support multiple independent clients. This support
currently only supports many single-thread warps / workgroups
coordinating over a single lock. This patch uses the support added in
the previous patch to test the RPC interface with multiple blocks.

Note that this does not work with multiple threads currently because of
the effect of warps / workgroups executing in lockstep incorrectly. This
will be added later.

Depends on D148485

Reviewed By: lntue, sivachandra

Differential Revision: https://reviews.llvm.org/D148486

libc/cmake/modules/LLVMLibCTestRules.cmake
libc/test/integration/startup/gpu/CMakeLists.txt
libc/test/integration/startup/gpu/rpc_test.cpp

index f9da04c..0ce5c80 100644 (file)
@@ -421,7 +421,7 @@ function(add_integration_test test_name)
     "INTEGRATION_TEST"
     "" # No optional arguments
     "SUITE" # Single value arguments
-    "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS" # Multi-value arguments
+    "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LOADER_ARGS" # Multi-value arguments
     ${ARGN}
   )
 
@@ -533,6 +533,7 @@ function(add_integration_test test_name)
     ${fq_target_name}
     COMMAND ${INTEGRATION_TEST_ENV}
             $<$<BOOL:${LIBC_TARGET_ARCHITECTURE_IS_GPU}>:${gpu_loader_exe}>
+            ${INTEGRATION_TEST_LOADER_ARGS}
             $<TARGET_FILE:${fq_build_target_name}> ${INTEGRATION_TEST_ARGS}
     COMMENT "Running integration test ${fq_target_name}"
   )
index a68873c..bc44fe1 100644 (file)
@@ -20,4 +20,8 @@ add_integration_test(
     rpc_test.cpp
   DEPENDS
     libc.src.__support.RPC.rpc_client
+    libc.src.__support.GPU.utils
+  LOADER_ARGS
+    --blocks 16
+    --threads 1
 )
index 3f823ae..0d3f137 100644 (file)
@@ -6,15 +6,16 @@
 //
 //===----------------------------------------------------------------------===//
 
+#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() {
-  constexpr int num_additions = 10000;
+  uint32_t num_additions = 1000 + 10 * get_block_id_x();
   uint64_t cnt = 0;
-  for (int i = 0; i < num_additions; ++i) {
+  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) {
@@ -30,5 +31,6 @@ static void test_add_simple() {
 
 TEST_MAIN(int argc, char **argv, char **envp) {
   test_add_simple();
+
   return 0;
 }