From: vincent.diemunsch@gmail.com
Subject: Re: GNAT vs Matlab - operation on multidimensional complex matrices
Date: Wed, 29 Apr 2020 14:08:05 -0700 (PDT)
Date: 2020-04-29T14:08:05-07:00 [thread overview]
Message-ID: <5abd8196-b4cf-4394-9e5a-af034797f785@googlegroups.com> (raw)
In-Reply-To: <ly8sjg49h0.fsf@pushface.org>
Le mardi 31 mars 2020 21:20:45 UTC+2, Simon Wright a écrit :
> Shark8 <onewingedshark@gmail.com> writes:
>
> > Ok then; the following should have convention Fortran IIRC:
> >
> > type tCubeReal is array (1..NumChannels, 1..NumAngles, 1..NumRanges) of mReal
> > with Convention => Fortran;
>
> I wondered about this; the code ran considerably slower with Convention
> => Fortran.
In Row Major (Convention Fortran) one needs to iterate on the first dimension, then the second and finally the third, to stay on contiguous regions in memory (and hence in the cache). So the loop must put the first dimension in the center :
for p in M’Range(3) loop
for n in M’Range (2) loop
for m in M’Range (1) loop
... M(m, n, p)
This is somehow counter-intuitive. But Row Major (like Little-endian with which it is closely related) has more properties (like extracting a submatrix or conforming to classical linear algebra) and is therefore preferred by scientists.
Regards,
Vincent
next prev parent reply other threads:[~2020-04-29 21:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-23 23:16 GNAT vs Matlab - operation on multidimensional complex matrices darek
2020-03-24 2:07 ` johnscpg
2020-03-24 6:40 ` J-P. Rosen
2020-03-24 9:37 ` Jeffrey R. Carter
2020-03-24 14:55 ` darek
2020-03-24 15:44 ` johnscpg
2020-03-31 17:25 ` Shark8
2020-03-31 19:20 ` Simon Wright
2020-03-31 19:54 ` Shark8
2020-04-29 21:08 ` vincent.diemunsch [this message]
2020-04-01 11:01 ` darek
2020-04-01 15:01 ` J-P. Rosen
2020-04-01 16:39 ` darek
2020-04-01 17:15 ` J-P. Rosen
2020-03-31 20:05 ` Shark8
2020-03-31 20:51 ` Jeffrey R. Carter
2020-06-08 17:42 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox