Skip to content

Commit

Permalink
fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ACEsuit committed Jun 1, 2024
1 parent 710689e commit 8aa9ff5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ WithAlloc.whatalloc(::typeof(mymul!), B, C) =
(promote_type(eltype(B), eltype(C)), size(B, 1), size(C, 2))

# the "naive use" of automated pre-allocation could look like this:
# This is essentially the code that the macro @withalloc generates
@no_escape begin
A2_alloc_info = WithAlloc.whatalloc(mymul!, B, C)
A2 = @alloc(A2_alloc_info...)
Expand Down Expand Up @@ -84,7 +85,6 @@ end
```

This approach should become non-allocating, which we can quickly check.
There currently seems to be a bug in `@withalloc` for more than a single allocation though.
```julia
using WithAlloc, LinearAlgebra, Bumper

Expand All @@ -97,5 +97,5 @@ nalloc = let B = randn(5,10), C = randn(10, 3)
@allocated sum( @withalloc mymul!(B, C) )
end

@show nalloc
@show nalloc # 0
```
4 changes: 2 additions & 2 deletions test/_readme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ WithAlloc.whatalloc(::typeof(mymul!), B, C) =
(promote_type(eltype(B), eltype(C)), size(B, 1), size(C, 2))

# the "naive use" of automated pre-allocation could look like this:
# (this is essentially the code that the macro generates)
@no_escape begin
A2_alloc_info = WithAlloc.whatalloc(mymul!, B, C)
A2 = @alloc(A2_alloc_info...)
Expand Down Expand Up @@ -53,10 +54,9 @@ end
end



# ------------------------------------------------------------------------
# Bonus: does this become non-allocating ... we can quickly check ...
# there currently seems to be a bug in @withalloc for more than a singl
# allocation.

using WithAlloc, LinearAlgebra, Bumper

Expand Down

0 comments on commit 8aa9ff5

Please sign in to comment.