This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Eliminate barrier if workgroup size is not greater than wavefront size
ClosedPublic

Authored by rampitec on Apr 5 2017, 4:08 PM.

Details

Summary

If a workgroup size is known to be not greater than wavefront size
the s_barrier instruction is not needed since all threads are guarantied
to come to the same point at the same time.

Note, that fence translated into s_waitcnt still remain, since it is a
separate IR instruction.

See also D31728.

Diff Detail

Repository
rL LLVM

Event Timeline

rampitec created this revision.Apr 5 2017, 4:08 PM
rampitec edited the summary of this revision. (Show Details)Apr 5 2017, 4:10 PM
arsenm edited edge metadata.Apr 5 2017, 4:13 PM

Should this replace it with a wave barrier instead of just deleting it?

Should this replace it with a wave barrier instead of just deleting it?

I do not see what can happen to convergence after lowering, but probably it is better to replace it with wave_barrier anyway. Will do.

t-tye added a comment.Apr 5 2017, 4:24 PM

Should this replace it with a wave barrier instead of just deleting it?

I do not see what can happen to convergence after lowering, but probably it is better to replace it with wave_barrier anyway. Will do.

I think the issue is that need to ensure there is no reordering of code before and after the barrier since other lanes may be reading those values. Also need to ensure that the basic block is not cloned as again that would change the cross lane semantics. Without the wave_barrier the compiler could make changes based on only considering the single lane execution semantics.

rampitec planned changes to this revision.Apr 5 2017, 4:26 PM

Will replace it with wave_barrier.

rampitec updated this revision to Diff 94306.Apr 5 2017, 5:00 PM

Replace barrier with no-op wave_barrier.

arsenm accepted this revision.Apr 5 2017, 5:10 PM

LGTM

This revision is now accepted and ready to land.Apr 5 2017, 5:10 PM
This revision was automatically updated to reflect the committed changes.