提交 5bcb6380 编写于 作者: D Dong Zhihong

"fix common test"

上级 d8aebaf5
/* 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 <algorithm>
......@@ -106,5 +120,5 @@ class NCCLManager {
comm_table;
};
} // namespace operators
} // namespace platform
} // namespace paddle
......@@ -6,9 +6,12 @@
#include <thread>
#include <vector>
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册