Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge origin/main (4139d41) into pr2-compact-tier: the native task / …
…mesh pipelines bf420fd keeps in the pipeline archive are taken by the size tiers too (nvn_geometry.inc: a mesh pipeline found in a file the compaction does not take is not captured again), arch_harvest's rename, and the tier tests wait for an earlier test's queued archive work before picking
  • Loading branch information
bettterlabs committed Nov 9, 2026
commit c85dcf1f53d507a3ec83d3792eac57c2ce46b381
2 changes: 1 addition & 1 deletion dm/gfx/nvn/nvn_geometry.inc
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ static id<MTLRenderPipelineState> mtk_build(const pso_key *k, NvShader *ts, NvSh
if (m4) {
id<MTLRenderPipelineState> ps = nil; int from_run = 0;
for (id<MTL4Archive> a in g_arch4p) if ((ps = [a newRenderPipelineStateWithDescriptor:m4 error:nil])) break; // a period of mesh pipelines alone is a p file (no vertex layout)
if (!ps) for (id<MTL4Archive> a in g_arch4) if ((ps = [a newRenderPipelineStateWithDescriptor:m4 error:nil])) { from_run = 1; break; }
if (!ps) for (id<MTL4Archive> a in g_arch4) if ((ps = [a newRenderPipelineStateWithDescriptor:m4 error:nil])) { from_run = arch_compact_takes(a); break; } // a file this compaction takes
if (ps) {
g_mtk_arch++; if (archived) *archived = 1;
if (from_run && g_compact_enabled && atomic_load(&g_warm_running)) arch_harvest(m4, 1);
Expand Down
2 changes: 1 addition & 1 deletion dm/gfx/nvn/nvn_mtl.m
Original file line number Diff line number Diff line change
Expand Up @@ -8043,7 +8043,7 @@ static void arch_harvest(MTL4PipelineDescriptor *d, int compact) {
if (g_arch_bundle && (ps = [g_arch_bundle newComputePipelineStateWithDescriptor:d error:nil])) atomic_fetch_add(&g_cps_arch, 1);
else for (id<MTL4Archive> a in g_arch4) if ((ps = [a newComputePipelineStateWithDescriptor:d error:nil])) { // arch_capture_cs writes them to plain files only
atomic_fetch_add(&g_cps_run, 1);
if (arch_compact_takes(a) && atomic_load(&g_warm_running)) cps_harvest(d, 1);
if (arch_compact_takes(a) && atomic_load(&g_warm_running)) arch_harvest(d, 1);
break;
}
atomic_fetch_add(&g_cps_look_ns, bp_now() - t0);
Expand Down
12 changes: 9 additions & 3 deletions dm/gfx/tests/t_pso_archive.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Metal 4 descriptor keeps the MTLDevice path; pso_key_norm drops what no pipeline depends on; compaction merges the files the prewarm took bases from into one per full period despite a
// mid-prewarm timer flush, removing them only after its last period, and a compaction that did not finish is not tried again on the same system build; depth-only draws write depth; concurrent colour variants compile
// one base; archive flushes preserve unrelated compiler state; a function with function constants is specialized by its pipeline's descriptor, not through its library,
// and an MTLDevice pipeline gets it specialized; the descriptor for a specialization is the caller's whether the driver returns it retained or autoreleased; a compute pipeline is captured into a plain file and taken from it later, one without a Metal 4 descriptor never looked up; a capture that fails builds the pipeline all the same and hands a full period over, or stops capturing after a failure in a period that captured nothing; run files are compacted by size tier from the pipeline count in their names (a tier of more than PSO_ARCH_COMPACT files and every smaller one, never a full period's, old and malformed names as the largest tier, the same across fresh processes), and a compute pipeline in a file left out is not captured again
// and an MTLDevice pipeline gets it specialized; the descriptor for a specialization is the caller's whether the driver returns it retained or autoreleased; a compute pipeline is captured into a plain file and taken from it later, one without a Metal 4 descriptor never looked up; a native mesh pipeline is captured into a p file and taken from it later, with or without a task shader or a pixel shader, captured again by a compaction, and one without a Metal 4 descriptor built through the MTLDevice; a capture that fails builds the pipeline all the same and hands a full period over, or stops capturing after a failure in a period that captured nothing; run files are compacted by size tier from the pipeline count in their names (a tier of more than PSO_ARCH_COMPACT files and every smaller one, never a full period's, old and malformed names as the largest tier, the same across fresh processes), and a compute or task / mesh pipeline in a file left out is not captured again
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Expand Down Expand Up @@ -153,7 +153,7 @@ static void compute_pipelines(void) {
EXPECT("compute, compaction: captured again", 1, g_compacted);
g_compact_state = calloc(g_arch4.count + 1, 1); g_compacted = 0; // a pick that leaves the file it is in: not captured again
EXPECT("compute, compaction of other files: a pipeline", 1, cps_new(kf, &err) != nil);
dispatch_sync(cps_harvest_q(), ^{});
dispatch_sync(arch_harvest_q(), ^{});
EXPECT("compute, compaction of other files: not captured again", 0, g_compacted);
g_compact_state = NULL;
EXPECT("compute, compaction: waits for the flush", pending + 1, g_arch_new);
Expand Down Expand Up @@ -249,6 +249,11 @@ static void mesh_pipelines(void) {
EXPECT("mesh, compaction: from the archive", arch + 4, g_mtk_arch);
dispatch_sync(arch_harvest_q(), ^{});
EXPECT("mesh, compaction: captured again", 1, g_compacted);
g_compact_state = calloc(g_arch4.count + 1, 1); g_compacted = 0; // a pick that leaves the file it is in: not captured again
EXPECT("mesh, compaction of other files: a pipeline", 1, mtk_build(&k, nil, ms, fs, &err, NULL) != nil);
dispatch_sync(arch_harvest_q(), ^{});
EXPECT("mesh, compaction of other files: not captured again", 0, g_compacted);
g_compact_state = NULL;
EXPECT("mesh, compaction: waits for the flush", pending + 1, g_arch_new);
atomic_store(&g_warm_running, 0); g_compact_enabled = 0; g_compacted = 0;
arch_flush_wait();
Expand Down Expand Up @@ -491,7 +496,8 @@ static long pick_n(NSArray<NSArray<NSNumber *> *> *groups) {
for (NSArray<NSNumber *> *g in groups) for (int i = 0; i < g[0].intValue; i++, seq++)
[names addObject:g[1].intValue > 0 ? [NSString stringWithFormat:@"/x/%05d-%d.mtl4a", seq, g[1].intValue] : g[1].intValue ? [NSString stringWithFormat:@"/x/%05d-x.mtl4a", seq]
: [NSString stringWithFormat:@"/x/%05d.mtl4a", seq]];
g_compact_enabled = 0; g_compact_files = nil; g_compact_state = NULL; arch_compact_pick(names);
arch_flush_wait(); dispatch_sync(g_arch_q, ^{}); // an earlier test's queued write or finish must not land between the pick and the count
g_compacted = 0; g_compact_enabled = 0; g_compact_files = nil; g_compact_state = NULL; arch_compact_pick(names);
long n = g_compact_enabled ? compacting_n() : 0;
g_compact_enabled = 0; g_compact_files = nil; g_compact_state = NULL;
return n;
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.