W1033

W1033 — The loop of a spawn region runs on one thread although each pass writes only memory of its own, so its passes could run at the same time. The warning points at what stops it: a call the compiler cannot show writes nothing, inline MLIR, a read of a row another pass writes, bounds not known when compiling, and the like. A region that calls barrier() asks for blocks and threads, so it is warned about whenever it runs on one thread, with the first thing that stopped the split: two threads that may write the same element, a break out of a loop that holds a barrier(), a write to block-shared memory with no barrier() after it, and the like.

What the compiler reports

Warning[W1033]
{{^}}4 3 2 1{{$}}

The fragments the test suite holds the compiler to. An ellipsis marks text the test does not constrain; the emitted message also carries a source location.

A program that triggers it

//
// Part of the Vx Project, under the Apache License v2.0 with LLVM Exceptions.
// See LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// A `spawn` region fills a tile, calls `barrier()`, and then reads the tile in the other order.
// The region runs on one thread, so the compiler warns (W1033). Both code generators run it.
//

fn main() -> i32 {
  let mut out = Tensor<f32, [4]>::new();
  spawn on(Topology::CPU) {
    let mut part = Tensor<f32, [4]>::new();
    for t in 0..4 {
      part[t] = (t as f32) + 1.0;
    }
    barrier();
    for t in 0..4 {
      out[t] = part[3 - t];
    }
  }
  println!("{} {} {} {}", out[0], out[1], out[2], out[3]);
  return 0;
}

From tests/backend/pass/a_barrier_in_a_spawn_region.vx, which asserts this diagnostic on every commit.

Related