@@ -71,63 +71,47 @@ pool_schedule::handleSchedule( raft::kernel * const kernel )
71
71
void
72
72
pool_schedule::start ()
73
73
{
74
- // qt_sinc_t *sinc( qt_sinc_create(0, nullptr, nullptr, 0) );
75
- // TODO, this needs to be fixed to ensure we can increment expect
76
- // atomically from other threads, probably need to modify qthreads
77
- // interface a bit
78
- // std::size_t sinc_count( 0 );
79
74
/* *
80
75
* NOTE: this section is the same as the code in the "handleSchedule"
81
76
* function so that it doesn't call the lock for the thread map.
82
77
*/
83
78
auto &container ( kernel_set.acquire () );
84
- // const auto expected_dst_size( dst_kernels.size() );
85
- // qt_sinc_expect( sinc /** sinc struct **/, expected_dst_size );
86
79
for ( auto * const k : container )
87
80
{
88
81
auto *td ( new thread_data ( k ) );
89
82
thread_data_pool.emplace_back ( td );
90
83
if ( ! k->output .hasPorts () /* * has no outputs, only 0 > inputs **/ )
91
84
{
92
- tail.emplace_back ( td );
93
85
/* * destination kernel **/
94
- qthread_spawn ( pool_schedule::pool_run,
95
- (void *) td,
96
- 0 ,
97
- 0 ,
98
- 0 ,
99
- nullptr ,
100
- 1 ,
101
- 0 );
102
- /* * inc number to expect for sync **/
103
- // sinc_count++;
104
- }
105
- else
106
- {
107
- /* * else non-destination kerenl **/
108
- qthread_spawn ( pool_schedule::pool_run,
109
- (void *) td,
110
- 0 ,
111
- 0 ,
112
- 0 ,
113
- nullptr ,
114
- 1 ,
115
- 0 );
86
+ tail.emplace_back ( td );
116
87
}
88
+ qthread_spawn ( pool_schedule::pool_run,
89
+ (void *) td,
90
+ 0 ,
91
+ 0 ,
92
+ 0 ,
93
+ nullptr ,
94
+ NO_SHEPHERD,
95
+ 0 );
117
96
}
97
+ /* *
98
+ * NOTE: can't quite get the sync object behavior to work
99
+ * quite well enough for this application. Should theoretically
100
+ * work according to the documentation here:
101
+ * http://www.cs.sandia.gov/qthreads/man/qthread_spawn.html
102
+ * however it seems that the wait segfaults. Adding on the
103
+ * TODO list I'll implement a better mwait monitor vs. spinning
104
+ * which is relatively bad.
105
+ */
118
106
kernel_set.release ();
119
- /* * wait on sync **/
120
- // assert( sinc_count == expected_dst_size );
121
107
bool keep_going ( true );
122
108
while ( keep_going )
123
109
{
124
110
std::chrono::milliseconds dura ( 3 );
125
111
std::this_thread::sleep_for ( dura );
126
-
127
112
std::lock_guard< std::mutex > lock ( tail_mutex );
128
113
keep_going = false ;
129
-
130
- for ( auto *td : tail )
114
+ for ( auto * const td : tail )
131
115
{
132
116
if ( ! td->finished )
133
117
{
@@ -136,8 +120,6 @@ pool_schedule::start()
136
120
}
137
121
}
138
122
}
139
- // qt_sinc_wait( sinc /** sinc struct **/,
140
- // nullptr /** ignore bytes copied, we don't care **/ );
141
123
return ;
142
124
}
143
125
@@ -167,12 +149,19 @@ aligned_t pool_schedule::pool_run( void *data )
167
149
}
168
150
#endif
169
151
volatile bool done ( false );
152
+ std::uint8_t run_count ( 0 );
170
153
while ( ! done )
171
154
{
172
155
Schedule::kernelRun ( thread_d->k , done );
173
- // takes care of peekset clearing too
174
- Schedule::fifo_gc ( &in, &out, &peekset );
175
- qthread_yield ();
156
+ // FIXME: add back in SystemClock user space timer
157
+ // set up one cache line per thread
158
+ if ( run_count++ == 20 || done )
159
+ {
160
+ run_count = 0 ;
161
+ // takes care of peekset clearing too
162
+ Schedule::fifo_gc ( &in, &out, &peekset );
163
+ qthread_yield ();
164
+ }
176
165
}
177
166
thread_d->finished = true ;
178
167
return ( 1 );
0 commit comments