generic_pointers: the null case joins the fixture; the null query test reads the printout's form
generic_null (which space a null generic pointer answers) was the probe's own source; the fixture now holds it too, so the runtime lane can run it against Metal's answers. The canon test's printout check matched a form body_text does not print (m3-max-21118).
This commit is contained in:
1 parent
d51aa35c62
commit
87a6929bc0
3 files changed
+31
-3
No files matched your search
@@ -226,7 +226,12 @@ fn a_query_of_a_pointer_a_null_may_reach_asks_whether_it_is_null() {
|
||||
let e = queried(Held::Nullable).unwrap_or_else(|e| panic!("{e}"));
|
||||
assert!(!names_generic(&e), "{}", body_text(&e));
|
||||
let text = body_text(&e);
|
||||
assert!(text.contains("icmp ne ptr addrspace(1)"), "{text}");
|
||||
// The device query compares the device pointer with the device null.
|
||||
assert!(
|
||||
text.lines()
|
||||
.any(|l| l.contains("icmp ne") && l.contains("ptr addrspace(1) zeroinitializer")),
|
||||
"{text}"
|
||||
);
|
||||
// The device query is the run's; the thread query is false.
|
||||
assert_eq!(stored(&e)[1..], [None, Some(0.0)], "{text}");
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// space, which a device, thread or threadgroup pointer converts to, read and written through
|
||||
// functions that take them, and asked which space they point into (`is_device_addrspace`,
|
||||
// `is_thread_addrspace`, `is_threadgroup_addrspace`). The owned fixture
|
||||
// `engine/generic_pointers.metal` holds the same source for `generic_spaces` and `generic_mixed`
|
||||
// (its header gives each word); `generic_null` is this probe's own: which space a null generic
|
||||
// `engine/generic_pointers.metal` holds the same source for `generic_spaces`, `generic_mixed` and
|
||||
// `generic_null` (its header gives each word); `generic_null` asks which space a null generic
|
||||
// pointer answers, where the run decides whether a pointer is null.
|
||||
//
|
||||
// Build (no cargo target needed):
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
// otherwise, a generic pointer into the thread or the device space as the run decides, and writes
|
||||
// out[t] = weigh(p, t & 1): 210 + (t & 1) for t < 4, (t & 1) + 100 for the rest.
|
||||
//
|
||||
// `generic_null`: thread t of eight keeps its pointers where in[t] < 4 and makes them null
|
||||
// otherwise, and writes out[4t + j]: [0] space(in or null), [1] space(local or null), [2]
|
||||
// space(shared or null), [3] space(nullptr): 1, 2, 3, 4 for t < 4, and 4 four times for the rest
|
||||
// (a null generic pointer is in no space).
|
||||
//
|
||||
// The locals are declared ahead of the switch's only label (on t >> 31, zero for every thread),
|
||||
// so every path into the switch bypasses their declarations and Clang emits no lifetime markers
|
||||
// for them (as in ob2_sized_array.metal). Loop-free.
|
||||
@@ -83,3 +88,21 @@ kernel void generic_mixed(device float *out [[buffer(0)]],
|
||||
out[t] = weigh(p, t & 1);
|
||||
}
|
||||
}
|
||||
|
||||
kernel void generic_null(device float *out [[buffer(0)]],
|
||||
device const float *in [[buffer(1)]],
|
||||
uint t [[thread_position_in_grid]],
|
||||
uint l [[thread_position_in_threadgroup]]) {
|
||||
threadgroup float shared[8];
|
||||
switch (t >> 31) {
|
||||
float local[2];
|
||||
default:
|
||||
local[0] = 1.0f;
|
||||
shared[l] = 1.0f;
|
||||
bool keep = in[t] < 4.0f;
|
||||
out[4 * t + 0] = space(keep ? in : nullptr);
|
||||
out[4 * t + 1] = space(keep ? (const float *)local : nullptr);
|
||||
out[4 * t + 2] = space(keep ? (const float *)shared : nullptr);
|
||||
out[4 * t + 3] = space(nullptr);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user