A generic pointer of no one space is refused as GenericPointer, naming how and where
canon::generic refused every generic pointer it could not give one address space as AddressSpace(8), with no location, so a caller could not tell a pointer of two spaces from one loaded from memory. Feature::GenericPointer (both crates) now names how the pointer gets a space only the run knows (TwoSpaces, Memory, Aggregate, Call, Integer) and the refusal locates the instruction where it does. AddressSpace's doc now lists 8 as defined; the planner treats a generic pointer that survived canonicalization as an invariant breach. FAST-PATHS records the gap, REFUSALS and the API signature table are regenerated, ARCHITECTURE names the pass. runtime_lane::generic_pointers compares generic_spaces and generic_null with the M3 Max's answers (run next on lavapipe).
This commit is contained in:
1 parent
8d8ae3a1f7
commit
15866645a8
14 files changed
+314
-74
No files matched your search
@@ -18,9 +18,10 @@
|
||||
//! parameter, brings in a space only the run knows.
|
||||
//!
|
||||
//! A group that pointers of two spaces enter, or one a space only the run knows, is
|
||||
//! `Unsupported{AddressSpace(8)}`: no Vulkan pointer holds either. So is a generic pointer passed
|
||||
//! to a call other than a query (the callee's type names the generic space), returned, or held in
|
||||
//! an aggregate or a vector value.
|
||||
//! `Unsupported{GenericPointer(..)}` at the instruction where it does, naming how
|
||||
//! ([`GenericPointer`]): no Vulkan pointer holds either. So is a generic pointer passed to a call
|
||||
//! other than a query (the callee's type names the generic space) or returned (`Call`), or held
|
||||
//! in an aggregate or a vector value (`Aggregate`).
|
||||
//!
|
||||
//! Each generic pointer then is its group's pointer type, and a group that no space enters a
|
||||
//! thread pointer (it addresses nothing). A cast into the generic space is its operand. A cast
|
||||
@@ -38,7 +39,7 @@
|
||||
//! bytes, and a pointer of every space is 64 bits.
|
||||
|
||||
use crate::budget::Meter;
|
||||
use crate::error::{Error, Feature, Unsupported};
|
||||
use crate::error::{DiagName, Error, Feature, GenericPointer, Location, Unsupported};
|
||||
use crate::intrinsics::AirIntrinsic;
|
||||
use crate::ir::{AddrSpace, Body, Callee, CastOp, Const, ConstExpr, ConstId, Constant, FastMath};
|
||||
use crate::ir::{FuncId, Idx, InstId, InstKind, IntPredicate, ModuleParts, Type, TypeId, Value};
|
||||
@@ -55,32 +56,50 @@ enum Space {
|
||||
Unseen,
|
||||
/// Pointers of this space.
|
||||
One(AddrSpace),
|
||||
/// Pointers of two spaces, or of a space only the run knows.
|
||||
Many,
|
||||
/// Pointers of two spaces, or of a space only the run knows: how, and the instruction where
|
||||
/// it entered, where one did.
|
||||
Many(GenericPointer, Option<InstId>),
|
||||
}
|
||||
|
||||
impl Space {
|
||||
fn join(self, other: Space) -> Space {
|
||||
/// The space of a group that both `self` and `other` enter, at instruction `at`.
|
||||
fn join(self, other: Space, at: Option<InstId>) -> Space {
|
||||
match (self, other) {
|
||||
(Space::Unseen, s) | (s, Space::Unseen) => s,
|
||||
(Space::One(a), Space::One(b)) if a == b => Space::One(a),
|
||||
_ => Space::Many,
|
||||
(m @ Space::Many(..), _) | (_, m @ Space::Many(..)) => m,
|
||||
_ => Space::Many(GenericPointer::TwoSpaces, at),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn refused() -> Error {
|
||||
Unsupported::not_implemented(Feature::AddressSpace(AddrSpace::Generic.raw())).into()
|
||||
/// A generic pointer refused for `how`, where no instruction locates it.
|
||||
fn refused(how: GenericPointer) -> Error {
|
||||
Unsupported::not_implemented(Feature::GenericPointer(how)).into()
|
||||
}
|
||||
|
||||
/// The entry's body and parameter types, and the module's tables.
|
||||
/// The entry's name, body and parameter types, and the module's tables.
|
||||
struct Cx<'a> {
|
||||
name: &'a DiagName,
|
||||
body: &'a Body,
|
||||
parts: &'a ModuleParts,
|
||||
params: &'a [TypeId],
|
||||
}
|
||||
|
||||
impl Cx<'_> {
|
||||
/// A generic pointer refused for `how`, at instruction `at` of the entry.
|
||||
fn refuse(&self, how: GenericPointer, at: InstId) -> Error {
|
||||
let block = self
|
||||
.body
|
||||
.blocks
|
||||
.iter()
|
||||
.find(|(_, b)| b.start <= at && at < b.end)
|
||||
.map(|(b, _)| b.raw());
|
||||
Unsupported::not_implemented(Feature::GenericPointer(how))
|
||||
.at(Location::function(self.name.clone(), block, Some(at.raw())))
|
||||
.into()
|
||||
}
|
||||
|
||||
fn generic(&self, ty: TypeId) -> bool {
|
||||
matches!(
|
||||
self.parts.types.get(ty),
|
||||
@@ -105,7 +124,7 @@ impl Cx<'_> {
|
||||
/// Whether `ty` holds a generic pointer below an aggregate or vector level.
|
||||
fn holds_generic(&self, ty: TypeId, depth: u32) -> Result<bool, Error> {
|
||||
if depth > DEPTH {
|
||||
return Err(refused());
|
||||
return Err(refused(GenericPointer::Aggregate));
|
||||
}
|
||||
Ok(match self.parts.types.get(ty) {
|
||||
Some(Type::Vector { elem, .. } | Type::Array { elem, .. }) => {
|
||||
@@ -125,7 +144,7 @@ impl Cx<'_> {
|
||||
/// The space a generic constant brings in, and whether it is null.
|
||||
fn constant(&self, c: ConstId, depth: u32) -> Result<(Space, bool), Error> {
|
||||
if depth > DEPTH {
|
||||
return Err(refused());
|
||||
return Err(refused(GenericPointer::Integer));
|
||||
}
|
||||
let k = self
|
||||
.parts
|
||||
@@ -155,14 +174,14 @@ impl Cx<'_> {
|
||||
Some(Const::Null)
|
||||
),
|
||||
),
|
||||
_ => (Space::Many, false),
|
||||
_ => (Space::Many(GenericPointer::Integer, None), false),
|
||||
}
|
||||
}
|
||||
Const::Expr(ConstExpr::Gep { ops, .. }) => match ops.first() {
|
||||
Some(&base) => self.constant(base, depth + 1)?,
|
||||
None => (Space::Many, false),
|
||||
None => (Space::Many(GenericPointer::Integer, None), false),
|
||||
},
|
||||
_ => (Space::Many, false),
|
||||
_ => (Space::Many(GenericPointer::Integer, None), false),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -240,7 +259,7 @@ impl Cx<'_> {
|
||||
fn operand(&self, v: Value) -> Result<(Space, bool), Error> {
|
||||
match v {
|
||||
Value::Const(c) => self.constant(c, 0),
|
||||
Value::Arg(_) => Ok((Space::Many, false)),
|
||||
Value::Arg(_) => Ok((Space::Many(GenericPointer::Call, None), false)),
|
||||
Value::Inst(_) => Ok((Space::Unseen, false)),
|
||||
}
|
||||
}
|
||||
@@ -305,6 +324,7 @@ pub(super) fn resolve(
|
||||
body: Body,
|
||||
parts: &mut ModuleParts,
|
||||
func: FuncId,
|
||||
name: &DiagName,
|
||||
m: &mut Meter,
|
||||
) -> Result<(Body, bool), Error> {
|
||||
let params: Vec<TypeId> = match parts.funcs.get(func).and_then(|f| parts.types.get(f.ty)) {
|
||||
@@ -313,6 +333,7 @@ pub(super) fn resolve(
|
||||
};
|
||||
let planned = scoped(m, |m, held| {
|
||||
let cx = Cx {
|
||||
name,
|
||||
body: &body,
|
||||
parts,
|
||||
params: ¶ms,
|
||||
@@ -322,7 +343,9 @@ pub(super) fn resolve(
|
||||
let Some(plan) = planned else {
|
||||
return Ok((body, false));
|
||||
};
|
||||
let edited = scoped(m, |m, held| rewrite(&body, parts, ¶ms, &plan, m, held))?;
|
||||
let edited = scoped(m, |m, held| {
|
||||
rewrite(&body, parts, (name, ¶ms), &plan, m, held)
|
||||
})?;
|
||||
body.release(m);
|
||||
Ok((edited, plan.folds))
|
||||
}
|
||||
@@ -365,7 +388,7 @@ fn plan(cx: &Cx<'_>, m: &mut Meter, held: &mut usize) -> Result<Option<Plan>, Er
|
||||
let generic = cx.generic(inst.ty);
|
||||
// Generic values held where no group reaches: an aggregate or a vector.
|
||||
if !generic && cx.holds_generic(inst.ty, 0)? {
|
||||
return Err(refused());
|
||||
return Err(cx.refuse(GenericPointer::Aggregate, i));
|
||||
}
|
||||
match &inst.kind {
|
||||
InstKind::Call(call) => {
|
||||
@@ -377,12 +400,14 @@ fn plan(cx: &Cx<'_>, m: &mut Meter, held: &mut usize) -> Result<Option<Plan>, Er
|
||||
}
|
||||
);
|
||||
if call.args.iter().any(|&a| cx.is_generic(a)) && !query {
|
||||
return Err(refused());
|
||||
return Err(cx.refuse(GenericPointer::Call, i));
|
||||
}
|
||||
folds |= query;
|
||||
// A query's pointer is its own group's.
|
||||
}
|
||||
InstKind::Ret(Some(v)) if cx.is_generic(*v) => return Err(refused()),
|
||||
InstKind::Ret(Some(v)) if cx.is_generic(*v) => {
|
||||
return Err(cx.refuse(GenericPointer::Call, i))
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if !generic {
|
||||
@@ -409,7 +434,7 @@ fn plan(cx: &Cx<'_>, m: &mut Meter, held: &mut usize) -> Result<Option<Plan>, Er
|
||||
Value::Const(c) if matches!(cx.parts.consts.get(*c).map(|k| &k.value), Some(Const::Null))
|
||||
);
|
||||
}
|
||||
_ => s = Space::Many,
|
||||
_ => s = Space::Many(GenericPointer::Integer, Some(i)),
|
||||
},
|
||||
InstKind::Gep { .. }
|
||||
| InstKind::Cast {
|
||||
@@ -421,15 +446,24 @@ fn plan(cx: &Cx<'_>, m: &mut Meter, held: &mut usize) -> Result<Option<Plan>, Er
|
||||
| InstKind::Select { .. } => {
|
||||
for v in linked(&inst.kind) {
|
||||
let (vs, vz) = cx.operand(v)?;
|
||||
s = s.join(vs);
|
||||
s = s.join(vs, Some(i));
|
||||
z |= vz;
|
||||
if let Value::Inst(j) = v {
|
||||
union(&mut parent, i.index(), j.index());
|
||||
}
|
||||
}
|
||||
}
|
||||
// A load, a call, an `inttoptr`, an atomic or an aggregate's element.
|
||||
_ => s = Space::Many,
|
||||
InstKind::Load { .. } | InstKind::AtomicRmw { .. } | InstKind::CmpXchg { .. } => {
|
||||
s = Space::Many(GenericPointer::Memory, Some(i));
|
||||
}
|
||||
InstKind::Call(_) => s = Space::Many(GenericPointer::Call, Some(i)),
|
||||
InstKind::ExtractValue { .. }
|
||||
| InstKind::ExtractElement { .. }
|
||||
| InstKind::InsertValue { .. }
|
||||
| InstKind::InsertElement { .. }
|
||||
| InstKind::ShuffleVector { .. } => s = Space::Many(GenericPointer::Aggregate, Some(i)),
|
||||
// An `inttoptr`: no other operation makes a pointer.
|
||||
_ => s = Space::Many(GenericPointer::Integer, Some(i)),
|
||||
}
|
||||
if let Some(slot) = source.get_mut(i.index()) {
|
||||
*slot = s;
|
||||
@@ -440,12 +474,12 @@ fn plan(cx: &Cx<'_>, m: &mut Meter, held: &mut usize) -> Result<Option<Plan>, Er
|
||||
}
|
||||
// Each group's space: the join of what enters each of its members.
|
||||
let mut group: Vec<Space> = filled(m, held, n, Space::Unseen)?;
|
||||
for k in 0..n {
|
||||
for (i, _) in cx.body.insts.iter() {
|
||||
m.tick(1)?;
|
||||
let r = find(&mut parent, k);
|
||||
let s = source.get(k).copied().unwrap_or(Space::Unseen);
|
||||
let r = find(&mut parent, i.index());
|
||||
let s = source.get(i.index()).copied().unwrap_or(Space::Unseen);
|
||||
if let Some(slot) = group.get_mut(r) {
|
||||
*slot = slot.join(s);
|
||||
*slot = slot.join(s, Some(i));
|
||||
}
|
||||
}
|
||||
// An `icmp`'s constant sides enter its group too.
|
||||
@@ -460,7 +494,7 @@ fn plan(cx: &Cx<'_>, m: &mut Meter, held: &mut usize) -> Result<Option<Plan>, Er
|
||||
let r = find(&mut parent, x.index());
|
||||
let (s, _) = cx.operand(c)?;
|
||||
if let Some(slot) = group.get_mut(r) {
|
||||
*slot = slot.join(s);
|
||||
*slot = slot.join(s, Some(x));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -484,8 +518,8 @@ fn plan(cx: &Cx<'_>, m: &mut Meter, held: &mut usize) -> Result<Option<Plan>, Er
|
||||
_ => find(&mut parent, i.index()),
|
||||
};
|
||||
let s = group.get(r).copied().unwrap_or(Space::Unseen);
|
||||
if s == Space::Many {
|
||||
return Err(refused());
|
||||
if let Space::Many(how, at) = s {
|
||||
return Err(cx.refuse(how, at.unwrap_or(i)));
|
||||
}
|
||||
if let Some(slot) = space.get_mut(i.index()) {
|
||||
*slot = s;
|
||||
@@ -573,7 +607,7 @@ fn retyped(
|
||||
m: &mut Meter,
|
||||
) -> Result<ConstId, Error> {
|
||||
if depth > DEPTH {
|
||||
return Err(refused());
|
||||
return Err(refused(GenericPointer::Integer));
|
||||
}
|
||||
let k = parts
|
||||
.consts
|
||||
@@ -593,7 +627,8 @@ fn retyped(
|
||||
space: AddrSpace::Generic,
|
||||
}) => retyped(parts, interned, o, s, depth + 1, m),
|
||||
Some(Type::Ptr { space }) if *space == s => Ok(o),
|
||||
_ => Err(refused()),
|
||||
Some(Type::Ptr { .. }) => Err(refused(GenericPointer::TwoSpaces)),
|
||||
_ => Err(refused(GenericPointer::Integer)),
|
||||
};
|
||||
}
|
||||
Const::Expr(ConstExpr::Gep {
|
||||
@@ -601,7 +636,9 @@ fn retyped(
|
||||
inbounds,
|
||||
ops,
|
||||
}) => {
|
||||
let (&base, rest) = ops.split_first().ok_or_else(refused)?;
|
||||
let (&base, rest) = ops
|
||||
.split_first()
|
||||
.ok_or_else(|| refused(GenericPointer::Integer))?;
|
||||
let base = retyped(parts, interned, base, s, depth + 1, m)?;
|
||||
let ops: Box<[ConstId]> = std::iter::once(base).chain(rest.iter().copied()).collect();
|
||||
Const::Expr(ConstExpr::Gep {
|
||||
@@ -610,7 +647,7 @@ fn retyped(
|
||||
ops,
|
||||
})
|
||||
}
|
||||
_ => return Err(refused()),
|
||||
_ => return Err(refused(GenericPointer::Integer)),
|
||||
};
|
||||
parts.consts.intern(Constant { ty, value }, m)
|
||||
}
|
||||
@@ -626,7 +663,7 @@ fn taken(space: Space) -> AddrSpace {
|
||||
fn rewrite(
|
||||
body: &Body,
|
||||
parts: &mut ModuleParts,
|
||||
params: &[TypeId],
|
||||
(name, params): (&DiagName, &[TypeId]),
|
||||
plan: &Plan,
|
||||
m: &mut Meter,
|
||||
held: &mut usize,
|
||||
@@ -688,12 +725,13 @@ fn rewrite(
|
||||
// else poison.
|
||||
let to = match parts.types.get(inst.ty) {
|
||||
Some(Type::Ptr { space }) => *space,
|
||||
_ => return Err(refused()),
|
||||
_ => return Err(refused(GenericPointer::Integer)),
|
||||
};
|
||||
let group = match v {
|
||||
Value::Inst(j) => plan.space.get(j.index()).copied().unwrap_or(Space::Unseen),
|
||||
Value::Const(c) => {
|
||||
Cx {
|
||||
name,
|
||||
body,
|
||||
parts,
|
||||
params,
|
||||
@@ -701,7 +739,7 @@ fn rewrite(
|
||||
.constant(c, 0)?
|
||||
.0
|
||||
}
|
||||
Value::Arg(_) => return Err(refused()),
|
||||
Value::Arg(_) => return Err(refused(GenericPointer::Call)),
|
||||
};
|
||||
let value = match group {
|
||||
// A pointer computed from no pointer, made a pointer of another space.
|
||||
@@ -725,7 +763,7 @@ fn rewrite(
|
||||
)?;
|
||||
Value::Const(poison)
|
||||
}
|
||||
Space::Many => return Err(refused()),
|
||||
Space::Many(how, _) => return Err(refused(how)),
|
||||
_ => match v {
|
||||
Value::Const(c) => {
|
||||
Value::Const(retyped(parts, &mut interned, c, to, 0, m)?)
|
||||
@@ -754,14 +792,16 @@ fn rewrite(
|
||||
plan.null.get(j.index()).copied().unwrap_or(true),
|
||||
),
|
||||
Value::Const(c) => Cx {
|
||||
name,
|
||||
body,
|
||||
parts,
|
||||
params,
|
||||
}
|
||||
.constant(c, 0)?,
|
||||
Value::Arg(_) => return Err(refused()),
|
||||
Value::Arg(_) => return Err(refused(GenericPointer::Call)),
|
||||
};
|
||||
let decided = Cx {
|
||||
name,
|
||||
body,
|
||||
parts,
|
||||
params,
|
||||
@@ -809,7 +849,7 @@ fn rewrite(
|
||||
(Space::Unseen, _) => {
|
||||
edit.replace(i, Value::Const(boolean(parts, false, m)?));
|
||||
}
|
||||
(Space::Many, _) => return Err(refused()),
|
||||
(Space::Many(how, _), _) => return Err(refused(how)),
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -820,7 +860,7 @@ fn rewrite(
|
||||
inst.kind.for_each_value(|v| {
|
||||
constants |= matches!(v, Value::Const(_)) && generic_of(parts, v);
|
||||
});
|
||||
let shared = result_generic || query_or_compare_in(parts, body, params, &inst.kind);
|
||||
let shared = result_generic || query_or_compare_in(parts, body, (name, params), &inst.kind);
|
||||
if constants {
|
||||
let mut kind = inst.kind.clone();
|
||||
let mut failed = None;
|
||||
@@ -832,17 +872,18 @@ fn rewrite(
|
||||
taken(own)
|
||||
} else {
|
||||
match (Cx {
|
||||
name,
|
||||
body,
|
||||
parts,
|
||||
params,
|
||||
})
|
||||
.constant(c, 0)
|
||||
{
|
||||
Ok((s, _)) if s != Space::Many => taken(s),
|
||||
Ok(_) => {
|
||||
failed.get_or_insert(refused());
|
||||
Ok((Space::Many(how, _), _)) => {
|
||||
failed.get_or_insert(refused(how));
|
||||
AddrSpace::Thread
|
||||
}
|
||||
Ok((s, _)) => taken(s),
|
||||
Err(e) => {
|
||||
failed.get_or_insert(e);
|
||||
AddrSpace::Thread
|
||||
@@ -999,11 +1040,12 @@ fn retyped_null(
|
||||
fn query_or_compare_in(
|
||||
parts: &ModuleParts,
|
||||
body: &Body,
|
||||
params: &[TypeId],
|
||||
(name, params): (&DiagName, &[TypeId]),
|
||||
kind: &InstKind,
|
||||
) -> bool {
|
||||
query_or_compare(
|
||||
&Cx {
|
||||
name,
|
||||
body,
|
||||
parts,
|
||||
params,
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
//! pointers**: then each pointer of MSL 4.1's generic address space becomes a pointer of the
|
||||
//! one space every pointer it may hold comes from, its space queries answered, and SCCP runs
|
||||
//! again where one was; a generic pointer of two spaces, or of one only the run knows, is
|
||||
//! `Unsupported{AddressSpace(8)}` (`generic`). A call whose immediates were not constants where it was
|
||||
//! `Unsupported{GenericPointer(..)}` (`generic`). A call whose immediates were not constants where it was
|
||||
//! decoded (`Callee::Unbound`: an internal function's parameter passed on to the intrinsic) is
|
||||
//! bound where they now are, each inlined copy with its own call site's constants. A value use of an unsupplied
|
||||
//! constant that survives is `Error::NeedsInput(FunctionConstant)`. **Unrolling**: a loop whose
|
||||
@@ -660,7 +660,7 @@ pub fn specialize_dynamic(
|
||||
};
|
||||
// MSL 4.1's generic pointers, each a pointer of the one space its pointers come from; SCCP
|
||||
// runs again over a body whose space queries that answered.
|
||||
let (resolved, queried) = generic::resolve(body, &mut parts, func, m)?;
|
||||
let (resolved, queried) = generic::resolve(body, &mut parts, func, &name, m)?;
|
||||
body = if queried {
|
||||
let solved = solve(&resolved, &mut parts, &fcs, &name, m)?;
|
||||
resolved.release(m);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! MSL 4.1's generic pointers become pointers of the one space every pointer they may hold comes
|
||||
//! from, their space queries answered; a generic pointer of two spaces, or of one only the run
|
||||
//! knows, is refused as `AddressSpace(8)`.
|
||||
//! knows, is refused as `GenericPointer`, naming how and at which instruction.
|
||||
|
||||
use super::*;
|
||||
use crate::error::{DiagName, GenericPointer};
|
||||
|
||||
/// What [`queried`]'s generic pointer `p` holds.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
@@ -217,8 +218,16 @@ fn stored(e: &Entry) -> Vec<Option<f32>> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn refused(e: Result<Entry, Error>) -> bool {
|
||||
matches!(&e, Err(Error::Unsupported(u)) if u.feature == Feature::AddressSpace(8))
|
||||
/// Whether `e` refuses a generic pointer for `how`, at an instruction of the kernel.
|
||||
fn refused(e: Result<Entry, Error>, how: GenericPointer) -> bool {
|
||||
match &e {
|
||||
Err(Error::Unsupported(u)) => {
|
||||
let at = u.location.as_ref().and_then(|l| l.in_function());
|
||||
u.feature == Feature::GenericPointer(how)
|
||||
&& at.is_some_and(|(f, _, i)| *f == DiagName::new("k") && i.is_some())
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -273,6 +282,6 @@ fn a_query_of_a_variable_or_null_is_the_condition_that_picks() {
|
||||
|
||||
#[test]
|
||||
fn a_generic_pointer_of_two_spaces_or_of_memory_is_refused() {
|
||||
assert!(refused(queried(Held::Mixed)));
|
||||
assert!(refused(queried(Held::Loaded)));
|
||||
assert!(refused(queried(Held::Mixed), GenericPointer::TwoSpaces));
|
||||
assert!(refused(queried(Held::Loaded), GenericPointer::Memory));
|
||||
}
|
||||
@@ -719,8 +719,9 @@ pub enum Feature {
|
||||
/// A function stage the model does not cover.
|
||||
Stage(u8),
|
||||
/// An LLVM address space the typed model does not define (it defines AIR's `thread` 0
|
||||
/// through `threadgroup_imageblock` 4). The 5 and 6 of Apple's AGX ray-tracing and
|
||||
/// tessellation library modules have no established meaning and stay refused.
|
||||
/// through `threadgroup_imageblock` 4, `object_data` 6, the mesh output handle's 7 and MSL
|
||||
/// 4.1's generic 8). The 5 of Apple's AGX ray-tracing and tessellation library modules has no
|
||||
/// established meaning and stays refused.
|
||||
AddressSpace(u32),
|
||||
/// A module-level record outside the accepted subset (alias, ifunc, comdat, …).
|
||||
ModuleRecord {
|
||||
@@ -811,6 +812,31 @@ pub enum Feature {
|
||||
/// [[buffer(n)]];` in Apple's `!air.global_bindings` list, valid AIR this version does not
|
||||
/// implement yet.
|
||||
ProgramScopeBinding,
|
||||
/// A generic pointer (MSL 4.1's `addrspace(8)`) that canonicalization cannot make a pointer of
|
||||
/// one address space, by how it comes to hold a space only the run knows
|
||||
/// ([`GenericPointer`]). Vulkan's logical addressing has no pointer that may point into either
|
||||
/// of two storage classes.
|
||||
GenericPointer(GenericPointer),
|
||||
}
|
||||
|
||||
/// How a refused generic pointer comes to hold an address space only the run knows
|
||||
/// ([`Feature::GenericPointer`]).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum GenericPointer {
|
||||
/// Pointers of two address spaces reach it: a `select` or `phi` of a device and a thread
|
||||
/// pointer, as the run picks.
|
||||
TwoSpaces,
|
||||
/// It is loaded from memory, or is an atomic operation's old value.
|
||||
Memory,
|
||||
/// It is held in, or taken from, an aggregate or a vector value.
|
||||
Aggregate,
|
||||
/// It crosses a call: a call's argument or result (other than a space query's pointer), a
|
||||
/// parameter, or the returned value.
|
||||
Call,
|
||||
/// It is made from an integer (`inttoptr`), or is a constant that is no address space's
|
||||
/// pointer made generic.
|
||||
Integer,
|
||||
}
|
||||
|
||||
/// A constants-block record that LLVM defines (`LLVMBitCodes.h`'s `ConstantsCodes`, and
|
||||
|
||||
@@ -494,6 +494,8 @@ mod function_tables;
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
mod generated_executions;
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
mod generic_pointers;
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
mod global_builtins;
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
mod gpu_times;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
//! MSL 4.1's generic pointers, on the device the cfg selects, under the validation layer: the owned
|
||||
//! fixture `generic_pointers`'s `generic_spaces` (generic pointers into the device, thread and
|
||||
//! threadgroup spaces, read, written and asked their space) and `generic_null` (generic pointers
|
||||
//! the run keeps or makes null, asked their space) answer what the M3 Max answers
|
||||
//! (`generic_pointers.m`).
|
||||
//!
|
||||
//! Each kernel runs eight threads in one threadgroup over `in[i] = i` (16 words); the fixture's
|
||||
//! header says what each word is. Every answer is a small integer or a half, exact in `float`.
|
||||
|
||||
use super::{
|
||||
buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages,
|
||||
ScratchCache, WAIT,
|
||||
};
|
||||
use crate::gpu::TEST_DEVICE;
|
||||
use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource};
|
||||
use metal2vulkan_devtools::llvm_assemble;
|
||||
use metal2vulkan_runtime::{
|
||||
CommandBufferStatus, ComputePipelineState, Device, PipelineOptions, Size,
|
||||
};
|
||||
use std::path::Path;
|
||||
|
||||
/// The threads, all in one threadgroup.
|
||||
const THREADS: usize = 8;
|
||||
|
||||
/// What the M3 Max answers (macOS 27.0.1) for `generic_spaces`, eight words a thread.
|
||||
#[rustfmt::skip]
|
||||
const SPACES: [[f32; 8]; THREADS] = [
|
||||
[100.0, 200.5, 302.0, 100.0, 3.5, 3.0, 2.0, 1.0],
|
||||
[101.0, 202.5, 304.0, 109.0, 3.5, 3.0, 2.0, 1.0],
|
||||
[102.0, 204.5, 306.0, 102.0, 3.5, 3.0, 2.0, 1.0],
|
||||
[103.0, 206.5, 308.0, 111.0, 3.5, 3.0, 2.0, 1.0],
|
||||
[104.0, 204.5, 310.0, 104.0, 3.5, 3.0, 2.0, 1.0],
|
||||
[105.0, 206.5, 312.0, 113.0, 3.5, 3.0, 2.0, 1.0],
|
||||
[106.0, 208.5, 314.0, 106.0, 3.5, 3.0, 2.0, 1.0],
|
||||
[107.0, 210.5, 300.0, 115.0, 3.5, 3.0, 2.0, 1.0],
|
||||
];
|
||||
|
||||
/// What the M3 Max answers for `generic_null`, four words a thread: the spaces of the device,
|
||||
/// thread and threadgroup pointers it kept (1, 2, 3) or made null (4), then of a null pointer.
|
||||
#[rustfmt::skip]
|
||||
const NULL: [[f32; 4]; THREADS] = [
|
||||
[1.0, 2.0, 3.0, 4.0],
|
||||
[1.0, 2.0, 3.0, 4.0],
|
||||
[1.0, 2.0, 3.0, 4.0],
|
||||
[1.0, 2.0, 3.0, 4.0],
|
||||
[4.0, 4.0, 4.0, 4.0],
|
||||
[4.0, 4.0, 4.0, 4.0],
|
||||
[4.0, 4.0, 4.0, 4.0],
|
||||
[4.0, 4.0, 4.0, 4.0],
|
||||
];
|
||||
|
||||
/// The fixture's `entry`, made into a pipeline.
|
||||
fn pipeline(device: &Device, entry: &str) -> ComputePipelineState {
|
||||
let ll =
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/public/engine/generic_pointers.ll");
|
||||
let library = device
|
||||
.new_library_with_air(&llvm_assemble(&ll).unwrap())
|
||||
.unwrap();
|
||||
let function = library.new_function_with_name(entry).unwrap();
|
||||
device
|
||||
.new_compute_pipeline_state(
|
||||
&ComputePipelineDescriptor::new(StageSource::Function(function.function_descriptor())),
|
||||
&PipelineOptions::default(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// The first `words` floats `entry` writes to buffer 0, over `in[i] = i` at buffer 1.
|
||||
fn dispatched(device: &Device, entry: &str, words: usize) -> Vec<f32> {
|
||||
let pipeline = pipeline(device, entry);
|
||||
let input: Vec<u8> = (0..16u16)
|
||||
.flat_map(|i| f32::from(i).to_le_bytes())
|
||||
.collect();
|
||||
let out = buffer_with(device, &vec![0; 4 * words]).unwrap();
|
||||
let input = buffer_with(device, &input).unwrap();
|
||||
let queue = device.new_command_queue().unwrap();
|
||||
let command_buffer = queue.command_buffer().unwrap();
|
||||
let mut encoder = command_buffer.compute_command_encoder().unwrap();
|
||||
encoder.set_compute_pipeline_state(&pipeline).unwrap();
|
||||
encoder.set_buffer(Some(&out), 0, 0).unwrap();
|
||||
encoder.set_buffer(Some(&input), 0, 1).unwrap();
|
||||
encoder
|
||||
.dispatch_threads(
|
||||
Size::new(THREADS as u64, 1, 1),
|
||||
Size::new(THREADS as u64, 1, 1),
|
||||
)
|
||||
.unwrap();
|
||||
encoder.end_encoding().unwrap();
|
||||
command_buffer.commit().unwrap();
|
||||
command_buffer.wait_until_completed_for(WAIT).unwrap();
|
||||
assert_eq!(command_buffer.status(), CommandBufferStatus::Completed);
|
||||
read_buffer(&out, 0, 4 * words as u64)
|
||||
.unwrap()
|
||||
.as_chunks::<4>()
|
||||
.0
|
||||
.iter()
|
||||
.map(|w| f32::from_le_bytes(*w))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Generic pointers of one space each, and generic pointers the run makes null, read, write and
|
||||
/// answer their spaces as Metal does.
|
||||
#[test]
|
||||
fn generic_pointers_answer_as_metal() {
|
||||
let messages = Messages::default();
|
||||
let cache = ScratchCache::new().unwrap();
|
||||
{
|
||||
let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |_| {}).unwrap();
|
||||
let spaces = dispatched(&device, "generic_spaces", 8 * THREADS);
|
||||
for (t, (got, want)) in spaces.chunks(8).zip(SPACES.iter()).enumerate() {
|
||||
assert_eq!(got, want, "generic_spaces: thread {t}");
|
||||
}
|
||||
let null = dispatched(&device, "generic_null", 4 * THREADS);
|
||||
for (t, (got, want)) in null.chunks(4).zip(NULL.iter()).enumerate() {
|
||||
assert_eq!(got, want, "generic_null: thread {t}");
|
||||
}
|
||||
}
|
||||
layer_reported_nothing_at_all(&messages);
|
||||
}
|
||||
@@ -64,6 +64,8 @@ pub use crate::air::error::{
|
||||
pub use crate::air::error::{BudgetExceeded, InternalError, InternalKind, Limit, LinkProblem};
|
||||
// The constants-block records a refusal names (`Feature::Constant`).
|
||||
pub use crate::air::error::ConstantRecord;
|
||||
// How a refused generic pointer holds a space only the run knows (`Feature::GenericPointer`).
|
||||
pub use crate::air::error::GenericPointer;
|
||||
use crate::air::error::{MissingInput, RequestError};
|
||||
use crate::device::requirements::{
|
||||
ApiVersion, FormatUsage, VkExtension, VkFeature, VkLimit, VkProperty,
|
||||
@@ -269,6 +271,7 @@ impl From<crate::air::error::Feature> for Feature {
|
||||
Air::GpuEncodedIndirectCommands => Feature::GpuEncodedIndirectCommands,
|
||||
Air::Imageblocks => Feature::Imageblocks,
|
||||
Air::ProgramScopeBinding => Feature::ProgramScopeBinding,
|
||||
Air::GenericPointer(how) => Feature::GenericPointer(how),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1167,10 +1170,10 @@ pub enum Feature {
|
||||
/// A function stage the model does not cover.
|
||||
Stage(u8),
|
||||
/// An LLVM address space the typed model does not define (it defines AIR's `thread` 0
|
||||
/// through `threadgroup_imageblock` 4, `object_data` 6 and the mesh output handle's 7). The 5
|
||||
/// of Apple's AGX ray-tracing and tessellation library modules has no established meaning and
|
||||
/// stays refused; a pointer in 6 or 7 outside an object or mesh function's payload or mesh
|
||||
/// handle is refused as this feature too, at analysis.
|
||||
/// through `threadgroup_imageblock` 4, `object_data` 6, the mesh output handle's 7 and MSL
|
||||
/// 4.1's generic 8). The 5 of Apple's AGX ray-tracing and tessellation library modules has no
|
||||
/// established meaning and stays refused; a pointer in 6 or 7 outside an object or mesh
|
||||
/// function's payload or mesh handle is refused as this feature too, at analysis.
|
||||
AddressSpace(u32),
|
||||
/// A module-level record outside the accepted subset (alias, ifunc, comdat, …).
|
||||
ModuleRecord {
|
||||
@@ -1600,6 +1603,11 @@ pub enum Feature {
|
||||
/// [[buffer(n)]];` in Apple's `!air.global_bindings` list, valid AIR this version does not
|
||||
/// implement yet.
|
||||
ProgramScopeBinding,
|
||||
/// A generic pointer (MSL 4.1's `addrspace(8)`) that canonicalization cannot make a pointer of
|
||||
/// one address space, by how it comes to hold a space only the run knows
|
||||
/// ([`GenericPointer`]). Vulkan's logical addressing has no pointer that may point into either
|
||||
/// of two storage classes.
|
||||
GenericPointer(GenericPointer),
|
||||
/// A sequentially consistent fence (`seq_cst` `atomic_thread_fence`, an LLVM `fence seq_cst`,
|
||||
/// or a `seq_cst` barrier ordering device memory), whose total order with the command
|
||||
/// buffer's other such fences the translation keeps through an atomic of the command buffer's
|
||||
|
||||
@@ -2086,15 +2086,16 @@ impl Planner<'_> {
|
||||
_ => return Err(Unsupported::not_implemented(Feature::MeshShading).into()),
|
||||
}
|
||||
}
|
||||
// A generic pointer canonicalization could give no one space (`canon::generic`).
|
||||
(
|
||||
_,
|
||||
space @ (AddrSpace::ObjectData | AddrSpace::MeshOutput | AddrSpace::Generic),
|
||||
) => {
|
||||
(_, space @ (AddrSpace::ObjectData | AddrSpace::MeshOutput)) => {
|
||||
return Err(
|
||||
Unsupported::not_implemented(Feature::AddressSpace(space.raw())).into(),
|
||||
)
|
||||
}
|
||||
// Canonicalization gives every generic pointer one space or refuses it
|
||||
// (`canon::generic`).
|
||||
(_, AddrSpace::Generic) => {
|
||||
return Err(invariant("a generic pointer survived canonicalization"))
|
||||
}
|
||||
(_, AddrSpace::Thread) => match roots {
|
||||
[Root::Alloca(a)] => match typed.get(a) {
|
||||
Some(&i) => Repr::PrivPtr(PrivForm::Typed(i)),
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
//! on committed profiles: `generic_spaces` (generic pointers into the device, thread and
|
||||
//! threadgroup spaces, each of one space, read, written and asked their space) and `generic_null`
|
||||
//! (generic pointers the run may make null) compile; `generic_mixed` (one generic pointer into the
|
||||
//! thread or the device space as the run decides) is refused as a generic pointer of two spaces.
|
||||
//! thread or the device space as the run decides) is refused as a generic pointer of two spaces
|
||||
//! (`GenericPointer::TwoSpaces`).
|
||||
|
||||
use crate::air::ir::print::print;
|
||||
use crate::budget::Budget;
|
||||
use crate::device::{Device, DevicePolicy};
|
||||
use crate::error::{Error, Feature};
|
||||
use crate::error::{Error, Feature, GenericPointer};
|
||||
use crate::library::{FunctionConstantValues, Library};
|
||||
use crate::pipeline::testing::{
|
||||
description, engine_dir, llvm_assemble, meter, profile, specialized_entry, AssembleError,
|
||||
@@ -66,15 +67,16 @@ fn generic_pointers_of_one_space_compile() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A generic pointer into the thread or the device space as the run decides is refused, naming
|
||||
/// the generic space.
|
||||
/// A generic pointer into the thread or the device space as the run decides is refused as a
|
||||
/// generic pointer of two spaces.
|
||||
#[test]
|
||||
fn a_generic_pointer_of_two_spaces_is_refused() {
|
||||
let Some(bc) = fixture() else { return };
|
||||
let library = Library::from_air(&bc).expect("library");
|
||||
for stem in PROFILES {
|
||||
match compiled(&library, stem, "generic_mixed") {
|
||||
Err(Error::Unsupported(u)) if u.feature == Feature::AddressSpace(8) => {}
|
||||
Err(Error::Unsupported(u))
|
||||
if u.feature == Feature::GenericPointer(GenericPointer::TwoSpaces) => {}
|
||||
other => panic!("{stem}: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1147,6 +1147,7 @@ enum metal2vulkan-air::error::ContainerError #[derive(Clone, Debug, PartialEq, E
|
||||
enum metal2vulkan-air::error::Error #[derive(Clone, Debug, PartialEq, Eq)] pub enum Error
|
||||
enum metal2vulkan-air::error::ErrorClass #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum ErrorClass
|
||||
enum metal2vulkan-air::error::Feature #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Feature
|
||||
enum metal2vulkan-air::error::GenericPointer #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum GenericPointer
|
||||
enum metal2vulkan-air::error::InputErrorKind #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum InputErrorKind
|
||||
enum metal2vulkan-air::error::InternalKind #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum InternalKind
|
||||
enum metal2vulkan-air::error::IntrinsicError #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum IntrinsicError
|
||||
@@ -1484,6 +1485,7 @@ enum metal2vulkan::error::Error #[derive(Clone, Debug, PartialEq, Eq)] #[non_exh
|
||||
enum metal2vulkan::error::ErrorClass #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum ErrorClass
|
||||
enum metal2vulkan::error::ExtendedRangeBlend #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum ExtendedRangeBlend
|
||||
enum metal2vulkan::error::Feature #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum Feature
|
||||
enum metal2vulkan::error::GenericPointer #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum GenericPointer
|
||||
enum metal2vulkan::error::InputErrorKind #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum InputErrorKind
|
||||
enum metal2vulkan::error::InternalKind #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum InternalKind
|
||||
enum metal2vulkan::error::IntrinsicError #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum IntrinsicError
|
||||
@@ -1908,6 +1910,7 @@ field metal2vulkan-air::intrinsics::NumTy.lanes pub lanes: u32
|
||||
field metal2vulkan-air::intrinsics::Pack.dir pub dir: PackDir
|
||||
field metal2vulkan-air::intrinsics::Pack.format pub format: PackFormat
|
||||
field metal2vulkan-air::intrinsics::Pack.ty pub ty: NumTy
|
||||
field metal2vulkan-air::intrinsics::PointerSpace.space pub space: AddrSpace
|
||||
field metal2vulkan-air::intrinsics::Signature.ret pub ret: Operand
|
||||
field metal2vulkan-air::intrinsics::SimdgroupSize.ty pub ty: Elem
|
||||
field metal2vulkan-air::intrinsics::Texture.access pub access: Option<Access>
|
||||
@@ -7912,6 +7915,7 @@ method metal2vulkan-air::intrinsics::NumTy::parse pub fn parse(token: &str) -> O
|
||||
method metal2vulkan-air::intrinsics::NumTy::scalar pub const fn scalar(elem: Elem) -> NumTy
|
||||
method metal2vulkan-air::intrinsics::NumTy::with_elem pub const fn with_elem(self, elem: Elem) -> NumTy
|
||||
method metal2vulkan-air::intrinsics::Pack::signature pub fn signature(&self) -> Signature
|
||||
method metal2vulkan-air::intrinsics::PointerSpace::signature pub fn signature(&self) -> Signature
|
||||
method metal2vulkan-air::intrinsics::ResultField::operand pub const fn operand(self) -> Operand
|
||||
method metal2vulkan-air::intrinsics::SamplerOp::signature pub fn signature(&self) -> Signature
|
||||
method metal2vulkan-air::intrinsics::Sign::parse pub fn parse(token: &str) -> Option<Sign>
|
||||
@@ -9981,6 +9985,7 @@ struct metal2vulkan-air::intrinsics::Math #[derive(Clone, Copy, Debug, PartialEq
|
||||
struct metal2vulkan-air::intrinsics::MemFlags #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct MemFlags
|
||||
struct metal2vulkan-air::intrinsics::NumTy #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct NumTy
|
||||
struct metal2vulkan-air::intrinsics::Pack #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Pack
|
||||
struct metal2vulkan-air::intrinsics::PointerSpace #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct PointerSpace
|
||||
struct metal2vulkan-air::intrinsics::Signature #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct Signature
|
||||
struct metal2vulkan-air::intrinsics::SimdgroupSize #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SimdgroupSize
|
||||
struct metal2vulkan-air::intrinsics::Texture #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Texture
|
||||
@@ -11027,6 +11032,7 @@ variant metal2vulkan-air::error::Feature::Constant Constant { record: ConstantRe
|
||||
variant metal2vulkan-air::error::Feature::DirectCall DirectCall
|
||||
variant metal2vulkan-air::error::Feature::DynamicCall DynamicCall
|
||||
variant metal2vulkan-air::error::Feature::FunctionConstantArgument FunctionConstantArgument
|
||||
variant metal2vulkan-air::error::Feature::GenericPointer GenericPointer(GenericPointer)
|
||||
variant metal2vulkan-air::error::Feature::GpuEncodedIndirectCommands GpuEncodedIndirectCommands
|
||||
variant metal2vulkan-air::error::Feature::Imageblocks Imageblocks
|
||||
variant metal2vulkan-air::error::Feature::InlineAsm InlineAsm
|
||||
@@ -11045,6 +11051,11 @@ variant metal2vulkan-air::error::Feature::Tensors Tensors
|
||||
variant metal2vulkan-air::error::Feature::Tessellation Tessellation
|
||||
variant metal2vulkan-air::error::Feature::Type Type { code: u32 }
|
||||
variant metal2vulkan-air::error::Feature::UnknownIntrinsic UnknownIntrinsic
|
||||
variant metal2vulkan-air::error::GenericPointer::Aggregate Aggregate
|
||||
variant metal2vulkan-air::error::GenericPointer::Call Call
|
||||
variant metal2vulkan-air::error::GenericPointer::Integer Integer
|
||||
variant metal2vulkan-air::error::GenericPointer::Memory Memory
|
||||
variant metal2vulkan-air::error::GenericPointer::TwoSpaces TwoSpaces
|
||||
variant metal2vulkan-air::error::InputErrorKind::Abi Abi(AbiError)
|
||||
variant metal2vulkan-air::error::InputErrorKind::Bitcode Bitcode(BitcodeError)
|
||||
variant metal2vulkan-air::error::InputErrorKind::Bitstream Bitstream(BitstreamError)
|
||||
@@ -11141,6 +11152,7 @@ variant metal2vulkan-air::intrinsics::AirIntrinsic::IsUniform IsUniform(IsUnifor
|
||||
variant metal2vulkan-air::intrinsics::AirIntrinsic::Math Math(Math)
|
||||
variant metal2vulkan-air::intrinsics::AirIntrinsic::Mesh Mesh(Mesh)
|
||||
variant metal2vulkan-air::intrinsics::AirIntrinsic::Pack Pack(Pack)
|
||||
variant metal2vulkan-air::intrinsics::AirIntrinsic::PointerSpace PointerSpace(PointerSpace)
|
||||
variant metal2vulkan-air::intrinsics::AirIntrinsic::Sampler Sampler(SamplerOp)
|
||||
variant metal2vulkan-air::intrinsics::AirIntrinsic::SimdMatrix SimdMatrix(SimdMatrix)
|
||||
variant metal2vulkan-air::intrinsics::AirIntrinsic::SimdgroupSize SimdgroupSize(SimdgroupSize)
|
||||
@@ -11606,6 +11618,7 @@ variant metal2vulkan-air::intrinsics::WorkItem::GlobalOffset GlobalOffset
|
||||
variant metal2vulkan-air::intrinsics::WorkItem::WorkDim WorkDim
|
||||
variant metal2vulkan-air::ir::AddrSpace::Constant Constant = 2
|
||||
variant metal2vulkan-air::ir::AddrSpace::Device Device = 1
|
||||
variant metal2vulkan-air::ir::AddrSpace::Generic Generic = 8
|
||||
variant metal2vulkan-air::ir::AddrSpace::MeshOutput MeshOutput = 7
|
||||
variant metal2vulkan-air::ir::AddrSpace::ObjectData ObjectData = 6
|
||||
variant metal2vulkan-air::ir::AddrSpace::Thread Thread = 0
|
||||
@@ -14049,6 +14062,7 @@ variant metal2vulkan::error::Feature::Format Format
|
||||
variant metal2vulkan::error::Feature::FramebufferFetch FramebufferFetch
|
||||
variant metal2vulkan::error::Feature::FunctionConstantArgument FunctionConstantArgument
|
||||
variant metal2vulkan::error::Feature::GatherExtended GatherExtended
|
||||
variant metal2vulkan::error::Feature::GenericPointer GenericPointer(GenericPointer)
|
||||
variant metal2vulkan::error::Feature::GlobalBuiltinInFragment GlobalBuiltinInFragment
|
||||
variant metal2vulkan::error::Feature::GpuEncodedIndirectCommands GpuEncodedIndirectCommands
|
||||
variant metal2vulkan::error::Feature::GpuTimes GpuTimes
|
||||
@@ -14142,6 +14156,11 @@ variant metal2vulkan::error::Feature::ViewportDepthRange ViewportDepthRange
|
||||
variant metal2vulkan::error::Feature::VulkanVersion VulkanVersion
|
||||
variant metal2vulkan::error::Feature::WideLines WideLines
|
||||
variant metal2vulkan::error::Feature::WideSwitchLiteral WideSwitchLiteral
|
||||
variant metal2vulkan::error::GenericPointer::Aggregate Aggregate
|
||||
variant metal2vulkan::error::GenericPointer::Call Call
|
||||
variant metal2vulkan::error::GenericPointer::Integer Integer
|
||||
variant metal2vulkan::error::GenericPointer::Memory Memory
|
||||
variant metal2vulkan::error::GenericPointer::TwoSpaces TwoSpaces
|
||||
variant metal2vulkan::error::InputErrorKind::Abi Abi(AbiError)
|
||||
variant metal2vulkan::error::InputErrorKind::Bitcode Bitcode(BitcodeError)
|
||||
variant metal2vulkan::error::InputErrorKind::Bitstream Bitstream(BitstreamError)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -68,7 +68,7 @@ rest is `crates/metal2vulkan/src/`.
|
||||
|
||||
| Module | Role |
|
||||
|---|---|
|
||||
| `air` (`metal2vulkan-air`) | The container (metallib, bitcode wrapper, raw module), the bitstream and bitcode readers, the typed IR, the `air.*` and `llvm.*` intrinsic families, the metadata ABI (`AirAbi`), and canonicalization (`canon`: inlining (each `byval` argument's copy made at its call first), function constants, SCCP (reading the integer fields of a constant global whose value is known, folding the integer bit operations `llvm.ctpop`, `llvm.bitreverse` and `llvm.bswap` and the scalar `llvm.umin`, `llvm.umax`, `llvm.smin` and `llvm.smax` on constants, settling the float operations a constant operand decides whatever the others hold (a NaN operand, the first in order: as it is beside a value the run computes, quieted where every operand is a constant; a product by a zero under `nnan` and `nsz`, `+0`), and reading the immediates of an intrinsic call that its function's parameters gave it once inlining makes them its call site's constants), the unrolling of loops whose constant trip count decides a branch where that leaves the entry no larger, the allocation of a private array of nested arrays as far as its indices reach where constants and counted loops bound every one of them (`canon::reach`), a pointer loaded from a constant table at an index only the run knows (a table of constexpr samplers) read as the `select` chain over the table's elements (`canon::const_tables`), devirtualization, linking, pruning, pointee erasure, the speculation of the short branch arms Metal's backend runs in every lane, the split of a whole array's or struct's load or store in buffer or threadgroup memory into its members' accesses, and a kernel of a pipeline of OpenCL mode linked as Metal links it: the three hidden buffers appended, its buffer indices 3 on, OpenCL C's work-item reads made reads of their built-ins or of the first buffer, each image format query a read of the third, and each operation of a 1D image the 2D texture's that Apple's OpenCL binds for it, `canon::opencl` and `canon::opencl_1d`; and OpenCL C's vector data loads and stores made their element accesses, `canon::vector_data`). Canonicalization also writes the formats the binder and runtime read: the visible-function table's words and the rasterization-rate map's parameter data |
|
||||
| `air` (`metal2vulkan-air`) | The container (metallib, bitcode wrapper, raw module), the bitstream and bitcode readers, the typed IR, the `air.*` and `llvm.*` intrinsic families, the metadata ABI (`AirAbi`), and canonicalization (`canon`: inlining (each `byval` argument's copy made at its call first), function constants, SCCP (reading the integer fields of a constant global whose value is known, folding the integer bit operations `llvm.ctpop`, `llvm.bitreverse` and `llvm.bswap` and the scalar `llvm.umin`, `llvm.umax`, `llvm.smin` and `llvm.smax` on constants, settling the float operations a constant operand decides whatever the others hold (a NaN operand, the first in order: as it is beside a value the run computes, quieted where every operand is a constant; a product by a zero under `nnan` and `nsz`, `+0`), and reading the immediates of an intrinsic call that its function's parameters gave it once inlining makes them its call site's constants), the unrolling of loops whose constant trip count decides a branch where that leaves the entry no larger, the allocation of a private array of nested arrays as far as its indices reach where constants and counted loops bound every one of them (`canon::reach`), a pointer loaded from a constant table at an index only the run knows (a table of constexpr samplers) read as the `select` chain over the table's elements (`canon::const_tables`), each of MSL 4.1's generic pointers made a pointer of the one address space every pointer it may hold comes from, its space queries answered (`canon::generic`), devirtualization, linking, pruning, pointee erasure, the speculation of the short branch arms Metal's backend runs in every lane, the split of a whole array's or struct's load or store in buffer or threadgroup memory into its members' accesses, and a kernel of a pipeline of OpenCL mode linked as Metal links it: the three hidden buffers appended, its buffer indices 3 on, OpenCL C's work-item reads made reads of their built-ins or of the first buffer, each image format query a read of the third, and each operation of a 1D image the 2D texture's that Apple's OpenCL binds for it, `canon::opencl` and `canon::opencl_1d`; and OpenCL C's vector data loads and stores made their element accesses, `canon::vector_data`). Canonicalization also writes the formats the binder and runtime read: the visible-function table's words and the rasterization-rate map's parameter data |
|
||||
| `graph` | The shared RPO, dominator tree, loop forest and SCC |
|
||||
| `budget` | `Budget`, `CancelToken`, and the per-attempt `Meter`: deadline, cancellation, work units, the byte ledger and every structural cap |
|
||||
| `memory/` | Pointer provenance, the `MemoryPlan`, leaf access emitters, arenas, root and handle lookups, word composition, atomics |
|
||||
|
||||
@@ -1526,6 +1526,15 @@ driver's. Each is open work.
|
||||
- **A direct call whose arguments do not line up with its callee's parameters** is refused with
|
||||
`InvalidInput(Canon(CallTypeMismatch))` (`canon::post_check`): LLVM leaves such a call undefined,
|
||||
and what Metal's back end makes of it is not documented, so no exact form is known.
|
||||
- **A generic pointer (MSL 4.1's `addrspace(8)`) that is no one address space's pointer** is
|
||||
refused with `Unsupported(GenericPointer(..))` at the instruction where it gets that space
|
||||
(`canon::generic`). The refusal names how it gets the space: `TwoSpaces` (a `select` or `phi`
|
||||
between pointers of two spaces, such as a device and a thread pointer, as the run picks),
|
||||
`Memory` (loaded from memory), `Aggregate` (held in a struct, array or vector value), `Call`
|
||||
(passed across a call that stays a call) or `Integer` (`inttoptr`). Vulkan's logical
|
||||
addressing has no pointer into either of two storage classes. A generic pointer that every
|
||||
path gives one space becomes that space's pointer, and its space queries are answered as Metal
|
||||
answers them, including no space for a null pointer (`runtime_lane::generic_pointers`).
|
||||
- **A loop that sums its counter fails to make through MoltenVK.** Apple's MSL front end rewrites a
|
||||
loop whose running sum adds its 32-bit counter (`1 + 2 + ... + n`) into a closed form in 33-bit
|
||||
integers, which the M3 Max's back end cannot legalize where it lands in the kernel's constant
|
||||
|
||||
+5
-3
@@ -27,7 +27,7 @@ Columns:
|
||||
|
||||
| Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| Translator and front-end refusals | 128 | 128 | 6 | 32 | 71 | 19 | 0 |
|
||||
| Translator and front-end refusals | 129 | 129 | 7 | 32 | 71 | 19 | 0 |
|
||||
| Runtime gaps | 78 | 78 | 1 | 9 | 46 | 22 | 0 |
|
||||
| Apple-only calls | 4 | 4 | 0 | 0 | 0 | 4 | 0 |
|
||||
| Binder refusals at a device limit | 9 | 9 | 0 | 1 | 7 | 1 | 0 |
|
||||
@@ -41,7 +41,7 @@ Columns:
|
||||
|
||||
| Kind | `metal-measured` | `metal-documented` | `metal-takes` | `device` | `ours` | `unknown` | `delegated` | `-` |
|
||||
|---|---|---|---|---|---|---|---|---|
|
||||
| Translator and front-end refusals | 0 | 0 | 0 | 48 | 57 | 0 | 0 | 23 |
|
||||
| Translator and front-end refusals | 0 | 0 | 0 | 48 | 58 | 0 | 0 | 23 |
|
||||
| Runtime gaps | 0 | 0 | 0 | 0 | 78 | 0 | 0 | 0 |
|
||||
| Apple-only calls | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 |
|
||||
| Binder refusals at a device limit | 0 | 0 | 0 | 9 | 0 | 0 | 0 | 0 |
|
||||
@@ -57,7 +57,7 @@ Columns:
|
||||
|---|---|---|---|---|---|
|
||||
| `LibraryKind` | A metallib of a kind the container does not read | - | `-` | via a helper: 2: `crates/metal2vulkan-air/src/container/mtlb.rs (parse)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: a metallib file type Apple's toolchain is not seen to write |
|
||||
| `Stage` | A function stage the model does not cover | - | `-` | via a helper: 2: `crates/metal2vulkan-air/src/abi/check.rs (unsupported_stage)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: a stage outside AIR's public stages |
|
||||
| `AddressSpace` | An LLVM address space the typed model does not define (it defines AIR's `thread` 0 through `threadgroup_imageblock` 4, `object_data` 6 and the... | every device (not implemented) | `ours` | 2: `crates/metal2vulkan-air/src/ir/types.rs (from_raw)`, `crates/metal2vulkan/src/memory/plan.rs (reprs)` | `none`: Apple's AGX library address spaces |
|
||||
| `AddressSpace` | An LLVM address space the typed model does not define (it defines AIR's `thread` 0 through `threadgroup_imageblock` 4, `object_data` 6, the mesh... | every device (not implemented) | `ours` | 2: `crates/metal2vulkan-air/src/ir/types.rs (from_raw)`, `crates/metal2vulkan/src/memory/plan.rs (reprs)` | `none`: Apple's AGX library address spaces |
|
||||
| `ModuleRecord` | A module-level record outside the accepted subset (alias, ifunc, comdat, …) | - | `-` | via a helper: 4: `crates/metal2vulkan-air/src/bitcode/module.rs (function)`, `crates/metal2vulkan-air/src/bitcode/module.rs (global)` (+2) | `none`: LLVM constructs AIR does not emit |
|
||||
| `Instruction` | An instruction record outside the closed instruction set | - | `-` | via a helper: 11: `crates/metal2vulkan-air/src/bitcode/function.rs (call, 2 sites)`, `crates/metal2vulkan-air/src/bitcode/function.rs (record, 8 sites)` (+1) | `none`: LLVM instructions AIR does not emit |
|
||||
| `Type` | A type outside the typed model | - | `-` | via a helper: 4: `crates/metal2vulkan-air/src/bitcode/types.rs (decode, 3 sites)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: LLVM types AIR does not emit |
|
||||
@@ -180,6 +180,7 @@ Columns:
|
||||
| `PrivateRenderState` | A private fixed-function property of Metal's pipeline descriptor (Apple SPI, OpenGL on Metal's) set to a value whose effect the translation has... | devices without VkFeature::FragmentShaderPixelInterlock; devices without VkFeature::LogicOp; devices without VkFeature::RasterizationOrderColorAttachmentAccess; every device (not implemented) | `ours` | 7: `crates/metal2vulkan/src/bind/heap.rs (array)`, `crates/metal2vulkan/src/bind/plan/resources.rs (write_rounding)` (+5) | `none`: Apple-private pipeline fields of OpenGL on Metal (no public header) |
|
||||
| `ExtendedRangeBlend` | A blend the function computes in the shader, into an extended-range attachment (`BGRA10_XR`, `BGR10_XR`, `RGB10A8_2P_XR10` and their `_sRGB`... | every device (not implemented) | `ours` | 5: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (refused)`, `crates/metal2vulkan/src/lower/fragment/fetch.rs (extended_range_output)` (+1) | `system`: an extended-range (XR10) attachment blended from an output other than four half or float lanes; a 16-bit float attachment's storage-form blend of a second-source factor or a one-color-channel mask under fast math; the consumer's guests blend RGB10A8_2P_XR10 attachments |
|
||||
| `ProgramScopeBinding` | A program-scope buffer binding of MSL 3.2 (macOS 15 and later), `constant T* constant p [[buffer(n)]];` in Apple's `!air.global_bindings` list,... | - | `-` | via a helper: 2: `crates/metal2vulkan-air/src/abi/module.rs (decode)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `app`: MSL 3.2 program-scope buffer bindings (macOS 15 and later) |
|
||||
| `GenericPointer` | A generic pointer (MSL 4.1's `addrspace(8)`) that canonicalization cannot make a pointer of one address space, by how it comes to hold a space... | every device (not implemented) | `ours` | 2: `crates/metal2vulkan-air/src/canon/generic.rs (refuse)`, `crates/metal2vulkan-air/src/canon/generic.rs (refused)` | `system`: MSL 4.1 generic pointers held in memory or of two spaces (macOS 27 and later) |
|
||||
| `SeqCstFence` | A sequentially consistent fence (`seq_cst` `atomic_thread_fence`, an LLVM `fence seq_cst`, or a `seq_cst` barrier ordering device memory), whose... | devices short of a Vulkan feature the site names | `device` | 1: `crates/metal2vulkan/src/lower/sync/barrier.rs (require_seq_cst)` | `rare`: a seq_cst fence in a vertex or fragment stage without its stores and atomics |
|
||||
| `PostDepthCoverage` | The coverage after the depth and stencil tests (`[[sample_mask, post_depth_coverage]]`), read through `VK_EXT_post_depth_coverage` | devices short of a Vulkan extension the site names; devices without VkExtension::ExtPostDepthCoverage | `device` | 2: `crates/metal2vulkan-runtime/src/families/features.rs (state)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)` | `rare`: the coverage after early depth and stencil tests on a device without VK_EXT_post_depth_coverage |
|
||||
| `WideLines` | Lines at a width other than 1 (Apple's `setLineWidth:`), drawn by the device's own wide lines (`wideLines`) or as bands of triangles through... | devices without VkFeature::TessellationShader; devices without VkLimit::MaxTessellationEvaluationOutputComponents; every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/pipeline/link/band.rs (plan, 3 sites)` | `none`: a line under the Apple-private setLineWidth: at a width other than 1 drawn as the band, whose pipeline form the translator does not build (a selected slice or viewport, barycentric weights, multiview, synthesized geometry, too many stage outputs) |
|
||||
@@ -702,6 +703,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `feature::PrivateRenderState`: `crates/metal2vulkan/src/bind/heap.rs (array)`; `crates/metal2vulkan/src/bind/plan/resources.rs (write_rounding)`; `crates/metal2vulkan/src/lower/sampler/select.rs (clamps_reference)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (alpha_test_refused)`; `crates/metal2vulkan/src/lower/texture/mod.rs (mode_rounded_write)`; `crates/metal2vulkan/src/pipeline/private_state.rs (logic_operation)`; `crates/metal2vulkan/src/pipeline/private_state.rs (refused)`
|
||||
- `feature::ExtendedRangeBlend`: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (refused)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (extended_range_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (plan, 3 sites)`
|
||||
- `feature::ProgramScopeBinding`: `crates/metal2vulkan-air/src/abi/module.rs (decode)`; `crates/metal2vulkan/src/error/mod.rs (from)`
|
||||
- `feature::GenericPointer`: `crates/metal2vulkan-air/src/canon/generic.rs (refuse)`; `crates/metal2vulkan-air/src/canon/generic.rs (refused)`
|
||||
- `feature::SeqCstFence`: `crates/metal2vulkan/src/lower/sync/barrier.rs (require_seq_cst)`
|
||||
- `feature::PostDepthCoverage`: `crates/metal2vulkan-runtime/src/families/features.rs (state)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`
|
||||
- `feature::WideLines`: `crates/metal2vulkan/src/pipeline/link/band.rs (plan, 3 sites)`
|
||||
|
||||
@@ -238,6 +238,7 @@ gap SurfaceDepthStencil rare a blit of the stencil of a Depth32Float_Stencil8 te
|
||||
feature ExtendedRangeBlend system an extended-range (XR10) attachment blended from an output other than four half or float lanes; a 16-bit float attachment's storage-form blend of a second-source factor or a one-color-channel mask under fast math; the consumer's guests blend RGB10A8_2P_XR10 attachments
|
||||
feature CommandPredication none Apple-private command predication on a device without buffer device addresses
|
||||
feature ProgramScopeBinding app MSL 3.2 program-scope buffer bindings (macOS 15 and later)
|
||||
feature GenericPointer system MSL 4.1 generic pointers held in memory or of two spaces (macOS 27 and later)
|
||||
feature SeqCstFence rare a seq_cst fence in a vertex or fragment stage without its stores and atomics
|
||||
gap MultisampledBufferCopy rare a buffer<->multisampled-texture copy on a device without sample-rate shading, an integer multisample attachment at the count, or the copy format's storage; and, where maintenance8's depth/colour copies are missing or wrong, what the sample-rate draws cannot move: a 16-bit depth on a driver whose codes the fragment-depth draw is not measured to keep, or a depth or stencil texture they cannot sample or render to (emulated elsewhere; the consumer's Maps pans and screensaver make the copy)
|
||||
gap MultisampledBufferLayout rare a buffer<->multisampled-texture copy at a bytesPerRow of 0 from an offset that is a multiple of 16, or of pixels of 32 bytes or more at a pitch below a row or off the pixel: Metal copies these by rules not yet reduced, and its API validation rejects them
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 17 and column 65.
|
Reference in new issue
Block a user