Files
rocm-systems/projects/rccl-tests/src/reduce_scatter.cu
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

116 lines
4.3 KiB
Plaintext
Raw Normal View History

2017-08-08 16:18:34 -07:00
/*************************************************************************
2022-09-20 02:21:36 -07:00
* Copyright (c) 2016-2022, NVIDIA CORPORATION. All rights reserved.
* Modifications Copyright (c) 2019-2022 Advanced Micro Devices, Inc. All rights reserved.
2017-08-08 16:18:34 -07:00
*
* See LICENSE.txt for license information
2017-08-08 16:18:34 -07:00
************************************************************************/
2024-03-05 09:47:18 -07:00
#include "cuda_runtime.h"
2017-08-08 16:18:34 -07:00
#include "common.h"
#include "rccl_compat.h"
2017-08-08 16:18:34 -07:00
void ReduceScatterGetCollByteCount(size_t *sendcount, size_t *recvcount, size_t *paramcount, size_t *sendInplaceOffset, size_t *recvInplaceOffset, size_t count, size_t eltSize, int nranks) {
size_t base = (count/nranks) & -(16/eltSize);
2022-09-20 02:21:36 -07:00
*sendcount = base*nranks;
*recvcount = base;
*sendInplaceOffset = 0;
2022-09-20 02:21:36 -07:00
*recvInplaceOffset = base;
*paramcount = base;
2017-08-08 16:18:34 -07:00
}
testResult_t ReduceScatterInitData(struct threadArgs* args, ncclDataType_t type, ncclRedOp_t op, int root, int rep, int in_place) {
2017-08-08 16:18:34 -07:00
size_t sendcount = args->sendBytes / wordSize(type);
size_t recvcount = args->expectedBytes / wordSize(type);
int nranks = args->nProcs*args->nThreads*args->nGpus;
2017-08-08 16:18:34 -07:00
for (int i=0; i<args->nGpus; i++) {
2024-03-05 09:47:18 -07:00
CUDACHECK(cudaSetDevice(args->gpus[i]));
int rank = ((args->proc*args->nThreads + args->thread)*args->nGpus + i);
2024-03-05 09:47:18 -07:00
CUDACHECK(cudaMemset(args->recvbuffs[i], 0, args->expectedBytes));
2017-08-08 16:18:34 -07:00
void* data = in_place ? args->recvbuffs[i] : args->sendbuffs[i];
2022-08-19 15:15:10 -05:00
TESTCHECK(InitData(data, sendcount, 0, type, op, rep, nranks, rank));
2024-03-05 09:47:18 -07:00
CUDACHECK(cudaMemcpy(args->expected[i], args->recvbuffs[i], args->expectedBytes, cudaMemcpyDefault));
TESTCHECK(InitDataReduce(args->expected[i], recvcount, rank*recvcount, type, op, rep, nranks));
2024-03-05 09:47:18 -07:00
CUDACHECK(cudaDeviceSynchronize());
2017-08-08 16:18:34 -07:00
}
return testSuccess;
2017-08-08 16:18:34 -07:00
}
testResult_t ReduceScatterGetAlgoProtoChannels(ncclComm_t comm, size_t count, ncclDataType_t type, int* algo, int* proto, int* nchannels) {
if(rcclTestsGetAlgoInfo == NULL) return testInternalError;
NCCLCHECK(rcclTestsGetAlgoInfo(comm, ncclFuncReduceScatter , count, type , 0, 0, 1, algo, proto, nchannels));
return testSuccess;
}
void ReduceScatterGetBw(size_t count, int typesize, double sec, double* algBw, double* busBw, int nranks) {
double baseBw = (double)(count * typesize * nranks) / 1.0E9 / sec;
2017-08-08 16:18:34 -07:00
*algBw = baseBw;
double factor = ((double)(nranks - 1))/((double)nranks);
2017-08-08 16:18:34 -07:00
*busBw = baseBw * factor;
}
testResult_t ReduceScatterRunColl(void* sendbuff, void* recvbuff, size_t count, ncclDataType_t type, ncclRedOp_t op, int root, ncclComm_t comm, cudaStream_t stream, void* bias = nullptr) {
2017-08-08 16:18:34 -07:00
NCCLCHECK(ncclReduceScatter(sendbuff, recvbuff, count, type, op, comm, stream));
return testSuccess;
}
struct testColl reduceScatterTest = {
"ReduceScatter",
ReduceScatterGetCollByteCount,
ReduceScatterInitData,
ReduceScatterGetBw,
ReduceScatterRunColl,
ReduceScatterGetAlgoProtoChannels
};
void ReduceScatterGetBuffSize(size_t *sendcount, size_t *recvcount, size_t count, int nranks) {
size_t paramcount, sendInplaceOffset, recvInplaceOffset;
ReduceScatterGetCollByteCount(sendcount, recvcount, &paramcount, &sendInplaceOffset, &recvInplaceOffset, count, /*eltSize=*/1, nranks);
2017-08-08 16:18:34 -07:00
}
testResult_t ReduceScatterRunTest(struct threadArgs* args, int root, ncclDataType_t type, const char* typeName, ncclRedOp_t op, const char* opName) {
args->collTest = &reduceScatterTest;
2017-08-08 16:18:34 -07:00
ncclDataType_t *run_types;
ncclRedOp_t *run_ops;
const char **run_typenames, **run_opnames;
int type_count, op_count;
if ((int)type != -1) {
2017-08-08 16:18:34 -07:00
type_count = 1;
run_types = &type;
run_typenames = &typeName;
} else {
2021-06-17 14:08:43 -07:00
type_count = test_typenum;
2017-08-08 16:18:34 -07:00
run_types = test_types;
run_typenames = test_typenames;
}
if ((int)op != -1) {
2017-08-08 16:18:34 -07:00
run_ops = &op;
run_opnames = &opName;
op_count = 1;
} else {
2021-06-17 14:08:43 -07:00
op_count = test_opnum;
2017-08-08 16:18:34 -07:00
run_ops = test_ops;
run_opnames = test_opnames;
}
for (int i=0; i<type_count; i++) {
for (int j=0; j<op_count; j++) {
#if defined(RCCL_FLOAT8)
if((run_types[i] == ncclFloat8e4m3 || run_types[i] == ncclFloat8e5m2) && (run_ops[j] == ncclProd || run_ops[j] == ncclAvg || strcmp(run_opnames[j],"mulsum") == 0))
continue;
#endif
TESTCHECK(TimeTest(args, run_types[i], run_typenames[i], run_ops[j], run_opnames[j], -1));
}
}
return testSuccess;
2017-08-08 16:18:34 -07:00
}
2019-04-18 10:34:55 -07:00
struct testEngine ncclTestEngine = {
ReduceScatterGetBuffSize,
ReduceScatterRunTest
};