From d79fab8098036dcad4628c21d61258195721e2a2 Mon Sep 17 00:00:00 2001 From: Tayler Hetherington Date: Mon, 17 Jun 2013 15:05:14 -0800 Subject: Review: 46001. Fixing a source of non-determinism in GPGPU-Sim (Bug 174). Not sure if this is the only issue, but this was definitely a source of non-determinism (checked with many of the -FT benchmarks). In gpgpu_sim_thread_concurrent() (gpgpusim_entrypoint.cc), the inner do{...}while(active); only breaks when the gpu is not active. As a result, the gpu is only initialized when the gpu becomes momentarily inactive. If one kernel completes while another kernel is currently pending in the stream's queue, the next kernel will start running immediately causing the GPU to not be reinitialized (which includes resetting per-kernel stats). The fix simply recognizes that a kernel has completed and breaks from the loop prior to starting the next operation. [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 16463] --- src/gpgpusim_entrypoint.cc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/gpgpusim_entrypoint.cc') diff --git a/src/gpgpusim_entrypoint.cc b/src/gpgpusim_entrypoint.cc index 9999bb1..20fb88e 100644 --- a/src/gpgpusim_entrypoint.cc +++ b/src/gpgpusim_entrypoint.cc @@ -115,14 +115,23 @@ void *gpgpu_sim_thread_concurrent(void*) g_the_gpu->init(); do { // check if a kernel has completed - // launch operation on device if one is pending and can be run - g_stream_manager->operation(&sim_cycles); - if( g_the_gpu->active() ) { - g_the_gpu->cycle(); - sim_cycles = true; - g_the_gpu->deadlock_check(); - } - active=g_the_gpu->active() || !g_stream_manager->empty_protected(); + // launch operation on device if one is pending and can be run + + // Need to break this loop when a kernel completes. This was a + // source of non-deterministic behaviour in GPGPU-Sim (bug 147). + // If another stream operation is available, g_the_gpu remains active, + // causing this loop to not break. If the next operation happens to be + // another kernel, the gpu is not re-initialized and the inter-kernel + // behaviour may be incorrect. + if(g_stream_manager->operation(&sim_cycles)) + break; + + if( g_the_gpu->active() ) { + g_the_gpu->cycle(); + sim_cycles = true; + g_the_gpu->deadlock_check(); + } + active=g_the_gpu->active() || !g_stream_manager->empty_protected(); } while( active ); if(g_debug_execution >= 3) { printf("GPGPU-Sim: ** STOP simulation thread (no work) **\n"); -- cgit v1.3