From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Llorens Newsgroups: gmane.lisp.guile.devel Subject: array-copy! is slow & array-map.c (was: Extremly slow for format & string-join) Date: Mon, 1 Apr 2013 19:15:31 +0200 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: multipart/mixed; boundary=Apple-Mail-133--17724916 X-Trace: ger.gmane.org 1364837215 25564 80.91.229.3 (1 Apr 2013 17:26:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Apr 2013 17:26:55 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Apr 01 19:27:22 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UMiVu-0007Um-Dd for guile-devel@m.gmane.org; Mon, 01 Apr 2013 19:27:22 +0200 Original-Received: from localhost ([::1]:46370 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMiVV-0005HW-Pd for guile-devel@m.gmane.org; Mon, 01 Apr 2013 13:26:57 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMiVP-0005BK-Sk for guile-devel@gnu.org; Mon, 01 Apr 2013 13:26:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMiVK-0008Co-II for guile-devel@gnu.org; Mon, 01 Apr 2013 13:26:51 -0400 Original-Received: from zhbdzmsp-smta15.bluewin.ch ([195.186.99.132]:43337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMiKU-0004WX-6X for guile-devel@gnu.org; Mon, 01 Apr 2013 13:15:34 -0400 Original-Received: from [195.186.227.130] ([195.186.227.130:60864] helo=zhhdzmsp-smta12.bluewin.ch) by zhbdzmsp-smta15.bluewin.ch (envelope-from ) (ecelerity 2.2.3.47 r(39824M)) with ESMTP id F8/7A-14388-4B0C9515; Mon, 01 Apr 2013 17:15:32 +0000 Original-Received: from [10.0.1.10] (81.63.103.144) by zhhdzmsp-smta12.bluewin.ch (8.5.142) (authenticated as dll@bluewin.ch) id 510085B005D23490 for guile-devel@gnu.org; Mon, 1 Apr 2013 17:15:32 +0000 In-Reply-To: X-Mailer: Apple Mail (2.1085) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.186.99.132 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16093 Archived-At: --Apple-Mail-133--17724916 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > Message: 5 > Date: Mon, 1 Apr 2013 15:40:48 +0800 > From: Daniel Hartwig > To: guile-devel@gnu.org > Subject: Re: Extremly slow for format & string-join > On 1 April 2013 14:59, Daniel Llorens = wrote: >> How can it be slower to allocate the result at once? >=20 > Shrug. I do not know much of array internals. You probably have much > more experience there than I. Not much with the implementation, no :-/ > Except for the curious profile output, I suspect the overhead is due > to such factors as repeated application of MAPFUNC and consequent > arithmetic to access the shared arrays contents mapfunc is used only to compute the strides and bounds, it isn't kept = beyond make-shared-array. But I hadn't thought that the profile was wrong. Indeed, the slow part = is not make-typed-array but array-copy!. scheme@(guile-user)> (define s "1234567890") scheme@(guile-user)> (define t (make-shared-array s (lambda (i j) (list = j)) 1000000 10)) scheme@(guile-user)> (define a (make-typed-array 'a *unspecified* = 1000000 10)) scheme@(guile-user)> (define b (make-typed-array 'a *unspecified* = 1000000 10)) scheme@(guile-user)> ,time (array-copy! t a) ;; 1.718000s real time, 1.710000s run time. 0.000000s spent in GC. scheme@(guile-user)> ,time (array-copy! a b) ;; 1.673000s real time, 1.670000s run time. 0.000000s spent in GC. scheme@(guile-user)>=20 Since I have no intuition for these numbers, I thought maybe it's really = this slow, or a cache problem, who knows: scheme@(guile-user)> (import (rnrs bytevectors)) scheme@(guile-user)> (define x (make-bytevector 40000000)) scheme@(guile-user)> ,time (define y (bytevector-copy x)) ;; 0.018000s real time, 0.020000s run time. 0.000000s spent in GC. In NumPy (using doubles): In [11]: %time a =3D np.zeros([1000000, 10]) CPU times: user 0.04 s, sys: 0.05 s, total: 0.09 s Wall time: 0.09 s In [12]: %time b =3D a+1 CPU times: user 0.04 s, sys: 0.05 s, total: 0.09 s Wall time: 0.09 s So it's really bad. I had a look at libguile/array-map.c. There are = three parts in there: [1] scm_ramapc(). This is a general array traversal function. It does = linearization, so the (array-copy! a b) call above should resolve to a = single call to racp(). [2] array-copy!, array-fill!, array-map!, array-for-each, etc. These all = use scm_ramapc(). [3] a bunch of specializations scm_ra_sum, scm_ra_difference, and so on.=20= First, I think that all of [3] should be gone, it's dead code. This is = the first patch. Second, array-map!, array-for-each cons on each application of proc. The = quick & dirty solution is to add 1-arg, 2-args, etc. cases to ramap(), = rafe(). array-index-map! does its own traversal and can't be linearized, = so that can't be fixed as easily. There are weirdo cases. For example = array-equal? calls array_compare that recurses on itself down to the = last rank. This means that there's a function call on each and every = array element. I don't know whether fixing these problems is worthwhile, or the whole = thing should be rewritten, maybe with a different approach. Either go to = Scheme where we have macros and can inline the inner loops, or use a = code generator to generate fixed rank cases, etc. Third, none of the above are causing the slowness of array-copy!. I = noticed that there's a double indirection in racp(). The second patch = removes it. Actually this double indirection goes on all over = array-map.c and I don't understand why it's needed... It's only a bit faster than before, though: scheme@(guile-user)> (define s "1234567890") scheme@(guile-user)> (define t (make-shared-array s (lambda (i j) (list = j)) 1000000 10)) scheme@(guile-user)> (define a (make-typed-array 'a *unspecified* = 1000000 10)) scheme@(guile-user)> (define b (make-typed-array 'a *unspecified* = 1000000 10)) scheme@(guile-user)> ,time (array-copy! t a) ;; 1.187000s real time, 1.190000s run time. 0.000000s spent in GC. scheme@(guile-user)> ,time (array-copy! a b) ;; 1.107000s real time, 1.110000s run time. 0.000000s spent in GC. scheme@(guile-user)>=20 There's the overhead of impl->, etc. I'm thinking that one can do a = direct memory copy when the array types are the same, or even call = memcpy() when the strides allow. I think these should be relatively = common cases. Regards, Daniel --Apple-Mail-133--17724916 Content-Disposition: attachment; filename=0001-Remove-dead-code-in-array-map.c.patch Content-Type: application/octet-stream; name="0001-Remove-dead-code-in-array-map.c.patch" Content-Transfer-Encoding: quoted-printable =46rom=203ab911215c98d6c3a018755439dda59cd5c0ed40=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniel=20Llorens=20=0A= Date:=20Mon,=201=20Apr=202013=2017:16:15=20+0200=0ASubject:=20[PATCH=20= 1/2]=20Remove=20dead=20code=20in=20array-map.c=0A=0A*=20array-map.h,=20= array-map.c:=20remove=20scm_ra_eqp,=20ra_compare,=20scm_ra_lessp,=0A=20=20= scm_ra_leqp,=20scm_ra_grp,=20scm_ra_greqp,=20scm_ra_sum,=20= scm_ra_difference,=0A=20=20scm_ra_product,=20scm_ra_divide,=20= scm_array_identity.=0A---=0A=20libguile/array-map.c=20|=20244=20= ---------------------------------------------------=0A=20= libguile/array-map.h=20|=20=2010=20---=0A=202=20files=20changed,=20254=20= deletions(-)=0A=0Adiff=20--git=20a/libguile/array-map.c=20= b/libguile/array-map.c=0Aindex=20d4da152..8c60f34=20100644=0A---=20= a/libguile/array-map.c=0A+++=20b/libguile/array-map.c=0A@@=20-385,252=20= +385,8=20@@=20SCM_DEFINE=20(scm_array_copy_x,=20"array-copy!",=202,=200,=20= 0,=0A=20}=0A=20#undef=20FUNC_NAME=0A=20=0A-/*=20Functions=20callable=20= by=20ARRAY-MAP!=20*/=0A-=0A-=0A-int=0A-scm_ra_eqp=20(SCM=20ra0,=20SCM=20= ras)=0A-{=0A-=20=20SCM=20ra1=20=3D=20SCM_CAR=20(ras),=20ra2=20=3D=20= SCM_CAR=20(SCM_CDR=20(ras));=0A-=20=20scm_t_array_handle=20ra0_handle;=0A= -=20=20scm_t_array_dim=20*ra0_dims;=0A-=20=20size_t=20n;=0A-=20=20= ssize_t=20inc0;=0A-=20=20size_t=20i0=20=3D=200;=0A-=20=20unsigned=20long=20= i1=20=3D=20SCM_I_ARRAY_BASE=20(ra1),=20i2=20=3D=20SCM_I_ARRAY_BASE=20= (ra2);=0A-=20=20long=20inc1=20=3D=20SCM_I_ARRAY_DIMS=20(ra1)->inc;=0A-=20= =20long=20inc2=20=3D=20SCM_I_ARRAY_DIMS=20(ra1)->inc;=0A-=20=20ra1=20=3D=20= SCM_I_ARRAY_V=20(ra1);=0A-=20=20ra2=20=3D=20SCM_I_ARRAY_V=20(ra2);=0A-=0A= -=20=20scm_array_get_handle=20(ra0,=20&ra0_handle);=0A-=20=20ra0_dims=20= =3D=20scm_array_handle_dims=20(&ra0_handle);=0A-=20=20n=20=3D=20= ra0_dims[0].ubnd=20-=20ra0_dims[0].lbnd=20+=201;=0A-=20=20inc0=20=3D=20= ra0_dims[0].inc;=0A-=0A-=20=20{=0A-=20=20=20=20for=20(;=20n--=20>=200;=20= i0=20+=3D=20inc0,=20i1=20+=3D=20inc1,=20i2=20+=3D=20inc2)=0A-=20=20=20=20= =20=20if=20(scm_is_true=20(scm_array_handle_ref=20(&ra0_handle,=20i0)))=0A= -=09if=20(!scm_is_eq=20(GVREF=20(ra1,=20i1),=20GVREF=20(ra2,=20i2)))=0A-=09= =20=20scm_array_handle_set=20(&ra0_handle,=20i0,=20SCM_BOOL_F);=0A-=20=20= }=0A-=0A-=20=20scm_array_handle_release=20(&ra0_handle);=0A-=20=20return=20= 1;=0A-}=0A-=0A-/*=20opt=200=20means=20<,=20nonzero=20means=20>=3D=20*/=0A= =20=0A=20static=20int=0A-ra_compare=20(SCM=20ra0,=20SCM=20ra1,=20SCM=20= ra2,=20int=20opt)=0A-{=0A-=20=20scm_t_array_handle=20ra0_handle;=0A-=20=20= scm_t_array_dim=20*ra0_dims;=0A-=20=20size_t=20n;=0A-=20=20ssize_t=20= inc0;=0A-=20=20size_t=20i0=20=3D=200;=0A-=20=20unsigned=20long=20i1=20=3D=20= SCM_I_ARRAY_BASE=20(ra1),=20i2=20=3D=20SCM_I_ARRAY_BASE=20(ra2);=0A-=20=20= long=20inc1=20=3D=20SCM_I_ARRAY_DIMS=20(ra1)->inc;=0A-=20=20long=20inc2=20= =3D=20SCM_I_ARRAY_DIMS=20(ra1)->inc;=0A-=20=20ra1=20=3D=20SCM_I_ARRAY_V=20= (ra1);=0A-=20=20ra2=20=3D=20SCM_I_ARRAY_V=20(ra2);=0A-=0A-=20=20= scm_array_get_handle=20(ra0,=20&ra0_handle);=0A-=20=20ra0_dims=20=3D=20= scm_array_handle_dims=20(&ra0_handle);=0A-=20=20n=20=3D=20= ra0_dims[0].ubnd=20-=20ra0_dims[0].lbnd=20+=201;=0A-=20=20inc0=20=3D=20= ra0_dims[0].inc;=0A-=0A-=20=20{=0A-=20=20=20=20for=20(;=20n--=20>=200;=20= i0=20+=3D=20inc0,=20i1=20+=3D=20inc1,=20i2=20+=3D=20inc2)=0A-=20=20=20=20= =20=20if=20(scm_is_true=20(scm_array_handle_ref=20(&ra0_handle,=20i0)))=0A= -=09if=20(opt=20?=0A-=09=20=20=20=20scm_is_true=20(scm_less_p=20(GVREF=20= (ra1,=20i1),=20GVREF=20(ra2,=20i2)))=20:=0A-=09=20=20=20=20scm_is_false=20= (scm_less_p=20(GVREF=20(ra1,=20i1),=20GVREF=20(ra2,=20i2))))=0A-=09=20=20= scm_array_handle_set=20(&ra0_handle,=20i0,=20SCM_BOOL_F);=0A-=20=20}=0A-=0A= -=20=20scm_array_handle_release=20(&ra0_handle);=0A-=20=20return=201;=0A= -}=0A-=0A-=0A-=0A-int=0A-scm_ra_lessp=20(SCM=20ra0,=20SCM=20ras)=0A-{=0A= -=20=20return=20ra_compare=20(ra0,=20SCM_CAR=20(ras),=20SCM_CAR=20= (SCM_CDR=20(ras)),=200);=0A-}=0A-=0A-=0A-int=0A-scm_ra_leqp=20(SCM=20= ra0,=20SCM=20ras)=0A-{=0A-=20=20return=20ra_compare=20(ra0,=20SCM_CAR=20= (SCM_CDR=20(ras)),=20SCM_CAR=20(ras),=201);=0A-}=0A-=0A-=0A-int=0A= -scm_ra_grp=20(SCM=20ra0,=20SCM=20ras)=0A-{=0A-=20=20return=20ra_compare=20= (ra0,=20SCM_CAR=20(SCM_CDR=20(ras)),=20SCM_CAR=20(ras),=200);=0A-}=0A-=0A= -=0A-int=0A-scm_ra_greqp=20(SCM=20ra0,=20SCM=20ras)=0A-{=0A-=20=20return=20= ra_compare=20(ra0,=20SCM_CAR=20(ras),=20SCM_CAR=20(SCM_CDR=20(ras)),=20= 1);=0A-}=0A-=0A-=0A-int=0A-scm_ra_sum=20(SCM=20ra0,=20SCM=20ras)=0A-{=0A= -=20=20long=20n=20=3D=20SCM_I_ARRAY_DIMS=20(ra0)->ubnd=20-=20= SCM_I_ARRAY_DIMS=20(ra0)->lbnd=20+=201;=0A-=20=20unsigned=20long=20i0=20= =3D=20SCM_I_ARRAY_BASE=20(ra0);=0A-=20=20long=20inc0=20=3D=20= SCM_I_ARRAY_DIMS=20(ra0)->inc;=0A-=20=20ra0=20=3D=20SCM_I_ARRAY_V=20= (ra0);=0A-=20=20if=20(!scm_is_null(ras))=0A-=20=20=20=20{=0A-=20=20=20=20= =20=20SCM=20ra1=20=3D=20SCM_CAR=20(ras);=0A-=20=20=20=20=20=20unsigned=20= long=20i1=20=3D=20SCM_I_ARRAY_BASE=20(ra1);=0A-=20=20=20=20=20=20long=20= inc1=20=3D=20SCM_I_ARRAY_DIMS=20(ra1)->inc;=0A-=20=20=20=20=20=20ra1=20=3D= =20SCM_I_ARRAY_V=20(ra1);=0A-=20=20=20=20=20=20switch=20(SCM_TYP7=20= (ra0)=20=3D=3D=20SCM_TYP7=20(ra1)=20?=20SCM_TYP7=20(ra0)=20:=200)=0A-=09= {=0A-=09default:=0A-=09=20=20{=0A-=09=20=20=20=20for=20(;=20n--=20>=200;=20= i0=20+=3D=20inc0,=20i1=20+=3D=20inc1)=0A-=09=20=20=20=20=20=20GVSET=20= (ra0,=20i0,=20scm_sum=20(GVREF(ra0,=20i0),=20GVREF(ra1,=20i1)));=0A-=09=20= =20=20=20break;=0A-=09=20=20}=0A-=09}=0A-=20=20=20=20}=0A-=20=20return=20= 1;=0A-}=0A-=0A-=0A-=0A-int=0A-scm_ra_difference=20(SCM=20ra0,=20SCM=20= ras)=0A-{=0A-=20=20long=20n=20=3D=20SCM_I_ARRAY_DIMS=20(ra0)->ubnd=20-=20= SCM_I_ARRAY_DIMS=20(ra0)->lbnd=20+=201;=0A-=20=20unsigned=20long=20i0=20= =3D=20SCM_I_ARRAY_BASE=20(ra0);=0A-=20=20long=20inc0=20=3D=20= SCM_I_ARRAY_DIMS=20(ra0)->inc;=0A-=20=20ra0=20=3D=20SCM_I_ARRAY_V=20= (ra0);=0A-=20=20if=20(scm_is_null=20(ras))=0A-=20=20=20=20{=0A-=20=20=20=20= =20=20switch=20(SCM_TYP7=20(ra0))=0A-=09{=0A-=09default:=0A-=09=20=20{=0A= -=09=20=20=20=20for=20(;=20n--=20>=200;=20i0=20+=3D=20inc0)=0A-=09=20=20=20= =20=20=20GVSET=20(ra0,=20i0,=20scm_difference=20(GVREF(ra0,=20i0),=20= SCM_UNDEFINED));=0A-=09=20=20=20=20break;=0A-=09=20=20}=0A-=09}=0A-=20=20= =20=20}=0A-=20=20else=0A-=20=20=20=20{=0A-=20=20=20=20=20=20SCM=20ra1=20= =3D=20SCM_CAR=20(ras);=0A-=20=20=20=20=20=20unsigned=20long=20i1=20=3D=20= SCM_I_ARRAY_BASE=20(ra1);=0A-=20=20=20=20=20=20long=20inc1=20=3D=20= SCM_I_ARRAY_DIMS=20(ra1)->inc;=0A-=20=20=20=20=20=20ra1=20=3D=20= SCM_I_ARRAY_V=20(ra1);=0A-=20=20=20=20=20=20switch=20(SCM_TYP7=20(ra0)=20= =3D=3D=20SCM_TYP7=20(ra1)=20?=20SCM_TYP7=20(ra0)=20:=200)=0A-=09{=0A-=09= default:=0A-=09=20=20{=0A-=09=20=20=20=20for=20(;=20n--=20>=200;=20i0=20= +=3D=20inc0,=20i1=20+=3D=20inc1)=0A-=09=20=20=20=20=20=20GVSET=20(ra0,=20= i0,=20scm_difference=20(GVREF=20(ra0,=20i0),=0A-=09=09=09=09=09=20=20=20=20= =20=20GVREF=20(ra1,=20i1)));=0A-=09=20=20=20=20break;=0A-=09=20=20}=0A-=09= }=0A-=20=20=20=20}=0A-=20=20return=201;=0A-}=0A-=0A-=0A-=0A-int=0A= -scm_ra_product=20(SCM=20ra0,=20SCM=20ras)=0A-{=0A-=20=20long=20n=20=3D=20= SCM_I_ARRAY_DIMS=20(ra0)->ubnd=20-=20SCM_I_ARRAY_DIMS=20(ra0)->lbnd=20+=20= 1;=0A-=20=20unsigned=20long=20i0=20=3D=20SCM_I_ARRAY_BASE=20(ra0);=0A-=20= =20long=20inc0=20=3D=20SCM_I_ARRAY_DIMS=20(ra0)->inc;=0A-=20=20ra0=20=3D=20= SCM_I_ARRAY_V=20(ra0);=0A-=20=20if=20(!scm_is_null=20(ras))=0A-=20=20=20=20= {=0A-=20=20=20=20=20=20SCM=20ra1=20=3D=20SCM_CAR=20(ras);=0A-=20=20=20=20= =20=20unsigned=20long=20i1=20=3D=20SCM_I_ARRAY_BASE=20(ra1);=0A-=20=20=20= =20=20=20long=20inc1=20=3D=20SCM_I_ARRAY_DIMS=20(ra1)->inc;=0A-=20=20=20=20= =20=20ra1=20=3D=20SCM_I_ARRAY_V=20(ra1);=0A-=20=20=20=20=20=20switch=20= (SCM_TYP7=20(ra0)=20=3D=3D=20SCM_TYP7=20(ra1)=20?=20SCM_TYP7=20(ra0)=20:=20= 0)=0A-=09{=0A-=09default:=0A-=09=20=20{=0A-=09=20=20=20=20for=20(;=20n--=20= >=200;=20i0=20+=3D=20inc0,=20i1=20+=3D=20inc1)=0A-=09=20=20=20=20=20=20= GVSET=20(ra0,=20i0,=20scm_product=20(GVREF=20(ra0,=20i0),=0A-=09=09=09=09= =09=20=20=20GVREF=20(ra1,=20i1)));=0A-=09=20=20}=0A-=09}=0A-=20=20=20=20= }=0A-=20=20return=201;=0A-}=0A-=0A-=0A-int=0A-scm_ra_divide=20(SCM=20= ra0,=20SCM=20ras)=0A-{=0A-=20=20long=20n=20=3D=20SCM_I_ARRAY_DIMS=20= (ra0)->ubnd=20-=20SCM_I_ARRAY_DIMS=20(ra0)->lbnd=20+=201;=0A-=20=20= unsigned=20long=20i0=20=3D=20SCM_I_ARRAY_BASE=20(ra0);=0A-=20=20long=20= inc0=20=3D=20SCM_I_ARRAY_DIMS=20(ra0)->inc;=0A-=20=20ra0=20=3D=20= SCM_I_ARRAY_V=20(ra0);=0A-=20=20if=20(scm_is_null=20(ras))=0A-=20=20=20=20= {=0A-=20=20=20=20=20=20switch=20(SCM_TYP7=20(ra0))=0A-=09{=0A-=09= default:=0A-=09=20=20{=0A-=09=20=20=20=20for=20(;=20n--=20>=200;=20i0=20= +=3D=20inc0)=0A-=09=20=20=20=20=20=20GVSET=20(ra0,=20i0,=20scm_divide=20= (GVREF=20(ra0,=20i0),=20SCM_UNDEFINED));=0A-=09=20=20=20=20break;=0A-=09=20= =20}=0A-=09}=0A-=20=20=20=20}=0A-=20=20else=0A-=20=20=20=20{=0A-=20=20=20= =20=20=20SCM=20ra1=20=3D=20SCM_CAR=20(ras);=0A-=20=20=20=20=20=20= unsigned=20long=20i1=20=3D=20SCM_I_ARRAY_BASE=20(ra1);=0A-=20=20=20=20=20= =20long=20inc1=20=3D=20SCM_I_ARRAY_DIMS=20(ra1)->inc;=0A-=20=20=20=20=20=20= ra1=20=3D=20SCM_I_ARRAY_V=20(ra1);=0A-=20=20=20=20=20=20switch=20= (SCM_TYP7=20(ra0)=20=3D=3D=20SCM_TYP7=20(ra1)=20?=20SCM_TYP7=20(ra0)=20:=20= 0)=0A-=09{=0A-=09default:=0A-=09=20=20{=0A-=09=20=20=20=20for=20(;=20n--=20= >=200;=20i0=20+=3D=20inc0,=20i1=20+=3D=20inc1)=0A-=09=20=20=20=20=20=20{=0A= -=09=09SCM=20res=20=3D=20=20scm_divide=20(GVREF=20(ra0,=20i0),=0A-=09=09=09= =09=20=20=20=20=20=20=20GVREF=20(ra1,=20i1));=0A-=09=09GVSET=20(ra0,=20= i0,=20res);=0A-=09=20=20=20=20=20=20}=0A-=09=20=20=20=20break;=0A-=09=20=20= }=0A-=09}=0A-=20=20=20=20}=0A-=20=20return=201;=0A-}=0A-=0A-=0A-int=0A= -scm_array_identity=20(SCM=20dst,=20SCM=20src)=0A-{=0A-=20=20return=20= racp=20(SCM_CAR=20(src),=20scm_cons=20(dst,=20SCM_EOL));=0A-}=0A-=0A-=0A= -=0A-static=20int=20=0A=20ramap=20(SCM=20ra0,=20SCM=20proc,=20SCM=20ras)=0A= =20{=0A=20=20=20long=20i=20=3D=20SCM_I_ARRAY_DIMS=20(ra0)->lbnd;=0Adiff=20= --git=20a/libguile/array-map.h=20b/libguile/array-map.h=0Aindex=20= 43d2a92..a50fcc5=20100644=0A---=20a/libguile/array-map.h=0A+++=20= b/libguile/array-map.h=0A@@=20-34,16=20+34,6=20@@=20SCM_API=20int=20= scm_ramapc=20(void=20*cproc,=20SCM=20data,=20SCM=20ra0,=20SCM=20lra,=0A=20= SCM_API=20int=20scm_array_fill_int=20(SCM=20ra,=20SCM=20fill,=20SCM=20= ignore);=0A=20SCM_API=20SCM=20scm_array_fill_x=20(SCM=20ra,=20SCM=20= fill);=0A=20SCM_API=20SCM=20scm_array_copy_x=20(SCM=20src,=20SCM=20dst);=0A= -SCM_API=20int=20scm_ra_eqp=20(SCM=20ra0,=20SCM=20ras);=0A-SCM_API=20int=20= scm_ra_lessp=20(SCM=20ra0,=20SCM=20ras);=0A-SCM_API=20int=20scm_ra_leqp=20= (SCM=20ra0,=20SCM=20ras);=0A-SCM_API=20int=20scm_ra_grp=20(SCM=20ra0,=20= SCM=20ras);=0A-SCM_API=20int=20scm_ra_greqp=20(SCM=20ra0,=20SCM=20ras);=0A= -SCM_API=20int=20scm_ra_sum=20(SCM=20ra0,=20SCM=20ras);=0A-SCM_API=20int=20= scm_ra_difference=20(SCM=20ra0,=20SCM=20ras);=0A-SCM_API=20int=20= scm_ra_product=20(SCM=20ra0,=20SCM=20ras);=0A-SCM_API=20int=20= scm_ra_divide=20(SCM=20ra0,=20SCM=20ras);=0A-SCM_API=20int=20= scm_array_identity=20(SCM=20src,=20SCM=20dst);=0A=20SCM_API=20SCM=20= scm_array_map_x=20(SCM=20ra0,=20SCM=20proc,=20SCM=20lra);=0A=20SCM_API=20= SCM=20scm_array_for_each=20(SCM=20proc,=20SCM=20ra0,=20SCM=20lra);=0A=20= SCM_API=20SCM=20scm_array_index_map_x=20(SCM=20ra,=20SCM=20proc);=0A--=20= =0A1.8.2=0A=0A= --Apple-Mail-133--17724916 Content-Disposition: attachment; filename=0002-Remove-double-indirection-in-element-access-in-array.patch Content-Type: application/octet-stream; name="0002-Remove-double-indirection-in-element-access-in-array.patch" Content-Transfer-Encoding: quoted-printable =46rom=20a38b0a98ed6093ee9ebe4ac60b4b6f9efbdcfdd5=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniel=20Llorens=20=0A= Date:=20Mon,=201=20Apr=202013=2018:43:58=20+0200=0ASubject:=20[PATCH=20= 2/2]=20Remove=20double=20indirection=20in=20element=20access=20in=0A=20= array-copy!=0A=0A*=20libguile/array-map.c:=20(racp):=20factor=20= scm_generalized_vector_ref,=0A=20=20scm_generalized_vector_set_x=20out=20= of=20the=20rank-1=20loop.=0A---=0A=20libguile/array-map.c=20|=2023=20= +++++++++++++----------=0A=201=20file=20changed,=2013=20insertions(+),=20= 10=20deletions(-)=0A=0Adiff=20--git=20a/libguile/array-map.c=20= b/libguile/array-map.c=0Aindex=208c60f34..767e97d=20100644=0A---=20= a/libguile/array-map.c=0A+++=20b/libguile/array-map.c=0A@@=20-350,21=20= +350,24=20@@=20scm_array_fill_int=20(SCM=20ra,=20SCM=20fill,=20SCM=20= ignore=20SCM_UNUSED)=0A=20#undef=20FUNC_NAME=0A=20=0A=20=0A-=0A-static=20= int=20=0A+static=20int=0A=20racp=20(SCM=20src,=20SCM=20dst)=0A=20{=0A=20=20= =20long=20n=20=3D=20(SCM_I_ARRAY_DIMS=20(src)->ubnd=20-=20= SCM_I_ARRAY_DIMS=20(src)->lbnd=20+=201);=0A-=20=20long=20inc_d,=20inc_s=20= =3D=20SCM_I_ARRAY_DIMS=20(src)->inc;=0A-=20=20unsigned=20long=20i_d,=20= i_s=20=3D=20SCM_I_ARRAY_BASE=20(src);=0A-=20=20dst=20=3D=20SCM_CAR=20= (dst);=0A-=20=20inc_d=20=3D=20SCM_I_ARRAY_DIMS=20(dst)->inc;=0A-=20=20= i_d=20=3D=20SCM_I_ARRAY_BASE=20(dst);=0A-=20=20src=20=3D=20SCM_I_ARRAY_V=20= (src);=0A-=20=20dst=20=3D=20SCM_I_ARRAY_V=20(dst);=0A+=20=20= scm_t_array_handle=20h_s,=20h_d;=0A+=20=20size_t=20i_s,=20i_d;=0A+=20=20= ssize_t=20inc_s,=20inc_d;=0A+=20=20dst=20=3D=20SCM_CAR(dst);=0A+=20=20= scm_generalized_vector_get_handle=20(SCM_I_ARRAY_V=20(src),=20&h_s);=0A+=20= =20scm_generalized_vector_get_handle=20(SCM_I_ARRAY_V=20(dst),=20&h_d);=0A= +=20=20i_s=20=3D=20h_s.base=20+=20h_s.dims[0].lbnd=20+=20= SCM_I_ARRAY_BASE=20(src)*h_s.dims[0].inc;=0A+=20=20i_d=20=3D=20h_d.base=20= +=20h_d.dims[0].lbnd=20+=20SCM_I_ARRAY_BASE=20(dst)*h_d.dims[0].inc;=0A+=20= =20inc_s=20=3D=20SCM_I_ARRAY_DIMS=20(src)->inc=20*=20h_s.dims[0].inc;=0A= +=20=20inc_d=20=3D=20SCM_I_ARRAY_DIMS=20(dst)->inc=20*=20= h_d.dims[0].inc;=0A=20=0A=20=20=20for=20(;=20n--=20>=200;=20i_s=20+=3D=20= inc_s,=20i_d=20+=3D=20inc_d)=0A-=20=20=20=20GVSET=20(dst,=20i_d,=20GVREF=20= (src,=20i_s));=0A+=20=20=20=20h_d.impl->vset=20(&h_d,=20i_d,=20= h_s.impl->vref=20(&h_s,=20i_s));=0A+=0A=20=20=20return=201;=0A=20}=0A=20=0A= --=20=0A1.8.2=0A=0A= --Apple-Mail-133--17724916 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail-133--17724916--