From 5bcb63800e602ed2c63c63ee5f82e986f645c960 Mon Sep 17 00:00:00 2001 From: Dong Zhihong Date: Sun, 15 Oct 2017 13:34:52 -0700 Subject: [PATCH] "fix common test" --- paddle/operators/nccl/nccl_gpu_common.h | 16 +++++++++++++++- paddle/operators/nccl/nccl_gpu_common_test.cc | 12 +++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/paddle/operators/nccl/nccl_gpu_common.h b/paddle/operators/nccl/nccl_gpu_common.h index 96b3bb801af..4a375fcc36a 100644 --- a/paddle/operators/nccl/nccl_gpu_common.h +++ b/paddle/operators/nccl/nccl_gpu_common.h @@ -1,3 +1,17 @@ +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ + #pragma once #include @@ -106,5 +120,5 @@ class NCCLManager { comm_table; }; -} // namespace operators +} // namespace platform } // namespace paddle diff --git a/paddle/operators/nccl/nccl_gpu_common_test.cc b/paddle/operators/nccl/nccl_gpu_common_test.cc index 9b46ea31ba1..6f6a4ac886d 100644 --- a/paddle/operators/nccl/nccl_gpu_common_test.cc +++ b/paddle/operators/nccl/nccl_gpu_common_test.cc @@ -6,9 +6,12 @@ #include #include +namespace paddle { +namespace platform { + TEST(WaitGroup, wait) { WaitGroup wg; - auto run_thread = [](int idx) { + auto run_thread = [&wg](int idx) { wg.Add(1); std::this_thread::sleep_for(std::chrono::seconds(1)); wg.Done(); @@ -20,4 +23,11 @@ TEST(WaitGroup, wait) { ths.emplace_back(std::thread(run_thread, i)); } wg.Wait(); + + for (int i = 0; i < TNUM; ++i) { + ths[i].join(); + } } + +} // namespace platform +} // namespace paddle -- GitLab