142860442a
* Added MPI support to execute unit/functional tests
Update node and process validation
Updated node detection count and modified validation method
Update validation logic to include max procs and nodes
* Address review comments
* Fix warnings
* Added a new NET transport test and clean up
* Added MPI test logging mechanism
* Decoupled GTest framework
* Added Net IB functional tests
* Updated with resource guards
* Added NET IB tests and refactored code
* Update P2pWorkflow test
* Update documentation
* Add MPI_TESTS_ENABLED guard to the file
* Fix Shm and NetIB tests
* Applied refactoring and cleanup
* Replaced BufferGuard with AutoGuard
* Modified test debug logging
* Use macro to reduce NcclTypeTraits code duplication
- Replace repetitive template specializations with a single
DEFINE_NCCL_TYPE_TRAIT macro
- Use stringification operator (#) to auto-generate type name strings
- Add #undef to keep macro from polluting namespace
- Makes adding new type mappings trivial
* Unify buffer initialization with generic pattern function
- Remove initializeBufferWithCustomPattern
- Make initializeBufferWithPattern generic with PatternFunc template param
- Now single function handles all patterns via lambda injection
- Updated all test files to use lambdas for pattern generation
- Pattern logic now visible at call site (self-documenting)
* Unify buffer verification with pluggable pattern function
- Remove verifyBufferWithCustomCheck
- Make verifyBufferData generic with PatternFunc template param
- Single function handles all verification patterns via lambda injection
- Updated all test files to use lambdas
- Better defaults: num_samples=0 means verify all elements
- Pattern logic now visible at call site (self-documenting)
* Docs: Add DeviceBufferHelpers section to MPITestRunner.md
- Document new refactored buffer initialization/verification API
- Explain pluggable pattern functions with lambda examples
- Show type mapping and automatic float/int comparison
- Include migration guide from old API to new unified functions
- Demonstrate best practices with real-world examples
- Reference recent refactoring commits (macro-based type traits)
* Docs: Update documentation and examples
- Update on DeviceBufferHelpers
- Update examples using DeviceBufferHelpers methods, e.g. data verification
* Address review comment.
- Replace manual pattern generation loop with initializeBufferWithPattern call
- Use downloadBuffer to get host copy instead of manual hipMemcpy
* Remove non-existent dependency
* Remove duplicate testcase
* Code cleanup in test files
* Moved common constants to base class
[ROCm/rccl commit: 29e1567b95]
115 Zeilen
3.2 KiB
C++
115 Zeilen
3.2 KiB
C++
/*************************************************************************
|
|
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
|
|
*
|
|
* See LICENSE.txt for license information
|
|
************************************************************************/
|
|
|
|
/**
|
|
* @file MPITestBase.hpp
|
|
* @brief Base class infrastructure for MPI-based RCCL testing
|
|
*
|
|
* Provides a common test base class for writing multi-process distributed tests
|
|
* using MPI and RCCL. Handles communicator creation, process validation, and
|
|
* resource cleanup automatically.
|
|
*
|
|
* @see MPITestBase for the main base class
|
|
* @see MPIEnvironment for global MPI setup
|
|
*/
|
|
|
|
#ifndef MPI_TEST_BASE_HPP
|
|
#define MPI_TEST_BASE_HPP
|
|
|
|
#include "MPITestCore.hpp"
|
|
#include "gtest/gtest.h"
|
|
|
|
#ifdef MPI_TESTS_ENABLED
|
|
#include "MPIEnvironment.hpp"
|
|
#include "TestChecks.hpp"
|
|
#include "rccl/rccl.h"
|
|
#include "utils.h" // For getHostName() from RCCL
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <hip/hip_runtime.h>
|
|
#include <mpi.h>
|
|
#include <string>
|
|
|
|
/**
|
|
* @class MPITestBase
|
|
* @brief Google Test adapter for MPI tests
|
|
*
|
|
* Integrates MPITestCore with Google Test framework for seamless MPI testing.
|
|
* Inherits from both ::testing::Test (for GTest integration) and MPITestCore
|
|
* (for MPI/RCCL functionality).
|
|
*
|
|
* **Features:**
|
|
* - Process count validation (minimum processes, power-of-two requirements)
|
|
* - Node count validation (single-node vs multi-node)
|
|
* - Test-specific RCCL communicator creation and management
|
|
* - HIP stream management for each test
|
|
* - Automatic resource cleanup via GTest TearDown
|
|
*
|
|
* **Usage Example:**
|
|
* @code
|
|
* class MyMPITest : public MPITestBase {};
|
|
*
|
|
* TEST_F(MyMPITest, BasicAllReduce) {
|
|
* if (!validateTestPrerequisites(2)) {
|
|
* GTEST_SKIP() << "Need at least 2 processes";
|
|
* }
|
|
* ASSERT_EQ(ncclSuccess, createTestCommunicator());
|
|
*
|
|
* ncclComm_t comm = getActiveCommunicator();
|
|
* hipStream_t stream = getActiveStream();
|
|
*
|
|
* // Your test logic here...
|
|
* // Cleanup happens automatically in TearDown()
|
|
* }
|
|
* @endcode
|
|
*
|
|
* @note For standalone tests without GTest, use MPIStandaloneTest instead
|
|
* @see MPITestCore for the base framework-agnostic functionality
|
|
* @see MPIEnvironment for global MPI initialization
|
|
*/
|
|
/**
|
|
* @brief Google Test adapter for MPI tests
|
|
*
|
|
* Integrates MPITestCore with Google Test framework by inheriting from both
|
|
* ::testing::Test and MPITestCore.
|
|
*
|
|
* @note For standalone tests (without GTest), use MPIStandaloneTest instead
|
|
*/
|
|
class MPITestBase
|
|
: public ::testing::Test
|
|
, public MPITestCore
|
|
{
|
|
public:
|
|
/**
|
|
* @brief Google Test SetUp hook - initializes test resources
|
|
*
|
|
* Automatically called before each test runs. Calls initializeTest()
|
|
* from MPITestCore for any custom initialization.
|
|
*
|
|
* @note No ambiguity with MPITestCore::initializeTest() - different names
|
|
*/
|
|
void SetUp() override
|
|
{
|
|
initializeTest();
|
|
}
|
|
|
|
/**
|
|
* @brief Google Test TearDown hook - ensures cleanup of test resources
|
|
*
|
|
* Automatically called after each test completes. Calls cleanupTest()
|
|
* from MPITestCore to ensure proper resource cleanup.
|
|
*/
|
|
void TearDown() override
|
|
{
|
|
cleanupTest();
|
|
}
|
|
};
|
|
|
|
#endif // MPI_TESTS_ENABLED
|
|
|
|
#endif // MPI_TEST_BASE_HPP
|