Files
rocm-systems/test/common/TestChecks.cpp
T
Atul Kulkarni 29e1567b95 Enable MPI support to execute MPI specific unit/functional tests (#1996)
* 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
2025-12-06 16:05:37 -06:00

53 строки
1.5 KiB
C++

/*************************************************************************
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
*
* See LICENSE.txt for license information
************************************************************************/
/**
* @file TestChecks.cpp
* @brief Implementation file for TestChecks.hpp
*
* Provides definitions for variables used by test logging macros.
*/
#include "TestChecks.hpp"
#ifdef MPI_TESTS_ENABLED
#include <cstdlib>
#include <cstring>
// Define and initialize rcclTestDebugLevel for TEST_* macros
// This matches RCCL's debug level parsing logic from src/debug.cc
// Values correspond to ncclDebugLogLevel enum in nccl_common.h:
// - -1 = Uninitialized (treated as ERROR level)
// - 0 = NCCL_LOG_NONE
// - 1 = NCCL_LOG_VERSION
// - 2 = NCCL_LOG_WARN
// - 3 = NCCL_LOG_INFO
// - 4 = NCCL_LOG_ABORT
// - 5 = NCCL_LOG_TRACE
int rcclTestDebugLevel = []() -> int {
const char* env = std::getenv("NCCL_DEBUG");
// Default to ERROR level if not set (matches RCCL behavior)
if (!env) return -1;
// Match RCCL's case-insensitive string comparison
if (strcasecmp(env, "NONE") == 0) return 0;
if (strcasecmp(env, "VERSION") == 0) return 1;
if (strcasecmp(env, "WARN") == 0) return 2;
if (strcasecmp(env, "INFO") == 0) return 3;
if (strcasecmp(env, "ABORT") == 0) return 4;
if (strcasecmp(env, "TRACE") == 0) return 5;
// Unknown value, default to ERROR level
return -1;
}();
#endif // MPI_TESTS_ENABLED