[llvm] [mlir] [mlir] Add InferUniformityOpInterface (PR #220825)

Alessandro Potenza via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 08:05:48 PDT 2026


================
@@ -0,0 +1,120 @@
+//===- InferUniformityOpInterface.h - Uniformity ----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the definitions of the uniformity inference interface
+// defined in `InferUniformityOpInterface.td`, and the lattice value it works
+// with.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_INTERFACES_INFERUNIFORMITYOPINTERFACE_H
+#define MLIR_INTERFACES_INFERUNIFORMITYOPINTERFACE_H
+
+#include "mlir/IR/OpDefinition.h"
+#include "llvm/ADT/ArrayRef.h"
+#include <optional>
+
+namespace mlir {
+
+/// The widest group of threads of a SIMT launch within which an SSA value is
+/// known to be the same for every thread, from the narrowest to the widest.
+///
+/// The groups nest: a thread belongs to a subgroup (warp, wave), a subgroup to
+/// a workgroup (thread block), a workgroup to a cluster, and every cluster to
+/// the launch. A value that is the same within a group is also the same within
+/// every narrower group, so the scopes are totally ordered and the meet of two
+/// scopes is the narrower one.
+enum class UniformityScope : uint8_t {
+  /// Two threads of the same subgroup may observe different values.
+  Divergent = 0,
+  /// The same for every thread of a subgroup.
+  Subgroup,
+  /// The same for every thread of a workgroup.
+  Workgroup,
+  /// The same for every thread of a cluster of workgroups.
+  Cluster,
+  /// The same for every thread of the launch.
+  Uniform,
+};
----------------
alepot55 wrote:

scf.for and affine.for implement it in the third PR, and spirv ops could too, since apart from cluster these are the SPIR-V execution scopes as well, so I didn't want SCF or SPIR-V to depend on the GPU dialect. If you'd still rather have it under GPU, the other dialects' ops would become external models registered from the GPU side, the way SCF registers its BufferizableOpInterface models, and the analysis would move with it. I can do that if it's the preferred shape.


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


More information about the llvm-commits mailing list