comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: ada lapack
Date: Sun, 19 Aug 2012 10:50:25 +0300
Date: 2012-08-19T10:50:25+03:00	[thread overview]
Message-ID: <a9bk61F46aU1@mid.individual.net> (raw)
In-Reply-To: <k0p957$4qq$1@speranza.aioe.org>

On 12-08-19 02:40 , Nasser M. Abbasi wrote:
> On 8/18/2012 6:16 PM, Niklas Holsti wrote:
>> On 12-08-19 01:51 , Nasser M. Abbasi wrote:
>>> On 8/18/2012 3:45 PM, Niklas Holsti wrote:
>>>
>>>>
>>>> I wonder why Ada_Lapack needs convention-Fortran matrices, when it does
>>>> not use any Fortran code.
>>>
>>> I assumed all along this is becuase Fortran matrix is column major
>>> order for storing the memory layout for the matrix. C uses row
>>> major, and I assumed Ada does also. Fortran and Matlab uses Column
>>> major.
>>
>> All true (well, I don't know about Matlab, but I can believe you).
>>
>> If Ada code passes matrices to Fortran code, the Fortran layout must be
>> used, since the Fortran code assumes it. (Or else the Fortran code sees
>> the matrix as transposed.)
>>
>> But the layout of a matrix in pure Ada code does not matter (except,
>> possibly, for execution time) if the code accesses the matrix in the
>> usual way with indices. The layout matters only if the matrix is
>> accessed in some nasty way, such as by using overlays (for X'address use
>> ...) as is now done in Ada_Lapack.
>>
> 
> 
> humm... but Fortran pre-compiled binary code will send back a matrix
> data to Ada. It is 2-ways. So, the binding is telling the compiler,
> or the rtl to rearrange the matrix data from lapack so that it is
> in row major so that when it is used in Ada, it is in the correct
> memory layout for Ada.

Ada_Lapack is entirely in Ada. It does not call any Fortran code. The
only reason for using Fortran layout is to let the Ada translation
access matrix rows and matrix columns using the same "recasting" tricks
as in the original Fortran code.

That is a hack, but it is also a conservative translation approach that
is defensible if the result is good for one's needs. But it has the
drawback that the Ada standard matrix types cannot be used, which means
that their operations (like "+") are not automatically available.

I think it would be possible to use the recasting tricks for matrices in
the Ada layout, but one would have to change the strides in several
places in the code -- that is, where the code now accesses columns with
stride 1, and rows with stride "column length", this would have to be
swapped so that rows are accessed with stride 1, and columns with stride
"row length".

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .



  reply	other threads:[~2012-08-19  7:50 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-15  6:16 ada lapack Leo Brewin
2012-08-16  3:34 ` Jerry
2012-08-17  6:25 ` Ada novice
2012-08-17  7:11   ` Leo Brewin
2012-08-17  7:42     ` Ada novice
2012-08-17  9:43       ` Niklas Holsti
2012-08-17 10:27         ` Ada novice
2012-08-17 11:08           ` Niklas Holsti
2012-08-17 11:33             ` Ada novice
2012-08-17 13:45               ` Leo Brewin
2012-08-17 14:11                 ` Marc C
2012-08-18 11:57                   ` Ada novice
2012-08-18 13:13                     ` Niklas Holsti
2012-08-18 13:48                       ` Ada novice
2012-08-18 15:22                         ` Nasser M. Abbasi
2012-08-18 16:33                           ` Ada novice
2012-08-18 17:32                             ` Simon Wright
2012-08-18 17:44                               ` Nasser M. Abbasi
2012-08-18 20:45                             ` Niklas Holsti
2012-08-18 21:46                               ` Simon Wright
2012-08-19  2:24                                 ` Leo Brewin
2012-08-19  5:39                                   ` Ada novice
2012-08-19  7:10                                     ` Leo Brewin
2012-08-19 13:02                                       ` Simon Wright
2012-08-20 14:05                                         ` Nasser M. Abbasi
2012-08-20 14:57                                           ` Simon Wright
2012-08-20 15:10                                             ` Nasser M. Abbasi
2012-08-20 18:09                                               ` Ada novice
2012-08-20 18:46                                             ` Nasser M. Abbasi
2012-08-20 15:03                                           ` Nasser M. Abbasi
2012-08-20 22:57                                             ` Simon Wright
2012-08-20 23:09                                               ` Nasser M. Abbasi
2012-08-20 23:31                                                 ` Simon Wright
2012-08-21 10:44                                             ` Simon Wright
2012-08-21 14:50                                               ` Nasser M. Abbasi
2012-08-18 22:51                               ` Nasser M. Abbasi
2012-08-18 23:16                                 ` Niklas Holsti
2012-08-18 23:40                                   ` Nasser M. Abbasi
2012-08-19  7:50                                     ` Niklas Holsti [this message]
2012-08-19  2:20                             ` Leo Brewin
2012-08-17 14:12                 ` Brian Drummond
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox