Files
TheRock/rocm-systems/projects/rccl/test/AllToAllVTests.cpp
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

204 lines
7.6 KiB
C++

/*************************************************************************
* Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
*
* See LICENSE.txt for license information
************************************************************************/
// Note: InPlace is not supported for All-To-Allv
#include "TestBed.hpp"
namespace RcclUnitTesting
{
// Prepare sendcount/recvcounts, sdispls/rdispls arrays within options
void PrepareCounts(int const totalRanks, int const chunkSize,
OptionalColArgs& options,
std::vector<size_t>& numInputElements,
std::vector<size_t>& numOutputElements,
int percentZeroElement = 0)
{
numInputElements.clear();
numOutputElements.clear();
numInputElements.resize(totalRanks, 0);
numOutputElements.resize(totalRanks, 0);
// Decide how many elements each pair send/recv
for (int sendRank = 0; sendRank < totalRanks; ++sendRank)
for (int recvRank = 0; recvRank < totalRanks; ++recvRank)
{
// Get linear indices into sendcounts/recvcounts array
int const sendIdx = sendRank * totalRanks + recvRank;
int const recvIdx = recvRank * totalRanks + sendRank;
// Each pair sends slightly different amounts of elements (based on chunkSize)
int numElements = (1 + sendRank + recvRank) * chunkSize;
options.sendcounts[sendIdx] = options.recvcounts[recvIdx] = numElements;
}
// Psuedo-randomly zero out some of the sends
int s = 0, r = 0;
double zeroStride = (percentZeroElement <= 0) ? (totalRanks * totalRanks + 1) :
(percentZeroElement >= 100) ? 1.0
: 100.0 / percentZeroElement;
double zeroTarget = zeroStride;
for (int i = 1; i <= totalRanks * totalRanks; i++) {
if (i >= zeroTarget) {
options.sendcounts[s * totalRanks + r] = options.recvcounts[r * totalRanks + s] = 0;
zeroTarget += zeroStride;
}
int next = ((s*totalRanks+(r+(s*s)%7/2)%totalRanks) + totalRanks-1) % (totalRanks*totalRanks);
s = next / totalRanks;
r = ((next % totalRanks) - (s*s)%7/2) % totalRanks;
if (r < 0) r += totalRanks;
}
// Compute displacements
for (int sendRank = 0; sendRank < totalRanks; ++sendRank)
{
int totalSend = 0;
int totalRecv = 0;
for (int recvRank = 0; recvRank < totalRanks; ++recvRank)
{
int const pairIdx = sendRank * totalRanks + recvRank;
options.sdispls[pairIdx] = totalSend;
options.rdispls[pairIdx] = totalRecv;
totalSend += options.sendcounts[pairIdx];
totalRecv += options.recvcounts[pairIdx];
}
numInputElements[sendRank] = totalSend;
numOutputElements[sendRank] = totalRecv;
}
}
TEST(AlltoAllv, OutOfPlace)
{
TestBed testBed;
// Configuration
std::vector<ncclDataType_t> const& testDataTypes = {ncclInt32, ncclFloat64, ncclFloat16};
bool const inPlace = false;
bool const useManagedMem = false;
bool const useHipGraph = false;
OptionalColArgs options;
std::vector<ncclDataType_t> dataTypes;
testBed.GetSupportedDataTypes(dataTypes, testDataTypes);
if (dataTypes.empty()) {
GTEST_SKIP() << "Skipping... test datatypes excluded by UT_DATATYPES.";
}
bool isCorrect = true;
for (int totalRanks : testBed.ev.GetNumGpusList())
for (int isMultiProcess : testBed.ev.GetIsMultiProcessList())
{
int const numProcesses = isMultiProcess ? totalRanks : 1;
const std::vector<int>& gpuPriorityOrder = testBed.ev.GetGpuPriorityOrder();
testBed.InitComms(TestBed::GetDeviceIdsList(numProcesses, totalRanks, gpuPriorityOrder));
// Prepare AlltoAllV options
std::vector<size_t> numInputElements;
std::vector<size_t> numOutputElements;
PrepareCounts(totalRanks, 256, options, numInputElements, numOutputElements, 40);
for (int dataIdx = 0; dataIdx < dataTypes.size() && isCorrect; ++dataIdx)
{
if (testBed.ev.showNames)
{
std::string name = testBed.GetTestCaseName(totalRanks, isMultiProcess,
ncclCollAlltoAllv, dataTypes[dataIdx],
ncclSum, -1, inPlace, useManagedMem, useHipGraph);
TEST_INFO("%s", name.c_str());
}
for (int rank = 0; rank < totalRanks; ++rank)
{
testBed.SetCollectiveArgs(ncclCollAlltoAllv,
dataTypes[dataIdx],
numInputElements[rank],
numOutputElements[rank],
options,
-1,
0,
rank);
}
testBed.AllocateMem(inPlace, useManagedMem);
testBed.PrepareData();
testBed.ExecuteCollectives({}, useHipGraph);
testBed.ValidateResults(isCorrect);
testBed.DeallocateMem();
}
testBed.DestroyComms();
}
testBed.Finalize();
}
TEST(AlltoAllv, OutOfPlaceGraph)
{
TestBed testBed;
// Configuration
std::vector<ncclDataType_t> const& testDataTypes = {ncclFloat32, ncclInt8};
bool const inPlace = false;
bool const useManagedMem = false;
bool const useHipGraph = false;
OptionalColArgs options;
std::vector<ncclDataType_t> dataTypes;
testBed.GetSupportedDataTypes(dataTypes, testDataTypes);
if (dataTypes.empty()) {
GTEST_SKIP() << "Skipping... test datatypes excluded by UT_DATATYPES.";
}
bool isCorrect = true;
for (int totalRanks : testBed.ev.GetNumGpusList())
for (int isMultiProcess : testBed.ev.GetIsMultiProcessList())
{
int const numProcesses = isMultiProcess ? totalRanks : 1;
const std::vector<int>& gpuPriorityOrder = testBed.ev.GetGpuPriorityOrder();
testBed.InitComms(TestBed::GetDeviceIdsList(numProcesses, totalRanks, gpuPriorityOrder));
// Prepare AlltoAllV options
std::vector<size_t> numInputElements;
std::vector<size_t> numOutputElements;
PrepareCounts(totalRanks, 256, options, numInputElements, numOutputElements, 60);
for (int dataIdx = 0; dataIdx < dataTypes.size() && isCorrect; ++dataIdx)
{
if (testBed.ev.showNames)
{
std::string name = testBed.GetTestCaseName(totalRanks, isMultiProcess,
ncclCollAlltoAllv, dataTypes[dataIdx],
ncclSum, -1, inPlace, useManagedMem, useHipGraph);
TEST_INFO("%s", name.c_str());
}
for (int rank = 0; rank < totalRanks; ++rank)
{
testBed.SetCollectiveArgs(ncclCollAlltoAllv,
dataTypes[dataIdx],
numInputElements[rank],
numOutputElements[rank],
options,
-1,
0,
rank);
}
testBed.AllocateMem(inPlace, useManagedMem);
testBed.PrepareData();
testBed.ExecuteCollectives({}, useHipGraph);
testBed.ValidateResults(isCorrect);
testBed.DeallocateMem();
}
testBed.DestroyComms();
}
testBed.Finalize();
}
}