summaryrefslogtreecommitdiff
path: root/src/stream_manager.cc
diff options
context:
space:
mode:
authorJin Wang <[email protected]>2014-10-23 15:33:59 -0400
committerJin Wang <[email protected]>2016-07-05 09:05:36 -0400
commitf372a4c641b9e6d38470ead6ae25743d26c5fed1 (patch)
tree5a331b1221150c5118e2ef3e058e62340c1a8aeb /src/stream_manager.cc
parent3bb32d87175d873e7089ad50a0069acc195edb34 (diff)
BUG: kernels should return to stream if not pushed to concurrent kernel pool
Diffstat (limited to 'src/stream_manager.cc')
-rw-r--r--src/stream_manager.cc37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/stream_manager.cc b/src/stream_manager.cc
index 687d544..546ab3b 100644
--- a/src/stream_manager.cc
+++ b/src/stream_manager.cc
@@ -95,6 +95,15 @@ stream_operation CUstream_st::next()
return result;
}
+void CUstream_st::cancel_front()
+{
+ pthread_mutex_lock(&m_lock);
+ assert(m_pending);
+ m_pending = false;
+ pthread_mutex_unlock(&m_lock);
+
+}
+
void CUstream_st::print(FILE *fp)
{
pthread_mutex_lock(&m_lock);
@@ -111,10 +120,10 @@ void CUstream_st::print(FILE *fp)
}
-void stream_operation::do_operation( gpgpu_sim *gpu )
+bool stream_operation::do_operation( gpgpu_sim *gpu )
{
if( is_noop() )
- return;
+ return true;
assert(!m_done && m_stream);
if(g_debug_execution >= 3)
@@ -153,16 +162,23 @@ void stream_operation::do_operation( gpgpu_sim *gpu )
case stream_kernel_launch:
if( gpu->can_start_kernel() ) {
gpu->set_cache_config(m_kernel->name());
- printf("kernel %d: \'%s\' transfer to GPU hardware scheduler\n", m_kernel->get_uid(), m_kernel->name().c_str() );
+ if(g_debug_execution >= 3)
+ printf("kernel %d: \'%s\' transfer to GPU hardware scheduler\n", m_kernel->get_uid(), m_kernel->name().c_str() );
m_kernel->print_parent_info();
if( m_sim_mode )
gpu->functional_launch( m_kernel );
else
gpu->launch( m_kernel );
}
+ else {
+ if(g_debug_execution >= 3)
+ printf("kernel %d: \'%s\' not ready to transfer to GPU hardware scheduler\n", m_kernel->get_uid(), m_kernel->name().c_str() );
+ return false;
+ }
break;
case stream_event: {
- printf("event update\n");
+ if(g_debug_execution >= 3)
+ printf("event update\n");
time_t wallclock = time((time_t *)NULL);
m_event->update( gpu_tot_sim_cycle, wallclock );
m_stream->record_next_done();
@@ -173,6 +189,7 @@ void stream_operation::do_operation( gpgpu_sim *gpu )
}
m_done=true;
fflush(stdout);
+ return true;
}
void stream_operation::print( FILE *fp ) const
@@ -204,7 +221,16 @@ bool stream_manager::operation( bool * sim)
bool check=check_finished_kernel();
if(check)m_gpu->print_stats();
stream_operation op =front();
- op.do_operation( m_gpu );
+ if(!op.do_operation( m_gpu )) //not ready to execute
+ {
+ //cancel operation
+ if( op.is_kernel() ) {
+ unsigned grid_uid = op.get_kernel()->get_uid();
+ m_grid_id_to_stream.erase(grid_uid);
+ }
+ op.get_stream()->cancel_front();
+
+ }
pthread_mutex_unlock(&m_lock);
//pthread_mutex_lock(&m_lock);
// simulate a clock cycle on the GPU
@@ -228,6 +254,7 @@ bool stream_manager::register_finished_kernel(unsigned grid_uid)
//Jin: should check children kernels for CDP
if(kernel->is_finished()) {
+ printf("kernel %d finishes, retires from stream %d\n", grid_uid, stream->get_uid());
stream->record_next_done();
m_grid_id_to_stream.erase(grid_uid);
kernel->notify_parent_finished();