Skip to content

Commit

Permalink
[DO NOT MERGE] Add Barrier to fix race issue from different layout
Browse files Browse the repository at this point in the history
Signed-off-by: Nirvedh Meshram <nirvedh@gmail.com>
  • Loading branch information
nirvedhmeshram committed Jan 8, 2025
1 parent ba95762 commit 982856b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ LogicalResult resolveGPUMappedForallOp(RewriterBase &rewriter,
Value ub = getValueOrCreateConstantIndexOp(rewriter, loc, totalLoopTripCount);
Value step =
rewriter.create<arith::ConstantIndexOp>(loc, flatTotalNumWorkers);
// This needs to be landed properly do not merge.
rewriter.create<gpu::BarrierOp>(loc);
auto forLoop = rewriter.create<scf::ForOp>(loc, lb, ub, step, ValueRange{});
rewriter.create<gpu::BarrierOp>(loc);
Block *loopBody = forLoop.getBody();

// Get the replacement IDs for the forall iterator ids.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ hal.executable public @main {
// for loop.
// CHECK: vector.transfer_write %{{.*}}, %[[B2]]{{.*}} memref<10x1xf32, #hal.descriptor_type<storage_buffer>>
// CHECK-NEXT: }
// CHECK-NEXT: gpu.barrier
// CHECK-NEXT: } {mapping = [#iree_codegen.workgroup_mapping<x>]}
// CHECK-NEXT: return

Expand Down

0 comments on commit 982856b

Please sign in to comment.