File tree Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 14
14
15
15
#pragma once
16
16
17
+ #include < gflags/gflags.h>
17
18
#include < condition_variable> // NOLINT
18
19
#include < deque>
19
20
20
21
#include " paddle/fluid/platform/enforce.h"
21
22
23
+ DECLARE_bool (reader_queue_speed_test_mode);
24
+
22
25
namespace paddle {
23
26
namespace operators {
24
27
namespace reader {
@@ -72,7 +75,9 @@ class BlockingQueue {
72
75
if (!queue_.empty ()) {
73
76
PADDLE_ENFORCE_NOT_NULL (elem);
74
77
*elem = queue_.front ();
75
- queue_.pop_front ();
78
+ if (LIKELY (!FLAGS_reader_queue_speed_test_mode)) {
79
+ queue_.pop_front ();
80
+ }
76
81
send_cv_.notify_one ();
77
82
return true ;
78
83
} else {
Original file line number Diff line number Diff line change 20
20
21
21
#include " paddle/fluid/operators/reader/blocking_queue.h"
22
22
23
+ DEFINE_bool (reader_queue_speed_test_mode, false ,
24
+ " If set true, the queue.pop will only get data from queue but not "
25
+ " remove the data from queue for speed testing" );
26
+
23
27
using paddle::operators::reader::BlockingQueue;
24
28
25
29
TEST (BlockingQueue, CapacityTest) {
Original file line number Diff line number Diff line change @@ -130,6 +130,13 @@ struct EOFException : public std::exception {
130
130
#define UNLIKELY (condition ) (condition == 0 )
131
131
#endif
132
132
133
+ #if !defined(_WIN32)
134
+ #define LIKELY (condition ) __builtin_expect(static_cast <bool >(condition), 1 )
135
+ #else
136
+ // there is no equivalent intrinsics in msvc.
137
+ #define LIKELY (condition ) (condition != 0 )
138
+ #endif
139
+
133
140
template <typename ... Args>
134
141
inline typename std::enable_if<sizeof ...(Args) != 0 , void >::type throw_on_error (
135
142
bool stat, const Args&... args) {
Original file line number Diff line number Diff line change @@ -57,6 +57,10 @@ limitations under the License. */
57
57
58
58
#include " pybind11/stl.h"
59
59
60
+ DEFINE_bool (reader_queue_speed_test_mode, false ,
61
+ " If set true, the queue.pop will only get data from queue but not "
62
+ " remove the data from queue for speed testing" );
63
+
60
64
// disable auto conversion to list in Python
61
65
PYBIND11_MAKE_OPAQUE (paddle::framework::LoDTensorArray);
62
66
You can’t perform that action at this time.
0 commit comments