forked from tungstenfabric/tf-third-party
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtbb-2018_U5_patch1.diff
More file actions
121 lines (110 loc) · 4.74 KB
/
Copy pathtbb-2018_U5_patch1.diff
File metadata and controls
121 lines (110 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
diff --git a/third_party/tbb-2018_U5/include/tbb/compat/condition_variable b/third_party/tbb-2018_U5/include/tbb/compat/condition_variable
--- a/third_party/tbb-2018_U5/include/tbb/compat/condition_variable
+++ b/third_party/tbb-2018_U5/include/tbb/compat/condition_variable
@@ -451,6 +451,8 @@ __TBB_DEFINE_PROFILING_SET_NAME(interface5::condition_variable)
} // namespace tbb
+#if defined(TBB_INJECT_INTO_STD_NAMESPACE)
+
#if TBB_IMPLEMENT_CPP0X
namespace std {
@@ -473,4 +475,6 @@ using tbb::interface5::no_timeout;
#endif /* TBB_IMPLEMENT_CPP0X */
+#endif /* TBB_INJECT_INTO_STD_NAMESPACE */
+
#endif /* __TBB_condition_variable_H */
diff --git a/third_party/tbb-2018_U5/src/tbb/mac64-tbb-export.lst b/third_party/tbb-2018_U5/src/tbb/mac64-tbb-export.lst
--- a/third_party/tbb-2018_U5/src/tbb/mac64-tbb-export.lst
+++ b/third_party/tbb-2018_U5/src/tbb/mac64-tbb-export.lst
@@ -122,7 +122,7 @@ __TBB_SYMBOL( _ZTSN3tbb18captured_exceptionE )
__TBB_SYMBOL( _ZTVN3tbb18captured_exceptionE )
__TBB_SYMBOL( _ZTIN3tbb13tbb_exceptionE )
__TBB_SYMBOL( _ZTSN3tbb13tbb_exceptionE )
-__TBB_SYMBOL( _ZTVN3tbb13tbb_exceptionE )
++// __TBB_SYMBOL( _ZTVN3tbb13tbb_exceptionE ) macos linker issue
#endif /* __TBB_TASK_GROUP_CONTEXT */
// Symbols for exceptions thrown from TBB
diff --git a/third_party/tbb-2018_U5/src/tbb/private_server.cpp b/third_party/tbb-2018_U5/src/tbb/private_server.cpp
--- a/third_party/tbb-2018_U5/src/tbb/private_server.cpp
+++ b/third_party/tbb-2018_U5/src/tbb/private_server.cpp
@@ -25,7 +25,7 @@
#include "scheduler_common.h"
#include "governor.h"
#include "tbb_misc.h"
-
+#include <cassert>
using rml::internal::thread_monitor;
namespace tbb {
@@ -76,6 +76,7 @@ private:
//! Link for list of workers that are sleeping or have no associated thread.
private_worker* my_next;
+ private_worker* my_prev;
friend class private_server;
@@ -95,7 +96,7 @@ private:
protected:
private_worker( private_server& server, tbb_client& client, const size_t i ) :
my_server(server), my_client(client), my_index(i),
- my_thread_monitor(), my_handle(), my_next()
+ my_thread_monitor(), my_handle(), my_next(NULL), my_prev(NULL)
{
my_state = st_init;
}
@@ -135,6 +136,7 @@ private:
Can be lowered asynchronously, but must be raised only while holding my_asleep_list_mutex,
because raising it impacts the invariant for sleeping threads. */
atomic<int> my_slack;
+ atomic<int> duplicate_insert_into_sleep_list;
//! Counter used to determine when to delete this.
atomic<int> my_ref_count;
@@ -328,11 +330,14 @@ private_server::private_server( tbb_client& client ) :
#if TBB_USE_ASSERT
my_net_slack_requests = 0;
#endif /* TBB_USE_ASSERT */
+ duplicate_insert_into_sleep_list = 0;
my_asleep_list_root = NULL;
my_thread_array = tbb::cache_aligned_allocator<padded_private_worker>().allocate( my_n_thread );
for( size_t i=0; i<my_n_thread; ++i ) {
private_worker* t = new( &my_thread_array[i] ) padded_private_worker( *this, client, i );
t->my_next = my_asleep_list_root;
+ if (my_asleep_list_root)
+ my_asleep_list_root->my_prev = t;
my_asleep_list_root = t;
}
}
@@ -353,7 +358,14 @@ inline bool private_server::try_insert_in_asleep_list( private_worker& t ) {
// it sees us sleeping on the list and wakes us up.
int k = ++my_slack;
if( k<=0 ) {
+ if (t.my_next || t.my_prev || &t == my_asleep_list_root) {
+ ++duplicate_insert_into_sleep_list;
+ --my_slack;
+ return true;
+ }
t.my_next = my_asleep_list_root;
+ if (my_asleep_list_root)
+ my_asleep_list_root->my_prev = &t;
my_asleep_list_root = &t;
return true;
} else {
@@ -383,6 +395,10 @@ void private_server::wake_some( int additional_slack ) {
}
// Pop sleeping worker to combine with claimed unit of slack
my_asleep_list_root = (*w++ = my_asleep_list_root)->my_next;
+ assert(!(*(w-1))->my_prev);
+ if (my_asleep_list_root)
+ my_asleep_list_root->my_prev = NULL;
+ (*(w-1))->my_next = NULL;
}
if( additional_slack ) {
// Contribute our unused slack to my_slack.
diff --git a/third_party/tbb-2018_U5/src/tbb/semaphore.h b/third_party/tbb-2018_U5/src/tbb/semaphore.h
--- a/third_party/tbb-2018_U5/src/tbb/semaphore.h
+++ b/third_party/tbb-2018_U5/src/tbb/semaphore.h
@@ -210,7 +210,7 @@ public:
}
//! post/release
void V() {
- __TBB_ASSERT( my_sem>=1, "multiple V()'s in a row?" );
+ // __TBB_ASSERT( my_sem>=1, "multiple V()'s in a row?" );
if( my_sem--!=1 ) {
//if old value was 2
my_sem = 0;