Fix for issue 3306. (#3324)

This commit is contained in:
Thejaswi
2018-05-23 07:12:20 +05:30
committed by Rory Mitchell
parent 8f6aadd4b7
commit d367e4fc6b
3 changed files with 6 additions and 11 deletions

View File

@@ -1004,7 +1004,7 @@ class AllReducer {
template <typename T, typename FunctionT>
void ExecuteShards(std::vector<T> *shards, FunctionT f) {
#pragma omp parallel for schedule(static, 1)
#pragma omp parallel for schedule(static, 1) if (shards->size() > 1)
for (int shard = 0; shard < shards->size(); ++shard) {
f(shards->at(shard));
}
@@ -1023,7 +1023,7 @@ void ExecuteShards(std::vector<T> *shards, FunctionT f) {
template <typename T, typename FunctionT>
void ExecuteIndexShards(std::vector<T> *shards, FunctionT f) {
#pragma omp parallel for schedule(static, 1)
#pragma omp parallel for schedule(static, 1) if (shards->size() > 1)
for (int shard = 0; shard < shards->size(); ++shard) {
f(shard, shards->at(shard));
}
@@ -1045,7 +1045,7 @@ void ExecuteIndexShards(std::vector<T> *shards, FunctionT f) {
template <typename ReduceT,typename T, typename FunctionT>
ReduceT ReduceShards(std::vector<T> *shards, FunctionT f) {
std::vector<ReduceT> sums(shards->size());
#pragma omp parallel for schedule(static, 1)
#pragma omp parallel for schedule(static, 1) if (shards->size() > 1)
for (int shard = 0; shard < shards->size(); ++shard) {
sums[shard] = f(shards->at(shard));
}