Added NCCL error checking to tests.
Also cleaned up makefile so that tests and lib are not built unnecessarily. Change-Id: Ia0c596cc2213628de2f066be97615c09bb1bb262 Reviewed-on: http://git-master/r/999627 Reviewed-by: Przemek Tredak <ptredak@nvidia.com> Tested-by: Przemek Tredak <ptredak@nvidia.com>
This commit is contained in:
committed by
Przemek Tredak
parent
fe1a956715
commit
2758353380
@@ -1,5 +1,5 @@
|
||||
/*************************************************************************
|
||||
* Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -41,7 +41,7 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
ncclComm_t* const comms, const std::vector<int>& dList) {
|
||||
// initialize data
|
||||
int nDev = 0;
|
||||
ncclCommCount(comms[0], &nDev);
|
||||
NCCLCHECK(ncclCommCount(comms[0], &nDev));
|
||||
cudaStream_t* s = (cudaStream_t*)malloc(sizeof(cudaStream_t)*nDev);
|
||||
T* buffer = (T*)malloc(nDev * N * sizeof(T));
|
||||
T* result = (T*)malloc(nDev * N * sizeof(T));
|
||||
@@ -61,8 +61,8 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
// warm up GPU
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclAllGather((const void*)sendbuff[i], std::min(32 * 1024, N), type,
|
||||
(void*)recvbuff[i], comms[i], s[i]);
|
||||
NCCLCHECK(ncclAllGather((const void*)sendbuff[i], std::min(32 * 1024, N), type,
|
||||
(void*)recvbuff[i], comms[i], s[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -79,8 +79,8 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclAllGather((const void*)sendbuff[i], n, type, (void*)recvbuff[i], comms[i],
|
||||
s[i]);
|
||||
NCCLCHECK(ncclAllGather((const void*)sendbuff[i], n, type, (void*)recvbuff[i], comms[i],
|
||||
s[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -121,7 +121,7 @@ template<typename T>
|
||||
void RunTests(const int N, const ncclDataType_t type, ncclComm_t* const comms,
|
||||
const std::vector<int>& dList) {
|
||||
int nDev = 0;
|
||||
ncclCommCount(comms[0], &nDev);
|
||||
NCCLCHECK(ncclCommCount(comms[0], &nDev));
|
||||
T** sendbuff = (T**)malloc(nDev * sizeof(T*));
|
||||
T** recvbuff = (T**)malloc(nDev * sizeof(T*));
|
||||
|
||||
@@ -199,15 +199,15 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
ncclComm_t* comms = (ncclComm_t*)malloc(sizeof(ncclComm_t)*nDev);
|
||||
ncclCommInitAll(comms, nDev, dList.data());
|
||||
NCCLCHECK(ncclCommInitAll(comms, nDev, dList.data()));
|
||||
|
||||
printf("# Using devices\n");
|
||||
for (int g=0; g<nDev; ++g) {
|
||||
int cudaDev;
|
||||
int rank;
|
||||
cudaDeviceProp prop;
|
||||
ncclCommCuDevice(comms[g], &cudaDev);
|
||||
ncclCommUserRank(comms[g], &rank);
|
||||
NCCLCHECK(ncclCommCuDevice(comms[g], &cudaDev));
|
||||
NCCLCHECK(ncclCommUserRank(comms[g], &rank));
|
||||
CUDACHECK(cudaGetDeviceProperties(&prop, cudaDev));
|
||||
printf("# Rank %2d uses device %2d [0x%02x] %s\n", rank, cudaDev,
|
||||
prop.pciBusID, prop.name);
|
||||
|
||||
@@ -48,7 +48,7 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
memset(result, 0, N * sizeof(T));
|
||||
|
||||
int nDev = 0;
|
||||
ncclCommCount(comms[0], &nDev);
|
||||
NCCLCHECK(ncclCommCount(comms[0], &nDev));
|
||||
cudaStream_t* s = (cudaStream_t*)malloc(sizeof(cudaStream_t)*nDev);
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -66,7 +66,7 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
// warm up GPU
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclAllReduce((const void*)sendbuff[i], (void*)recvbuff[i], std::min(N, 1024 * 1024), type, op, comms[i], s[i]);
|
||||
NCCLCHECK(ncclAllReduce((const void*)sendbuff[i], (void*)recvbuff[i], std::min(N, 1024 * 1024), type, op, comms[i], s[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -87,8 +87,8 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
//for (int i=0; i<100; i++) {
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclAllReduce((const void*)sendbuff[i], (void*)recvbuff[i], n, type, op,
|
||||
comms[i], s[i]);
|
||||
NCCLCHECK(ncclAllReduce((const void*)sendbuff[i], (void*)recvbuff[i], n, type, op,
|
||||
comms[i], s[i]));
|
||||
}
|
||||
//}
|
||||
|
||||
@@ -130,8 +130,8 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
//for (int i=0; i<100; i++) {
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclAllReduce((const void*)sendbuff[i], (void*)sendbuff[i], n, type, op,
|
||||
comms[i], s[i]);
|
||||
NCCLCHECK(ncclAllReduce((const void*)sendbuff[i], (void*)sendbuff[i], n, type, op,
|
||||
comms[i], s[i]));
|
||||
}
|
||||
//}
|
||||
|
||||
@@ -176,7 +176,7 @@ template<typename T>
|
||||
void RunTests(const int N, const ncclDataType_t type, ncclComm_t* comms,
|
||||
const std::vector<int>& dList) {
|
||||
int nDev = 0;
|
||||
ncclCommCount(comms[0], &nDev);
|
||||
NCCLCHECK(ncclCommCount(comms[0], &nDev));
|
||||
T** sendbuff = (T**)malloc(nDev * sizeof(T*));
|
||||
T** recvbuff = (T**)malloc(nDev * sizeof(T*));
|
||||
|
||||
@@ -256,7 +256,7 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
ncclComm_t* comms = (ncclComm_t*)malloc(sizeof(ncclComm_t)*nDev);
|
||||
ncclCommInitAll(comms, nDev, dList.data());
|
||||
NCCLCHECK(ncclCommInitAll(comms, nDev, dList.data()));
|
||||
|
||||
if (!csv) {
|
||||
printf("# Using devices\n");
|
||||
@@ -264,8 +264,8 @@ int main(int argc, char* argv[]) {
|
||||
int cudaDev;
|
||||
int rank;
|
||||
cudaDeviceProp prop;
|
||||
ncclCommCuDevice(comms[g], &cudaDev);
|
||||
ncclCommUserRank(comms[g], &rank);
|
||||
NCCLCHECK(ncclCommCuDevice(comms[g], &cudaDev));
|
||||
NCCLCHECK(ncclCommUserRank(comms[g], &rank));
|
||||
CUDACHECK(cudaGetDeviceProperties(&prop, cudaDev));
|
||||
printf("# Rank %2d uses device %2d [0x%02x] %s\n", rank, cudaDev,
|
||||
prop.pciBusID, prop.name);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*************************************************************************
|
||||
* Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -41,7 +41,7 @@ void RunTest(T** buff, const int N, const ncclDataType_t type, const int root,
|
||||
ncclComm_t* const comms, const std::vector<int>& dList) {
|
||||
// initialize data
|
||||
int nDev = 0;
|
||||
ncclCommCount(comms[0], &nDev);
|
||||
NCCLCHECK(ncclCommCount(comms[0], &nDev));
|
||||
cudaStream_t* s = (cudaStream_t*)malloc(sizeof(cudaStream_t)*nDev);
|
||||
T* buffer = (T*)malloc(N * sizeof(T));
|
||||
T* result = (T*)malloc(N * sizeof(T));
|
||||
@@ -65,7 +65,7 @@ void RunTest(T** buff, const int N, const ncclDataType_t type, const int root,
|
||||
// warm up GPU
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclBcast((void*)buff[i], std::min(32 * 1024, N), type, root, comms[i], s[i]);
|
||||
NCCLCHECK(ncclBcast((void*)buff[i], std::min(32 * 1024, N), type, root, comms[i], s[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -83,7 +83,7 @@ void RunTest(T** buff, const int N, const ncclDataType_t type, const int root,
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclBcast((void*)buff[i], n, type, root, comms[i], s[i]);
|
||||
NCCLCHECK(ncclBcast((void*)buff[i], n, type, root, comms[i], s[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -123,7 +123,7 @@ template<typename T>
|
||||
void RunTests(const int N, const ncclDataType_t type, ncclComm_t* const comms,
|
||||
const std::vector<int>& dList) {
|
||||
int nDev = 0;
|
||||
ncclCommCount(comms[0], &nDev);
|
||||
NCCLCHECK(ncclCommCount(comms[0], &nDev));
|
||||
T** buff = (T**)malloc(nDev * sizeof(T*));
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -199,15 +199,15 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
ncclComm_t* comms = (ncclComm_t*)malloc(sizeof(ncclComm_t)*nDev);;
|
||||
ncclCommInitAll(comms, nDev, dList.data());
|
||||
NCCLCHECK(ncclCommInitAll(comms, nDev, dList.data()));
|
||||
|
||||
printf("# Using devices\n");
|
||||
for (int g = 0; g < nDev; ++g) {
|
||||
int cudaDev;
|
||||
int rank;
|
||||
cudaDeviceProp prop;
|
||||
ncclCommCuDevice(comms[g], &cudaDev);
|
||||
ncclCommUserRank(comms[g], &rank);
|
||||
NCCLCHECK(ncclCommCuDevice(comms[g], &cudaDev));
|
||||
NCCLCHECK(ncclCommUserRank(comms[g], &rank));
|
||||
CUDACHECK(cudaGetDeviceProperties(&prop, cudaDev));
|
||||
printf("# Rank %2d uses device %2d [0x%02x] %s\n", rank, cudaDev,
|
||||
prop.pciBusID, prop.name);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*************************************************************************
|
||||
* Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -41,7 +41,7 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
const ncclRedOp_t op, ncclComm_t* const comms, const std::vector<int>& dList) {
|
||||
// initialize data
|
||||
int nDev = 0;
|
||||
ncclCommCount(comms[0], &nDev);
|
||||
NCCLCHECK(ncclCommCount(comms[0], &nDev));
|
||||
cudaStream_t* s = (cudaStream_t*)malloc(sizeof(cudaStream_t)*nDev);
|
||||
|
||||
T* buffer = (T*)malloc(N * nDev * sizeof(T));
|
||||
@@ -66,8 +66,8 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
// warm up GPU
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclReduceScatter((const void*)sendbuff[i], (void*)recvbuff[i],
|
||||
std::min(N, 1024 * 1024), type, op, comms[i], s[i]);
|
||||
NCCLCHECK(ncclReduceScatter((const void*)sendbuff[i], (void*)recvbuff[i],
|
||||
std::min(N, 1024 * 1024), type, op, comms[i], s[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -86,8 +86,8 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclReduceScatter((const void*)sendbuff[i], (void*)recvbuff[i], n, type,
|
||||
op, comms[i], s[i]);
|
||||
NCCLCHECK(ncclReduceScatter((const void*)sendbuff[i], (void*)recvbuff[i], n, type,
|
||||
op, comms[i], s[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -122,8 +122,8 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclReduceScatter((const void*)sendbuff[i], (void*)sendbuff[i], n, type,
|
||||
op, comms[i], s[i]);
|
||||
NCCLCHECK(ncclReduceScatter((const void*)sendbuff[i], (void*)sendbuff[i], n, type,
|
||||
op, comms[i], s[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -163,7 +163,7 @@ template<typename T>
|
||||
void RunTests(const int N, const ncclDataType_t type, ncclComm_t* const comms,
|
||||
const std::vector<int>& dList) {
|
||||
int nDev = 0;
|
||||
ncclCommCount(comms[0], &nDev);
|
||||
NCCLCHECK(ncclCommCount(comms[0], &nDev));
|
||||
T** sendbuff = (T**)malloc(nDev * sizeof(T*));
|
||||
T** recvbuff = (T**)malloc(nDev * sizeof(T*));
|
||||
|
||||
@@ -243,15 +243,15 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
ncclComm_t* comms = (ncclComm_t*)malloc(sizeof(ncclComm_t)*nDev);
|
||||
ncclCommInitAll(comms, nDev, dList.data());
|
||||
NCCLCHECK(ncclCommInitAll(comms, nDev, dList.data()));
|
||||
|
||||
printf("# Using devices\n");
|
||||
for (int g = 0; g < nDev; ++g) {
|
||||
int cudaDev;
|
||||
int rank;
|
||||
cudaDeviceProp prop;
|
||||
ncclCommCuDevice(comms[g], &cudaDev);
|
||||
ncclCommUserRank(comms[g], &rank);
|
||||
NCCLCHECK(ncclCommCuDevice(comms[g], &cudaDev));
|
||||
NCCLCHECK(ncclCommUserRank(comms[g], &rank));
|
||||
CUDACHECK(cudaGetDeviceProperties(&prop, cudaDev));
|
||||
printf("# Rank %2d uses device %2d [0x%02x] %s\n", rank, cudaDev,
|
||||
prop.pciBusID, prop.name);
|
||||
|
||||
+11
-11
@@ -50,7 +50,7 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
memset(result, 0, N * sizeof(T));
|
||||
|
||||
int nDev = 0;
|
||||
ncclCommCount(comms[0], &nDev);
|
||||
NCCLCHECK(ncclCommCount(comms[0], &nDev));
|
||||
cudaStream_t* s = (cudaStream_t*)malloc(sizeof(cudaStream_t)*nDev);
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -68,8 +68,8 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
// warm up GPU
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclReduce((const void*)sendbuff[i], (void*)recvbuff[i], std::min(N, 1024 * 1024),
|
||||
type, op, root, comms[i], s[i]);
|
||||
NCCLCHECK(ncclReduce((const void*)sendbuff[i], (void*)recvbuff[i], std::min(N, 1024 * 1024),
|
||||
type, op, root, comms[i], s[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
@@ -90,8 +90,8 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
//for (int i=0; i<100; i++) {
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclReduce((const void*)sendbuff[i], (void*)recvbuff[i], n, type, op,
|
||||
root, comms[i], s[i]);
|
||||
NCCLCHECK(ncclReduce((const void*)sendbuff[i], (void*)recvbuff[i], n, type, op,
|
||||
root, comms[i], s[i]));
|
||||
}
|
||||
//}
|
||||
|
||||
@@ -129,8 +129,8 @@ void RunTest(T** sendbuff, T** recvbuff, const int N, const ncclDataType_t type,
|
||||
//for (int i=0; i<100; i++) {
|
||||
for (int i = 0; i < nDev; ++i) {
|
||||
CUDACHECK(cudaSetDevice(dList[i]));
|
||||
ncclReduce((const void*)sendbuff[i], (void*)sendbuff[i], n, type, op,
|
||||
root, comms[i], s[i]);
|
||||
NCCLCHECK(ncclReduce((const void*)sendbuff[i], (void*)sendbuff[i], n, type, op,
|
||||
root, comms[i], s[i]));
|
||||
}
|
||||
//}
|
||||
|
||||
@@ -171,7 +171,7 @@ template<typename T>
|
||||
void RunTests(const int N, const ncclDataType_t type, ncclComm_t* const comms,
|
||||
const std::vector<int>& dList) {
|
||||
int nDev = 0;
|
||||
ncclCommCount(comms[0], &nDev);
|
||||
NCCLCHECK(ncclCommCount(comms[0], &nDev));
|
||||
T** sendbuff = (T**)malloc(nDev * sizeof(T*));
|
||||
T** recvbuff = (T**)malloc(nDev * sizeof(T*));
|
||||
|
||||
@@ -253,7 +253,7 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
ncclComm_t* comms = (ncclComm_t*)malloc(sizeof(ncclComm_t)*nDev);
|
||||
ncclCommInitAll(comms, nDev, dList.data());
|
||||
NCCLCHECK(ncclCommInitAll(comms, nDev, dList.data()));
|
||||
|
||||
if (!csv) {
|
||||
printf("# Using devices\n");
|
||||
@@ -261,8 +261,8 @@ int main(int argc, char* argv[]) {
|
||||
int cudaDev;
|
||||
int rank;
|
||||
cudaDeviceProp prop;
|
||||
ncclCommCuDevice(comms[g], &cudaDev);
|
||||
ncclCommUserRank(comms[g], &rank);
|
||||
NCCLCHECK(ncclCommCuDevice(comms[g], &cudaDev));
|
||||
NCCLCHECK(ncclCommUserRank(comms[g], &rank));
|
||||
CUDACHECK(cudaGetDeviceProperties(&prop, cudaDev));
|
||||
printf("# Rank %2d uses device %2d [0x%02x] %s\n", rank, cudaDev,
|
||||
prop.pciBusID, prop.name);
|
||||
|
||||
Reference in New Issue
Block a user