Skip to content

Commit 12a58ae

Browse files
mantaionutfacebook-github-bot
authored andcommitted
Fix compiling with C++17 (#343)
Summary: std::random_shuffle is deprecated in C++14 and removed in C++17. This commit replaces it by std::shuffle. Pull Request resolved: #343 Reviewed By: mehtanirav Differential Revision: D40433945 Pulled By: malfet fbshipit-source-id: 1608fa31d6cf8002e538d9a1504ab7443b0637de
1 parent a01540e commit 12a58ae

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gloo/cuda_collectives_native.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#pragma once
1010

1111
#include <algorithm>
12+
#include <random>
1213
#include <cmath>
1314

1415
#include "gloo/common/common.h"
@@ -51,8 +52,10 @@ class CudaLocalNativeReduce : public LocalOp<T> {
5152

5253
// Shuffle order in an attempt to evenly spread work across devices when
5354
// dealing with multiple instances of this operation.
54-
std::random_shuffle(indices_.begin(), indices_.end());
55-
55+
std::random_device rd;
56+
std::mt19937 mt(rd());
57+
std::shuffle(indices_.begin(), indices_.end(), mt);
58+
5659
// Initialize
5760
CudaDeviceGuard guard;
5861
for (auto i = 0; i < steps_; i++) {

0 commit comments

Comments
 (0)