Skip to content

Commit eea8635

Browse files
updates
1 parent 6501870 commit eea8635

File tree

2 files changed

+29
-40
lines changed

2 files changed

+29
-40
lines changed

src/.schedule.cpp.swp

16 KB
Binary file not shown.

src/poolschedule.cpp

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -71,63 +71,47 @@ pool_schedule::handleSchedule( raft::kernel * const kernel )
7171
void
7272
pool_schedule::start()
7373
{
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 );
7974
/**
8075
* NOTE: this section is the same as the code in the "handleSchedule"
8176
* function so that it doesn't call the lock for the thread map.
8277
*/
8378
auto &container( kernel_set.acquire() );
84-
//const auto expected_dst_size( dst_kernels.size() );
85-
//qt_sinc_expect( sinc /** sinc struct **/, expected_dst_size );
8679
for( auto * const k : container )
8780
{
8881
auto *td( new thread_data( k ) );
8982
thread_data_pool.emplace_back( td );
9083
if( ! k->output.hasPorts() /** has no outputs, only 0 > inputs **/ )
9184
{
92-
tail.emplace_back( td );
9385
/** 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 );
11687
}
88+
qthread_spawn( pool_schedule::pool_run,
89+
(void*) td,
90+
0,
91+
0,
92+
0,
93+
nullptr,
94+
NO_SHEPHERD,
95+
0 );
11796
}
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+
*/
118106
kernel_set.release();
119-
/** wait on sync **/
120-
//assert( sinc_count == expected_dst_size );
121107
bool keep_going( true );
122108
while( keep_going )
123109
{
124110
std::chrono::milliseconds dura( 3 );
125111
std::this_thread::sleep_for( dura );
126-
127112
std::lock_guard< std::mutex > lock( tail_mutex );
128113
keep_going = false;
129-
130-
for( auto *td : tail )
114+
for( auto * const td : tail )
131115
{
132116
if( ! td->finished )
133117
{
@@ -136,8 +120,6 @@ pool_schedule::start()
136120
}
137121
}
138122
}
139-
//qt_sinc_wait( sinc /** sinc struct **/,
140-
// nullptr /** ignore bytes copied, we don't care **/ );
141123
return;
142124
}
143125

@@ -167,12 +149,19 @@ aligned_t pool_schedule::pool_run( void *data )
167149
}
168150
#endif
169151
volatile bool done( false );
152+
std::uint8_t run_count( 0 );
170153
while( ! done )
171154
{
172155
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+
}
176165
}
177166
thread_d->finished = true;
178167
return( 1 );

0 commit comments

Comments
 (0)