From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119498 invoked by alias); 28 May 2017 23:32:33 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 119480 invoked by uid 89); 28 May 2017 23:32:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,LIKELY_SPAM_FROM,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=1n, 1N, HTo:D*charter.net, HTo:U*jvdelisle X-HELO: edge20.ethz.ch Received: from edge20.ethz.ch (HELO edge20.ethz.ch) (82.130.99.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 28 May 2017 23:32:29 +0000 Received: from CAS22.d.ethz.ch (172.31.51.112) by edge20.ethz.ch (82.130.99.26) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 29 May 2017 01:32:30 +0200 Received: from [192.168.0.227] (77.58.177.254) by mail.ethz.ch (172.31.51.112) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 29 May 2017 01:32:30 +0200 Subject: Re: [Patch, fortran] PR35339 Optimize implied do loops in io statements To: Jerry DeLisle References: <910df381-5f26-a05e-6cae-efbd26c1c880@charter.net> From: Nicolas Koenig CC: GCC-Fortran-ML Message-ID: <4bf3850e-393c-6ef8-3895-4a17931c1b9b@student.ethz.ch> Date: Sun, 28 May 2017 23:32:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <910df381-5f26-a05e-6cae-efbd26c1c880@charter.net> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00154.txt.bz2 Hello Jerry, it already handles READ statements ;) Those were the results i got: gcc@dcm-linux:~/pr/35339> cat perf_test.f90 program main implicit none integer:: i integer, parameter:: N = 10000000 integer, dimension(N):: g do i=1,N g(i) = i end do open(10,file="test.dat") write (10,*) (g(i), i=1,N) close(10) end program gcc@dcm-linux:~/pr/35339> gfortran -O3 perf_test.f90 gcc@dcm-linux:~/pr/35339> time ./a.out real 0m1.879s user 0m1.838s sys 0m0.040s gcc@dcm-linux:~/pr/35339> gfortran-7 -O3 perf_test.f90 gcc@dcm-linux:~/pr/35339> time ./a.out real 0m1.929s user 0m1.901s sys 0m0.028s It does seem to make everything a bit faster, but not by much. At least it gets rid of most of the loops that make problems with asynchronous io. I noticed while writing the patch that "a(1:size(a):1)" isn't converted to "a(FULL)". Would their be any performance gain in doing this? Nicolas On 05/29/2017 12:06 AM, Jerry DeLisle wrote: > On 05/27/2017 12:49 PM, Nicolas Koenig wrote: >> Hello everyone, >> >> attached is a patch to simplify implied do loops in io statements by >> replacing them with their respective array slices. For example "WRITE >> (*,*) (a(i), i=1,4,2)" becomes "WRITE (*,*) a(1:4:2)". >> >> Ok for trunk? >> > > Thanks for patch. Could you do some timing performance tests with and > without the patch on large arrays and see if we gain anything? > > Also, we should expand the test case to include implied do loops in > read statements. You could probably just rewind the file, copy down > the WRITEs and change them to READs or similar and check results. > > While doing some checks myself I noticed some odd behavior and found > PR53029. I posted a patch, but what caught my attention was the > implied do version was faster than the array version. (about .89 sec > vs 6 sec) > > So with my patch there I am now getting (.89 sec vs .007 sec) > > This prompted me to have you check some performance cases. > > Thanks for additional feedback, > > Jerry > >