[Mlir-commits] [mlir] [mlir][gpu] Eliminate redundant gpu.barrier ops (PR #71575)

Guray Ozen llvmlistbot at llvm.org
Tue Nov 7 12:04:23 PST 2023


grypp wrote:

The PR is a good start, but it doesn’t really optimize anything. It only removes barriers one after another. The program runs on a same speed even if we don't remove them, because the threads are already synchronized on the first barrier. 

I think this PR needs to be largely extended. A proper barrier elimination can remove more redundant barriers. 

**Example 1:**
Here the first barrier can be deleted. The second might be eliminated but we need to do alias analysis and memref region. 

‘’’
gpu.barrier
Read(%0 : memref<?xf32>)
gpu.barrier
Write(%0 : memref<?xf32>)
gpu.barrier
Read(%0 : memref<?xf32>)
‘’’

**Example 2:**

We also need to consider if-else statements. See the example below, we can eliminate first two barriers, because the last barrier is already synchronizing the threads. 

‘’’
if(){ 
…
gpu.barrier
} else {
…
gpu.barrier
}
gpu.barrier
‘’’



https://github.com/llvm/llvm-project/pull/71575


More information about the Mlir-commits mailing list