The easiest way to write slow for loops is to make them row-major instead
of column-major.

-- mb

On Thu, May 12, 2016 at 8:46 AM, Anonymous <[email protected]> wrote:

> So I guess the consensus is not that Julia's devectorized code is so much
> faster than its vectorized code (in fact I keep getting slow downs when I
> test out different devectorizations of my algorithms), but that R's
> devectorized code just sucks, either that or I really suck at writing for
> loops.
>
> honestly I've been testing out different devectorizations of my algorithms
> and I keep getting slower results, not faster, so either I really suck at
> writing for loops or Julia is doing a good job with my vectorized code.
>
> On Thursday, May 12, 2016 at 4:49:42 AM UTC-7, Stefan Karpinski wrote:
>>
>> On Thu, May 12, 2016 at 7:41 AM, Keno Fischer <
>> [email protected]> wrote:
>>
>>> There seems to be a myth going around that vectorized code in Julia is
>>> slow. That's not really the case. Often times it's just that
>>> devectorized code is faster because one can manually perform
>>> operations such as loop fusion, which the compiler cannot currently
>>> reason about (and most C compilers can't either). In some other
>>> languages those benefits get drowned out by language overhead, but in
>>> julia those kinds of constructs are generally fast. The cases where
>>> julia can be slower is when there is excessive memory allocation in a
>>> tight inner loop, but those cases can usually be rewritten fairly
>>> easily without losing the vectorized look of the code.
>>
>>
>> This. JMW's blog post on the subject is as relevant as when he wrote it:
>>
>>
>> http://www.johnmyleswhite.com/notebook/2013/12/22/the-relationship-between-vectorized-and-devectorized-code/
>>
>> Conclusion:
>>
>>    - *Julia’s vectorized code is 2x faster than R’s vectorized code*
>>    - Julia’s devectorized code is 140x faster than R’s vectorized code
>>    - Julia’s devectorized code is 1350x faster than R’s devectorized code
>>
>> Julia's vectorized code is not slow – it's faster than other languages.
>> It's just that Julia allows you to write even faster code when it matters.
>>
>

Reply via email to