[Fix] Fix potential deadlock caused by the last EXIT instruction.
#503
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Potentional deadlock may occur in
trace_shader_core_ctx::get_next_inst. Once the last instruction isEXIT, and no more instructions in traces,m_trace_warp->trace_done()will be evaluated to betrue. Since the number of instruction in pipeline will be increased atshader_core_ctx::decode()in gpgpu-sim, the!m_warp[warp_id]->inst_in_pipeline()will also be evaluated to be true. And finally, all threads will be set to completed, and cause a deadlock for issue stage.Increasing
inst_in_pipelinewith indecode()function of gpgpu-sim:https://github.com/accel-sim/gpgpu-sim_distribution/blob/b18ee3977962921c49fabe06d26ae19694497c26/src/gpgpu-sim/shader.cc#L896
Functional done will check if all threads have done:
https://github.com/accel-sim/gpgpu-sim_distribution/blob/b18ee3977962921c49fabe06d26ae19694497c26/src/gpgpu-sim/shader.cc#L4085C1-L4087C2
Issue stage will check if the warp is waiting, and one of the condition is whether it is
functional_done:https://github.com/accel-sim/gpgpu-sim_distribution/blob/b18ee3977962921c49fabe06d26ae19694497c26/src/gpgpu-sim/shader.cc#L4093C1-L4114C2
This PR provide a walk around for this situation. Before we check
trace_done(), we should firstly check ifget_next_trace_instreturns a valid instruction.