Files
rocm-systems/test/test_AllReduce.cpp
T

81 regels
3.3 KiB
C++

2019-05-16 16:16:18 +00:00
/*************************************************************************
2020-01-15 17:54:27 -07:00
* Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved.
2019-05-16 16:16:18 +00:00
*
* See LICENSE.txt for license information
************************************************************************/
#include "test_AllReduce.hpp"
namespace CorrectnessTests
{
2021-05-06 09:50:07 -06:00
TEST_P(AllReduceCorrectnessTest, Correctness)
{
if (numDevices > numDevicesAvailable) return;
// Prepare input / output / expected results
Dataset dataset;
dataset.Initialize(numDevices, numElements, dataType, inPlace, ncclCollAllReduce);
2021-05-06 09:50:07 -06:00
FillDatasetWithPattern(dataset);
ComputeExpectedResults(dataset, op);
// Launch the reduction (1 thread per GPU)
ncclGroupStart();
for (int i = 0; i < numDevices; i++)
2019-05-16 16:16:18 +00:00
{
2021-05-06 09:50:07 -06:00
ncclAllReduce(dataset.inputs[i], dataset.outputs[i],
numElements, dataType, op, comms[i], streams[i]);
2019-05-16 16:16:18 +00:00
}
2021-05-06 09:50:07 -06:00
ncclGroupEnd();
// Wait for reduction to complete
Synchronize();
// Check results
ValidateResults(dataset);
dataset.Release();
}
2021-10-26 16:36:46 -07:00
#if defined(BUILD_ALLREDUCE_ONLY)
INSTANTIATE_TEST_SUITE_P(AllReduceCorrectnessSweep,
AllReduceCorrectnessTest,
testing::Combine(
// Reduction operator
testing::Values(ncclSum),
// Data types
testing::Values(ncclFloat32),
// Number of elements
testing::Values(1024, 1048576),
// Number of devices
testing::Values(2,3,4,5,6,7,8),
// In-place or not
testing::Values(false, true),
testing::Values("RCCL_ENABLE_CLIQUE=0", "RCCL_ENABLE_CLIQUE=1")),
CorrectnessTest::PrintToStringParamName());
#else
2021-05-06 09:50:07 -06:00
INSTANTIATE_TEST_SUITE_P(AllReduceCorrectnessSweep,
AllReduceCorrectnessTest,
testing::Combine(
// Reduction operator
2021-08-25 12:01:49 -07:00
testing::Values(ncclSum, ncclProd, ncclMax, ncclMin, ncclAvg),
2021-05-06 09:50:07 -06:00
// Data types
testing::Values(ncclInt8,
ncclUint8,
ncclInt32,
ncclUint32,
ncclInt64,
ncclUint64,
//ncclFloat16,
ncclFloat32,
ncclFloat64,
ncclBfloat16),
// Number of elements
testing::Values(1024, 1048576),
// Number of devices
testing::Values(2,3,4,5,6,7,8),
// In-place or not
testing::Values(false, true),
testing::Values("RCCL_ENABLE_CLIQUE=0", "RCCL_ENABLE_CLIQUE=1")),
CorrectnessTest::PrintToStringParamName());
2021-10-26 16:36:46 -07:00
#endif
2019-05-16 16:16:18 +00:00
} // namespace