提交 8686f7c6 编写于 作者: Q Qiao Longfei

add reader_queue_speed_test_mode flag for speed test

上级 9c77b65c
......@@ -14,11 +14,14 @@
#pragma once
#include <gflags/gflags.h>
#include <condition_variable> // NOLINT
#include <deque>
#include "paddle/fluid/platform/enforce.h"
DECLARE_bool(reader_queue_speed_test_mode);
namespace paddle {
namespace operators {
namespace reader {
......@@ -72,7 +75,9 @@ class BlockingQueue {
if (!queue_.empty()) {
PADDLE_ENFORCE_NOT_NULL(elem);
*elem = queue_.front();
if (LIKELY(!FLAGS_reader_queue_speed_test_mode)) {
queue_.pop_front();
}
send_cv_.notify_one();
return true;
} else {
......
......@@ -20,6 +20,10 @@
#include "paddle/fluid/operators/reader/blocking_queue.h"
DEFINE_bool(reader_queue_speed_test_mode, false,
"If set true, the queue.pop will only get data from queue but not "
"remove the data from queue for speed testing");
using paddle::operators::reader::BlockingQueue;
TEST(BlockingQueue, CapacityTest) {
......
......@@ -130,6 +130,13 @@ struct EOFException : public std::exception {
#define UNLIKELY(condition) (condition == 0)
#endif
#if !defined(_WIN32)
#define LIKELY(condition) __builtin_expect(static_cast<bool>(condition), 1)
#else
// there is no equivalent intrinsics in msvc.
#define LIKELY(condition) (condition != 0)
#endif
template <typename... Args>
inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
bool stat, const Args&... args) {
......
......@@ -57,6 +57,10 @@ limitations under the License. */
#include "pybind11/stl.h"
DEFINE_bool(reader_queue_speed_test_mode, false,
"If set true, the queue.pop will only get data from queue but not "
"remove the data from queue for speed testing");
// disable auto conversion to list in Python
PYBIND11_MAKE_OPAQUE(paddle::framework::LoDTensorArray);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册