diff --git a/src/gpu-compute/wavefront.hh b/src/gpu-compute/wavefront.hh --- a/src/gpu-compute/wavefront.hh +++ b/src/gpu-compute/wavefront.hh @@ -52,6 +52,27 @@ static const int MAX_NUM_INSTS_PER_WF = 12; +/** + * A reconvergence stack entry conveys the necessary state to implement + * control flow divergence. + */ +struct ReconvergenceStackEntry { + /** + * PC of current instruction. + */ + uint32_t pc; + /** + * PC of the immediate post-dominator instruction, i.e., the value of + * @a pc for the first instruction that will be executed by the wavefront + * when a reconvergence point is reached. + */ + uint32_t rpc; + /** + * Execution mask. + */ + VectorMask execMask; +}; + /* * Arguments for the hsail opcode call, are user defined and variable length. * The hardware/finalizer can support arguments in hardware or use memory to @@ -368,7 +389,7 @@ * point (branch instruction), and shrinks every time the wavefront * reaches a reconvergence point (immediate post-dominator instruction). */ - std::stack> reconvergenceStack; + std::list> reconvergenceStack; }; #endif // __WAVEFRONT_HH__ # Node ID 4ec14dd08cc365a87d8c4633b944e6ba2b0a45e3 # Parent b64d8e2229aed09863e5807cdda1d058a6f6bd42 diff --git a/src/gpu-compute/wavefront.cc b/src/gpu-compute/wavefront.cc --- a/src/gpu-compute/wavefront.cc +++ b/src/gpu-compute/wavefront.cc @@ -873,7 +873,7 @@ const VectorMask& mask) { assert(mask.count()); - reconvergenceStack.emplace(new ReconvergenceStackEntry(pc, rpc, mask)); + reconvergenceStack.emplace_back(new ReconvergenceStackEntry{pc, rpc, mask}); } void @@ -886,7 +886,7 @@ execMask().to_string().c_str(), pc()); - reconvergenceStack.pop(); + reconvergenceStack.pop_back(); DPRINTF(WavefrontStack, "%3i %s\n", pc(), execMask().to_stringpc; + return reconvergenceStack.back()->pc; } uint32_t Wavefront::rpc() const { - return reconvergenceStack.top()->rpc; + return reconvergenceStack.back()->rpc; } VectorMask Wavefront::execMask() const { - return reconvergenceStack.top()->execMask; + return reconvergenceStack.back()->execMask; } bool Wavefront::execMask(int lane) const { - return reconvergenceStack.top()->execMask[lane]; + return reconvergenceStack.back()->execMask[lane]; } void Wavefront::pc(uint32_t new_pc) { - reconvergenceStack.top()->pc = new_pc; + reconvergenceStack.back()->pc = new_pc; } uint32_t