CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
90 lines
3.5 KiB
C++
90 lines
3.5 KiB
C++
/*************************************************************************
|
|
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
|
|
*
|
|
* See LICENSE.txt for license information
|
|
************************************************************************/
|
|
|
|
#include <gtest/gtest.h>
|
|
#include <rccl/rccl.h>
|
|
|
|
#include "RcclMockFuncs.hpp"
|
|
#include "comm.h"
|
|
#include "common/ProcessIsolatedTestRunner.hpp"
|
|
|
|
#include <fstream>
|
|
#include <thread>
|
|
|
|
#define HIPCALL(cmd) \
|
|
do { \
|
|
hipError_t error = (cmd); \
|
|
GTEST_ASSERT_EQ(error, hipSuccess); \
|
|
} while (0)
|
|
|
|
namespace RcclUnitTesting
|
|
{
|
|
/**
|
|
* \brief Verify correctness of Recorder record() correctness in binary mode
|
|
* ******************************************************************************************/
|
|
TEST(Recorder, ParseBinary)
|
|
{
|
|
// to add after binary export of logging is supported
|
|
}
|
|
|
|
/**
|
|
* \brief Verify correctness of Recorder record() correctness in json mode
|
|
* ******************************************************************************************/
|
|
TEST(Recorder, ParseJson)
|
|
{
|
|
RUN_ISOLATED_TEST_WITH_ENV(
|
|
"ParseJson",
|
|
[]()
|
|
{
|
|
int pid = getpid();
|
|
hipStream_t stream;
|
|
HIPCALL(hipStreamCreate(&stream));
|
|
|
|
int array[] = {2, 3, 5};
|
|
ncclComm comm{.nRanks = 1, .localRank = 1, .localRankToRank = array, .opCount = 8, .planner = {.nTasksColl = 13, .nTasksP2p = 21}};
|
|
rccl::rcclApiCall call(rccl::rrAllToAllv, {.sendbuff = (void*)0x7f22f9600000, .recvbuff = (void*)0x7f22f9601000, .count = 0, .datatype = ncclFloat32, .comm = &comm, .stream = stream});
|
|
rccl::Recorder::instance().record(call);
|
|
|
|
std::vector<rccl::rcclApiCall> calls;
|
|
char entry[4096];
|
|
gethostname(entry, 256);
|
|
// Parse the output file written by the Recorder
|
|
std::string filename = "/tmp/test." + std::to_string(pid) + "." + std::string(entry) + ".json";
|
|
std::ifstream fp(filename);
|
|
ASSERT_TRUE(fp.is_open()) << "Recorder did not create expected file: " << filename;
|
|
fp.getline(entry, 4096); // line 1: "{"
|
|
fp.getline(entry, 4096); // line 2: " version : 1,"
|
|
fp.getline(entry, 4096); // line 3: the serialised API call
|
|
parseJsonEntry(entry, calls);
|
|
ASSERT_FALSE(calls.empty()) << "parseJsonEntry produced no results; raw line: " << entry;
|
|
// Compare all fields after pid (pid is the child's pid, not the outer test's)
|
|
int result = memcmp(&(calls[0].pid)+1, &(call.pid)+1, sizeof(rccl::rcclApiCall)-sizeof(call.pid));
|
|
fp.close();
|
|
EXPECT_EQ(result, 0) << "Round-tripped rcclApiCall fields do not match";
|
|
},
|
|
{{"RCCL_REPLAY_FILE", "/tmp/test.json"}}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* \brief Verify RCCL Recorder's integrity in multithread context by comparing Recorder
|
|
* instance across different threads.
|
|
* ******************************************************************************************/
|
|
static void recorderCmp(void** recorder)
|
|
{
|
|
*recorder = &(rccl::Recorder::instance());
|
|
}
|
|
TEST(Recorder, VerifyMultithread)
|
|
{
|
|
void *p1, *p2;
|
|
std::thread t1(recorderCmp, &p1);
|
|
std::thread t2(recorderCmp, &p2);
|
|
t1.join();
|
|
t2.join();
|
|
assert(p1 == p2);
|
|
}
|
|
}
|