patch, libfortran: Speedup for unpack intrinsic
Thomas Koenig
tkoenig@netcologne.de
Sun Mar 23 17:46:00 GMT 2008
Hello world,
here is a speedup patch for the unpack intrinsic, with
a speedup that's quite OK:
$ cat unpack-speed.f90
program main
integer, parameter:: n = 100
integer :: i
real, dimension(n*n) :: vect
real, dimension(n,n) :: a,b
logical(kind=1), dimension(n,n) :: mask
call random_number(a)
mask = a > 0.5
call random_number(b)
call random_number(vect)
do i=1,10000
a = unpack(vect,mask,0.)
end do
end program main
$ gfortran -static -O3 unpack-speed.f90
$ time ./a.out
real 0m1.064s
user 0m1.048s
sys 0m0.000s
$ gfortran-4.3 -static -O3 unpack-speed.f90
$ time ./a.out
real 0m2.772s
user 0m2.760s
sys 0m0.000s
Regression-tested on i686-pc-linux-gnu. I'll ask Dominique in a
separate E-Mail to cross-check this for me (although I did try
to be more careful this time :-)
OK once this has passed cross-check?
Thomas
2007-03-23 Thomas Koenig <tkoenig@gcc.gnu.org
PR libfortran/32972
* Makefile.am: Add new variable, i_unpack_c, containing
unpack_i1.c, unpack_i2.c, unpack_i4.c, unpack_i8.c,
unpack_i16.c, unpack_r4.c, unpack_r8.c, unpack_r10.c,
unpack_r16.c, unpack_c4.c, unpack_c8.c, unpack_c10.c
and unpack_c16.c
Add i_unpack_c to gfor_built_src.
Add rule to generate i_unpack_c from m4/unpack.m4.
* Makefile.in: Regenerated.
* libgfortran.h: Add prototypes for unpack0_i1, unpack0_i2,
unpack0_i4, unpack0_i8, unpack0_i16, unpack0_r4, unpack0_r8,
unpack0_r10, unpack0_r16, unpack0_c4, unpack0_c8, unpack0_c10,
unpack0_c16, unpack1_i1, unpack1_i2, unpack1_i4, unpack1_i8,
unpack1_i16, unpack1_r4, unpack1_r8, unpack1_r10, unpack1_r16,
unpack1_c4, unpack1_c8, unpack1_c10 and unpack1_c16.
* intrinsics/pack_generic.c (unpack1): Add calls to specific
unpack1 functions.
(unpack0): Add calls to specific unpack0 functions.
* m4/unpack.m4: New file.
* generated/unpack_i1.c: New file.
* generated/unpack_i2.c: New file.
* generated/unpack_i4.c: New file.
* generated/unpack_i8.c: New file.
* generated/unpack_i16.c: New file.
* generated/unpack_r4.c: New file.
* generated/unpack_r8.c: New file.
* generated/unpack_r10.c: New file.
* generated/unpack_r16.c: New file.
* generated/unpack_c4.c: New file.
* generated/unpack_c8.c: New file.
* generated/unpack_c10.c: New file.
* generated/unpack_c16.c: New file.
2007-03-23 Thomas Koenig <tkoenig@gcc.gnu.org
PR libfortran/32972
* gfortran.dg/intrinsic_unpack_1.f90: New test case.
* gfortran.dg/intrinsic_unpack_2.f90: New test case.
* gfortran.dg/intrinsic_unpack_3.f90: New test case.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: intrinsic_unpack_1.f90
Type: text/x-fortran
Size: 3764 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080323/812c2ec4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: intrinsic_unpack_2.f90
Type: text/x-fortran
Size: 1139 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080323/812c2ec4/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: intrinsic_unpack_3.f90
Type: text/x-fortran
Size: 979 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080323/812c2ec4/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unpack-diff
Type: text/x-patch
Size: 22070 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080323/812c2ec4/attachment-0003.bin>
More information about the Gcc-patches
mailing list