[patch,libgfortran] PR51119 - MATMUL slow for large matrices

Tim Prince n8tm@aol.com
Mon Nov 14 02:04:00 GMT 2016


On 11/13/2016 7:55 PM, Steve Kargl wrote:
> On Sun, Nov 13, 2016 at 04:08:50PM -0800, Jerry DeLisle wrote:
>> Hi all,
>>
>> Attached patch implements a fast blocked matrix multiply. The basic algorithm is
>> derived from netlib.org tuned blas dgemm. See matmul.m4 for reference.
>>
>> The matmul() function is compiled with -Ofast -funroll-loops. This can be
>> customized further if there is an undesired optimization being used. This is
>> accomplished using #pragma optimize ( string ).
>>
>
> Did you run any tests with '--param max-unroll-times=4' where
> the 4 could be something other than 4.  On troutmask, with my
> code I've found that 4 seems to work the best with -funroll-loops.
>
That's been a typical optimum for Intel server and client CPUs beginning 
with Nehalem.  For small loops it should fit within Loop Stream 
Detection.   The high degree of source code blocking here argues that 
would be the most unrolling which could be useful.
AVX2 CPUs seem to have a more pronounced optimum at unroll-times=4 than 
earlier ones.  AVX-512 might argue for 2.

-- 
Tim Prince



More information about the Fortran mailing list