mkitti / ArrayAllocators.jl

Allocate arrays with malloc, calloc, or on NUMA nodes
MIT License
53 stars 1 forks source link

Implement alternative version of zeros #8

Closed mkitti closed 2 years ago

mkitti commented 2 years ago

From #7 it seems there may be an expectation for this package to implement a new version of zeros based on calloc that can be used a drop in replacement for Base.zeros.

I am somewhat reluctant to add this since the Array{T}(...) syntax is preferred. However, perhaps some will find this useful.

mkitti commented 2 years ago

Proposed usage may look like this:

julia> @time ArrayAllocators.zeros(Int, 3200, 3200);
  0.000026 seconds (4 allocations: 78.125 MiB)

julia> @time Base.zeros(Int, 3200, 3200);
  0.133595 seconds (2 allocations: 78.125 MiB, 67.36% gc time)

julia> ArrayAllocators.zeros(Int, 256, 256) == Base.zeros(Int, 256, 256)
true

It should be possible to also import ArrayAllocators.zeros if Base.zeros has not been used already.