Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
f8de2ce
Add a system of performance counters. WIP.
abadams Apr 30, 2026
69b6f59
Add performance warnings and Func nesting
abadams Apr 30, 2026
842222d
Add more performance warnings; better printing
abadams May 1, 2026
1c9fab9
Add warning for large expensive frees
abadams May 1, 2026
12f238d
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams May 1, 2026
a963da7
Move profiling later so flatten nested ramps is accounted for
abadams May 1, 2026
189be1f
Add warning for allocation in a serial loop
abadams May 1, 2026
a1f2fef
Profiler: instance-aware accounting, GPU support, recompute diagnostics
abadams May 14, 2026
cb092e2
Profiler: tag each entry with a kind instead of sniffing names/indices
abadams May 14, 2026
4417945
Profiler: rename the per-row "instance" concept to "entry"
abadams May 14, 2026
c1e0ee9
Profiler: drop stray debug(0) print
abadams May 14, 2026
f9d2432
Profiler: distinguish in-scope-name vs label-only first arg of declar…
abadams May 14, 2026
ca17ab8
Profiler: only widen counter-incrementing intrinsics inside vectorize…
abadams May 14, 2026
c01c433
Profiler: tolerate inline_marker chains not under a Provide
abadams May 14, 2026
bba76d7
Profiler: attribute inline_markers buried in extern call args
abadams May 15, 2026
4621be9
Profiler: re-use inline_marker as the BoundsInference Inliner's wrapper
abadams May 15, 2026
79b1549
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams May 15, 2026
1b54a18
Target is a struct, not a class
abadams May 15, 2026
3e575c2
Merge branch 'abadams/profile_recompute' of https://github.com/halide…
abadams May 15, 2026
9d10419
Delete dead code; clang-format
abadams May 15, 2026
b1b205e
Profiler: dedupe BuildInlineGraph let_roots via std::set
abadams May 15, 2026
6137cf8
Profiler: fix O(N^2) bounds-inference cost for chains of inlined Funcs
abadams May 17, 2026
54d2ffb
Profiler: further reduce BoundsInference cost for inlined chains
abadams May 17, 2026
62192a7
Profiler: tighten comments in BoundsInference deferral path
abadams May 17, 2026
696c085
Fix exponential blow-up in skip_stages on chains of let-bound selects
abadams May 17, 2026
69a4a16
Clean up branch-merging in SkipStages::visit(Select)
abadams May 17, 2026
83b9cdf
Simplify many_inlined_selects test
abadams May 17, 2026
d7b52e7
Merge branch 'abadams/fix_exponential_skip_stages' into abadams/profi…
abadams May 17, 2026
f931bfd
Profiler: drop poisoned declare_box_required_at_root markers
abadams May 18, 2026
2e8af72
test/profiler_instances: cover the overflowing-bounds drop path
abadams May 18, 2026
7a64c78
test/profiler_instances: simplify the overflowing-bounds repro
abadams May 18, 2026
8844628
test/profiler_instances: rename wide_user/table16 -> tab_caller/tab
abadams May 18, 2026
c14fcaa
Profiler: revert get_qualified_body to CSE per cached entry
abadams May 18, 2026
b7cce72
Merge branch 'abadams/profile_recompute' of https://github.com/halide…
abadams May 19, 2026
9453f13
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams May 19, 2026
9ca422d
Profiler: stamp narrowed bounds at inwards level for inwards counter
abadams May 21, 2026
5ef1dc7
Profiler: name warning kinds with an enum
abadams May 21, 2026
bd75abc
Merge branch 'abadams/profile_recompute' of https://github.com/halide…
abadams May 21, 2026
6942823
Profiler: flags bitfield, trivial-wrapper inference, friendly names, …
abadams May 21, 2026
dd9c1e8
BoundsInference: assert the Inliner never re-encounters an inline_marker
abadams May 21, 2026
d4320d1
test/correctness/inlined_doubling_chain: stress test for shared cache…
abadams May 21, 2026
1de71b7
Merge branch 'abadams/profile_recompute' of https://github.com/halide…
abadams May 21, 2026
486a22c
Profiler: copy per-Func identity flags into canonical aggregate
abadams May 22, 2026
c977000
Profiler: drop high-recompute warning for inlined Funcs
abadams May 22, 2026
4559e2a
Rewrite sliding window bounds let at the correct loop level
abadams May 22, 2026
fe571ed
Comment tweak
abadams May 22, 2026
803a2a5
Merge remote-tracking branch 'origin/abadams/sliding_window_bounds_re…
abadams May 22, 2026
9c2fe4a
Comment tweak
abadams May 22, 2026
287ca81
Merge remote-tracking branch 'origin/main' into abadams/sliding_windo…
abadams May 26, 2026
18321b3
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams May 26, 2026
e94034c
Merge remote-tracking branch 'origin/abadams/sliding_window_bounds_re…
abadams May 26, 2026
dede142
Remove inlined-Func profiling support
abadams May 26, 2026
930b7c7
Fix memory_profiler_mandelbrot to skip allocation-kind entries
abadams May 26, 2026
5c72a85
Remove profiler performance warnings and dead counters
abadams May 27, 2026
6c76de0
Revert BoundsInference.cpp to main
abadams May 27, 2026
aa9d8f3
Clean up profiler TODOs
abadams May 27, 2026
4d8c00a
Serialize/deserialize Function::profiler_display_name
abadams May 27, 2026
e74f39d
Remove inlined_doubling_chain test
abadams May 27, 2026
4adb721
Remove stale commented-out abort_if_false in profiler reset
abadams May 27, 2026
688a905
Profiler: track IR name on EntryInfo, fix stray entry for clone_in
abadams May 27, 2026
db609c9
Profiler: remove InjectCounters and dependent counter columns
abadams May 27, 2026
2cc3a3a
Profiler: cleanup unrelated diffs and unused machinery
abadams May 27, 2026
8826b8d
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams May 27, 2026
54338ef
Profiler: trim verbose comments
abadams May 27, 2026
9dc238e
Apply pre-commit auto-fixes
halide-ci[bot] May 27, 2026
9919861
Profiler tests: query the runtime via JIT symbol lookup
abadams May 28, 2026
e9277ca
Profiler tests: simplify
abadams May 28, 2026
651c067
Generator asserts: accept ProfileByTimer; drop stale user_context skip
abadams May 28, 2026
76b8424
Add profiler_instances build to CMake
alexreinking May 28, 2026
9b3d3a4
profiler_instances aottest: drop unused parent_name/parent_id_of helpers
abadams May 28, 2026
dadeeb5
Profiler: fix halide_profiler_func_stats 32-bit layout
abadams May 28, 2026
cf44d0c
Profiler: fix func_names stride mismatch on 32-bit
abadams May 28, 2026
f2f6387
Profiler: track and label fused-allocation buffers
abadams May 29, 2026
1f6e526
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams May 29, 2026
4d09888
Add back system of runtime counters to the profiler
abadams May 29, 2026
8de458f
Profiler: bill num_allocs and memory_total via the counters mutator
abadams May 29, 2026
ecbe6dd
Apply pre-commit auto-fixes
halide-ci[bot] May 29, 2026
095c154
Delete dead code
abadams May 29, 2026
d1a6c88
Merge branch 'abadams/profile_recompute_with_counters' of https://git…
abadams May 29, 2026
f7ab2dd
clang-tidy fixes
abadams Jun 3, 2026
299536e
clang-tidy fix in ScheduleFunctions
abadams Jun 3, 2026
23d8638
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams Jun 29, 2026
3d76431
Defer GPU shared/heap allocation fusing to the offload site
abadams Jul 15, 2026
7d7e298
Don't warp-stripe heap allocations in LowerWarpShuffles
abadams Jul 15, 2026
9be0149
Give fused GPU backing allocations a short unique name
abadams Jul 16, 2026
596b2ce
Merge remote-tracking branch 'origin/main' into abadams/defer_fusing_…
abadams Jul 17, 2026
b27b5cc
Apply pre-commit auto-fixes
halide-ci[bot] Jul 17, 2026
c0bd7c3
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams Jul 17, 2026
3fd00ff
Merge remote-tracking branch 'origin' into abadams/profile_recompute_…
abadams Jul 17, 2026
b668a28
Merge remote-tracking branch 'origin/abadams/defer_fusing_gpu_allocat…
abadams Jul 17, 2026
b9b4179
Give fused GPU allocations meaningful names via merging
abadams Jul 17, 2026
4ef55f1
Merge remote-tracking branch 'origin/abadams/defer_fusing_gpu_allocat…
abadams Jul 17, 2026
ec575ba
Fix GPU allocation naming
abadams Jul 17, 2026
5bc2d0e
test for orphan allocate nodes
abadams Jul 17, 2026
4a2b855
GPU memory tracking fixes
abadams Jul 27, 2026
3b89b82
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams Jul 27, 2026
8c26a5e
Profiler: tighten GPU recompute counters and fix allocation ordering
abadams Jul 27, 2026
bf1c4cb
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams Aug 3, 2026
27515b4
Profiler: flag GPU counters that are upper bounds with a leading '<'
abadams Aug 3, 2026
1bebecc
Merge remote-tracking branch 'origin/main' into abadams/profile_recom…
abadams Aug 5, 2026
70c3c69
Fix stale declare_allocation comment in IR.h
abadams Aug 6, 2026
c30c131
Drop unnecessary diffs vs main from the profiler branch
abadams Aug 7, 2026
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
3 changes: 3 additions & 0 deletions src/IR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,10 @@ constexpr const char *intrinsic_op_names[] = {
"count_leading_zeros",
"count_trailing_zeros",
"debug_to_file",
"declare_allocation",
"declare_box_required_at_root",
"declare_box_touched",
"declare_stage",
"div_round_to_zero",
"dynamic_shuffle",
"extract_bits",
Expand Down
15 changes: 15 additions & 0 deletions src/IR.h
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,23 @@ struct Call : public ExprNode<Call> {
count_leading_zeros,
count_trailing_zeros,
debug_to_file,
// Emitted (when profiling) for a device-only allocation that has no
// host-side Allocate node: the buffer lives solely on the device, so
// InjectHostDevBufferCopies elides its host allocation. Lets the
// profiler, which tracks memory at host Allocate nodes, still see the
// allocation and bill its size to the Func.
// Args: (StringImm Func name, size in bytes, IntImm memory type).
declare_allocation,
// Declares that region required of a particular Func at this
// scope. Injected by ScheduleFunctions and used by the profiler.
declare_box_required_at_root,
// Declares that a box region of an allocation has been touched (used by bounds inference)
declare_box_touched,
// Declares that the following stmt computes a particular stage of
// a particular Func. Used by the profiler to bill points computed
// in the pure def separately from points computed in update defs.
// Args: (Variable<Handle> handle for the func, Int<32> stage_idx).
declare_stage,
div_round_to_zero,
// A shuffle operation with runtime-varying indices.
dynamic_shuffle,
Expand Down
34 changes: 33 additions & 1 deletion src/InjectHostDevBufferCopies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "IRMutator.h"
#include "IROperator.h"
#include "IRPrinter.h"
#include "Simplify.h"
#include "Substitute.h"

#include <map>
Expand Down Expand Up @@ -490,6 +491,12 @@ class InjectBufferCopies : public IRMutator {
protected:
using IRMutator::visit;

// Whether the pipeline is being profiled, so we know whether to emit
// allocation markers for device-only buffers whose host allocation we
// strip below (the profiler tracks memory at the host Allocate, which
// no longer carries a size for these).
bool profiling;

// Inject the registration of a device destructor just after the
// .buffer symbol is defined (which is safely before the first
// device_malloc).
Expand Down Expand Up @@ -658,6 +665,25 @@ class InjectBufferCopies : public IRMutator {
// references to it (e.g. the one in the make_buffer
// call) with NULL.
body = substitute(op->name, reinterpret(Handle(), make_zero(UInt(64))), body);
if (profiling) {
// The storage still exists on the device, but with no
// host Allocate size the profiler can't see it. Emit a
// declare_allocation marker carrying the device
// allocation's byte size so it gets billed to this Func.
// A 0-dimensional allocation (empty extents) holds one
// element, so start the product at the element size.
Expr size_bytes = make_const(UInt(64), op->type.bytes());
for (const Expr &extent : op->extents) {
size_bytes *= cast<uint64_t>(extent);
}
size_bytes = simplify(size_bytes);
Expr marker = Call::make(Int(32), Call::declare_allocation,
{Expr(op->name),
size_bytes,
make_const(Int(32), (int)op->memory_type)},
Call::Intrinsic);
body = Block::make(Evaluate::make(marker), body);
}
}

return op->with(op->extents, condition, body);
Expand All @@ -674,6 +700,11 @@ class InjectBufferCopies : public IRMutator {
return IRMutator::visit(op);
}
}

public:
InjectBufferCopies(bool profiling)
: profiling(profiling) {
}
};

// Find the site in the IR where we want to inject the copies/dirty
Expand Down Expand Up @@ -794,7 +825,8 @@ Stmt inject_host_dev_buffer_copies(Stmt s, const Target &t) {
}

// Handle internal allocations
s = InjectBufferCopies()(s);
bool profiling = t.has_feature(Target::Profile) || t.has_feature(Target::ProfileByTimer);
s = InjectBufferCopies(profiling)(s);

// Handle inputs and outputs
FindOutermostProduce outermost;
Expand Down
13 changes: 7 additions & 6 deletions src/Lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,6 @@ void lower_impl(const vector<Function> &output_funcs,
s = bound_small_allocations(s);
log("Lowering after bounding small allocations:", s);

if (t.has_feature(Target::Profile) || t.has_feature(Target::ProfileByTimer)) {
debug(1) << "Injecting profiling...\n";
s = inject_profiling(s, pipeline_name, env);
log("Lowering after injecting profiling:", s);
}

if (t.has_feature(Target::CUDA)) {
debug(1) << "Injecting warp shuffles...\n";
s = lower_warp_shuffles(s, t);
Expand Down Expand Up @@ -440,6 +434,13 @@ void lower_impl(const vector<Function> &output_funcs,
s = hoist_loop_invariant_if_statements(s);
log("Lowering after removing dead allocations and hoisting loop invariants:", s);

if (t.has_feature(Target::Profile) || t.has_feature(Target::ProfileByTimer)) {
debug(1) << "Injecting profiling...\n";
s = inject_profiling(s, pipeline_name, env, t);
s = simplify(s);
log("Lowering after injecting profiling:", s);
}

debug(1) << "Finding intrinsics...\n";
// Must be run after the last simplification, because it turns
// divisions into shifts, which the simplifier reverses.
Expand Down
Loading
Loading