# Heap.home after GPU work: runs a `!` call (so the heap is CUDA managed memory), then moves the heap home twice and # prints what each call covered. Build: bend heap_test.bend -o heap_test && HEAP_TRACE=1 ./heap_test import Base import ../heap.bend as HP def pow2(+n: Nat) -> U32: match n: case 0n: 1 case 1n+p: a b = pow2(p) pow2(p) (a + b : U32) def main() -> IO(Unit): do IO: IO.print("GPU: " ++ U32.show(pow2!(16n))) a : U32 <- HP.Heap.home(0) b : U32 <- HP.Heap.home(256) IO.print("Heap.home: " ++ U32.show(a) ++ " MiB, then " ++ U32.show(b) ++ " MiB")