>> you should be able to write: 
>>
>>   @inbounds for y in 1:img.height 
>>     @simd for x in 1:img.wid 
>>       if 1 < x < img.wid 
>>         left   = img.data[x-1,y] 
>>         center = img.data[x,y] 
>>         @inbounds right  = img.data[x+1,y] 
>>
>> Just curious, why did you get rid of the @inbounds on the assignments to 
> left and center, but not right?

My mistake, should be `right  = img.data[x+1,y]` without the @inbounds

>> Also, did you check that the @simd works?  I'm no expert on that but my 
>> understanding is that most of the time it doesn't work with if-else.  If 
>> that is the case, maybe special-case the first and last iteration and 
>> run the loop like: @simd for x in 2:img.wid-1 . 
>
>
> I just did that and I don't see a huge difference there. I'm not sure @simd 
> is doing much there, in fact I took it out and nothing changed. Probably 
> have to look at the LLVM IR output to see what's happening there.

You have to look at the machine code, see
https://software.intel.com/en-us/articles/vectorization-in-julia

>  In fact that would save 
>> you a comparisons in each iteration irrespective of @simd. 
>>
>
> Yes, that's a good point.  I think I'll just pre-load those two columns 
> (the 1st and last columns of the matrix)



Reply via email to