Files
TheRock/rocm-systems/projects/rccl/test/common/TestBedChild.hpp
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

127 lines
4.4 KiB
C++

/*************************************************************************
* Copyright (c) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* See LICENSE.txt for license information
************************************************************************/
#pragma once
#include <vector>
#include <unistd.h>
#include "CollectiveArgs.hpp"
#include "rccl/rccl.h"
#define MAX_RANKS 32
#define MAX_LOOP_COUNTER 400000000000
namespace RcclUnitTesting
{
class TestBedChild
{
public:
// These are commands that can be given to the child process
enum
{
CHILD_GET_UNIQUE_ID = 0, // GetUniqueId()
CHILD_INIT_COMMS = 1, // InitComms()
CHILD_SET_COLL_ARGS = 2, // SetCollectiveArgs()
CHILD_ALLOCATE_MEM = 3, // AllocateMem()
CHILD_PREPARE_DATA = 4, // PrepareData()
CHILD_EXECUTE_COLL = 5, // ExecuteCollectives()
CHILD_VALIDATE_RESULTS = 6, // ValidateResults()
CHILD_LAUNCH_GRAPHS = 7, // LaunchGraphs()
CHILD_DEALLOCATE_MEM = 8, // DeallocateMem()
CHILD_DESTROY_COMMS = 9, // DestroyComms()
CHILD_DESTROY_GRAPHS = 10, // DestroyGraphs()
CHILD_STOP = 11, // Stop()
NUM_CHILD_COMMANDS = 12
};
char const ChildCommandNames[NUM_CHILD_COMMANDS][20] =
{
"GET_UNIQUE_ID",
"INIT_COMMS",
"SET_COLL_ARGS",
"ALLOCATE_MEM",
"PREPARE_DATA",
"EXECUTE_COLL",
"VALIDATE_RESULTS",
"LAUNCH_GRAPHS",
"DEALLOCATE_MEM",
"DESTROY_COMMS",
"DESTROY_GRAPHS",
"STOP"
};
// These variables remain constant for life of TestBedChild
int childId;
pid_t pid;
bool verbose;
int printValues;
bool useRankThreading;
// Pipes used to communicate between parent process
int parentWriteFd;
int parentReadFd;
int childWriteFd;
int childReadFd;
// These varibles may change based on commands issued by parent
int totalRanks; // Total ranks
int rankOffset; // Global rank offset for this child
int numGroupCalls; // Toatal # of group calls to be executed
bool useBlocking; // RCCL communication with blocking or non-blocking option
std::vector<int> numCollectivesInGroup; // # of collectives to run per group call
std::vector<int> numStreamsPerGroup; // # of different streams allowed per group call
std::vector<ncclComm_t> comms; // RCCL communicators for each rank
std::vector<int> deviceIds; // Device IDs for each rank
std::vector<std::vector<std::vector<hipStream_t>>> streams; // Streams for executing collectives per group call
std::vector<std::vector<std::vector<CollectiveArgs>>> collArgs; // Info for each collective for each rank per group call
std::vector<std::vector<std::vector<hipGraph_t>>> graphs; // Graphs for executing collectives per group call
std::vector<std::vector<std::vector<hipGraphExec_t>>> graphExecs; // GraphExecs for executing collectives per group call
std::vector<std::vector<std::vector<bool>>> graphEnabled;
// Constructor
TestBedChild(int const childId, bool const verbose, int const printValues, bool const useRankThreading);
// Prepare parent/child communication pipes - to be executed by parent process
int InitPipes();
// Execution
void StartExecutionLoop();
protected:
// Calls ncclGetUniqueId and returns it to parent
ErrCode GetUniqueId(std::vector<char>& retValBuf);
// Initialize RCCL communicators
ErrCode InitComms();
// Set CollectiveArgs
ErrCode SetCollectiveArgs();
// Allocate memory (input (GPU) / output (GPU) / expected (CPU))
ErrCode AllocateMem();
// Prepare input and expected data
ErrCode PrepareData();
// Execute a group of collectives
ErrCode ExecuteCollectives();
// Validate that output matches expected
ErrCode ValidateResults();
// Launch instantiated graphs
ErrCode LaunchGraphs();
// Release allocated memory
ErrCode DeallocateMem();
// Destroys RCCL communicators
ErrCode DestroyComms();
// Destroys graphs
ErrCode DestroyGraphs();
};
}