In case anyone is interested in contributing here, this is a simple 
optimization to make.  `A[:] = 0.` is currently using the abstract 
fallbacks, which is implemented with as a simple loop. There are already 
some optimizations for `setindex!(::Array, …)` in cases like this where we 
can take advantage of Array's contiguous memory storage 
here: 
https://github.com/JuliaLang/julia/blob/02748d1753ff698dd1c25cecbf19c3450aaac9e8/base/array.jl#L332

On Monday, October 5, 2015 at 4:37:23 PM UTC-4, Kristoffer Carlsson wrote:
>
> I get this on newest master
>
> julia> @time fill!(A, 0.);
>   0.007519 seconds (4 allocations: 160 bytes)
>
> julia> @time A[:] = 0.;
>   0.010495 seconds (5 allocations: 176 bytes)
>
> julia> @time ccall(:memset, Ptr{Void}, (Ptr{Void}, Cint, Csize_t), A, 0, 
> sizeof(A));
>   0.007656 seconds (4 allocations: 64 bytes)
>
> Doesn't matter much though, won't be a bottle neck for anyones code.
>
>
> On Monday, October 5, 2015 at 7:33:43 PM UTC+2, Tomas Lycken wrote:
>>
>> > but I'm using Julia 0.5, so maybe I have a better version of the A[:] 
>> assignment.
>>
>> I love how Julia just gets more and more powerful...
>>
>> // T
>>
>> On Monday, October 5, 2015 at 6:48:00 PM UTC+2, Steven G. Johnson wrote:
>>>
>>>
>>>
>>> On Monday, October 5, 2015 at 12:29:17 PM UTC-4, Kristoffer Carlsson 
>>> wrote:
>>>>
>>>> For me, the fill! version uses SIMD instructions so it is faster than 
>>>> the A[:] version.
>>>>
>>>> Steven, maybe you are on a julia version / computer where you don't get 
>>>> vectorized code from fill!.
>>>>
>>>
>>> I'm on a machine with SIMD, but I'm using Julia 0.5, so maybe I have a 
>>> better version of the A[:] assignment. 
>>>
>>

Reply via email to