RCCL Replayer update (#1603)

RCCL recorder w/ suggested change and UT



[ROCm/rccl commit: 9a55ff60a9]
This commit is contained in:
Tim
2025-04-19 00:21:27 -04:00
zatwierdzone przez GitHub
rodzic de2b66921a
commit 58ee618194
18 zmienionych plików z 1123 dodań i 93 usunięć
+2
Wyświetl plik
@@ -46,6 +46,7 @@ if(BUILD_TESTS)
ScatterTests.cpp
SendRecvTests.cpp
StandaloneTests.cpp
_RecorderTests.cpp
common/main.cpp
common/CallCollectiveForked.cpp
common/CollectiveArgs.cpp
@@ -55,6 +56,7 @@ if(BUILD_TESTS)
common/TestBed.cpp
common/TestBedChild.cpp
common/StandaloneUtils.cpp
../src/misc/recorder.cc
)
add_executable(rccl-UnitTests ${TEST_SOURCE_FILES})
@@ -0,0 +1,72 @@
/*************************************************************************
* 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 "TestBed.hpp"
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)
{
setenv("RCCL_REPLAY_FILE", "test.json", 1);
int pid = getpid();
hipStream_t stream;
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];
//parse the outfile
std::string filename = "test" + std::to_string(pid) + ".json";
std::ifstream fp("test" + std::to_string(pid) + ".json");
fp.getline(entry, 4096);
fp.getline(entry, 4096);
fp.getline(entry, 4096);
parseJsonEntry(entry, calls);
int result = memcmp((char*)&calls[0]+4, (char*)&call+4, sizeof(rccl::rcclApiCall)-4);
fp.close(); // care that recorder is not designed to anticipate fp closing before destructor
remove(filename.c_str());
unsetenv("RCCL_REPLAY_FILE");
assert(!result);
}
/**
* \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);
}
}
@@ -0,0 +1,7 @@
#include "info.h"
#include "comm.h"
void ncclDebugLog(ncclDebugLogLevel, unsigned long, char const*, int, char const*, ...) {};
ncclResult_t getHostName(char* hostname, int maxlen, const char delim) {
return ncclSuccess;
}