comp.lang.ada
 help / color / mirror / Atom feed
* BLAS
@ 2000-05-15  0:00 Duncan Sands
  2000-05-15  0:00 ` BLAS Robert A Duff
  0 siblings, 1 reply; 18+ messages in thread
From: Duncan Sands @ 2000-05-15  0:00 UTC (permalink / raw)
  To: bobduff, comp.lang.ada

I guess I should have made clear that the BLAS is a library, or rather
a collection of libraries, for basic matrix/vector operations written
in FORTRAN.  I say a collection of libraries because optimized versions
are available for many platforms (these are usually referred to as vendor
BLAS).  A reference implementation for the BLAS can be picked up from
www.netlib.org.  I am writing a binding to these libraries.

Anyway, on to Robert's comments:

Robert A Duff wrote:

>> Ada_Blas <- non generic package defining exceptions and other common stuff
>
>Why not plain BLAS?  I mean, one doesn't normally put "Ada_" at the
>front of everything written in Ada.

Well, I thought that people might want to instantiate the generic
packages as "BLAS", so I was trying to avoid this name.  It is
true that "Generic_BLAS" would be more in keeping with standard
usage.

>> generic
>>    type Float_Type is digits <>;
>>    type Matrix is array (Integer range <>, Integer range <>) of Float_Type'Base;
>> 
>> is rejected by GNAT.  
>
>On what grounds?  It looks legal to me...

GNAT says:
3.    type Matrix is array (Integer range <>, Integer range <>) of Float_Type'Base;
                     |
>>> only a subtype mark is allowed in a formal

The RM says (Generic Units - Formal Array Types): "The only form of
discrete_subtype_definition that is allowed within the declaration of
a generic formal (constrained) array subtype is a subtype_mark."

>>...I would like to do
>> 
>> generic
>>    type Float_Type is digits <>;
>>    type Base_Type is new Float_Type'Base;
>>    type Matrix is array (Integer range <>, Integer range <>) of Base_Type;
>
>I don't see why you want two float types.  Or is this just a workaround
>for the previous thing?

Yes, it is a workaround.

>> (2) Base_Type could have a range restriction.  Eg if I defined
>> type Base is new Float_Type'Base range 0.0 .. 1.0;
>> then this is fine for passing as the Base_Type parameter.  The
>> problem is that the Fortran procedures aren't going to respect the
>> range constraints, so after performing operations you may obtain
>> vectors/matrices with invalid components.  You could then check
>> (with the 'Valid attribute) if all components are ok, but this
>> would introduce heavy overheads.
>
>I don't see why you need 'Valid.  If there's a violation of a
>constraint, it will raise an exception -- it doesn't matter if it's
>inside a generic.  Or do I misunderstand what you're saying?

All the work is done by FORTRAN subroutines - and they are not going
to respect Ada range constraints.  One of the uses of the 'Valid
attribute described in the RM is to check results returned by
foreign language code.

>By the way, you could insist that the instance pass in an unconstrained
>subtype.  You could assert in the body that Float_Type'Base'First =
>Float_Type'First, and similarly for 'Last.

This is a good point.  In fact, I could allow any type to be passed and
only check for 'Valid results if the type was constrained.

>>...  Not checking is not in keeping
>> with the Ada philosophy!  By the way, I want Float_Type'Base because
>> it has no range constraints (cf Ada.Numerics.Generic_Elementary_Functions).
>
>Makes sense.  Maybe you're better off exporting the Matrix type, after
>all.  Hmm.

Well, the problem is that I also want to write a partial LAPACK binding.
There will be the same problem with that one.  It would be a pain to
have distinct BLAS and LAPACK vector and matrix types and have to keep
converting from one to the other...

Best wishes,

Duncan.







^ permalink raw reply	[flat|nested] 18+ messages in thread
* BLAS
@ 2000-05-12  0:00 Duncan Sands
  2000-05-12  0:00 ` BLAS Gautier
  0 siblings, 1 reply; 18+ messages in thread
From: Duncan Sands @ 2000-05-12  0:00 UTC (permalink / raw)
  To: Gautier De Montmollin

>Marvelous! When I find some time I'll use your binding.
>For now I'm using an excerpt, of course also with "digits <>"
>genericity for float type and with hastly conception - see below.
>Maybe the "BLAS_Precision" could be added as generic parametre
>for equilibirum with the generic "digits <>" ? Another solution
>would be to pass as generic:
>
> 1) the type you want to use,            type Float_Type is digits <>;
> 2) the type which you know is single,   type Single is digits <>;
> 3) the type which you know is double    type Double is digits <>;
>
>and automatically identify the type with the 'digits or another more
>subtle criterion. Surely for Ada 95, the Interface.Fortran package
>contains 2) and 3) so you can determine the "BLAS_Precision" only
>with 1) as generic, but then you'd lose the Ada 83 compatibility.

Dear Gautier, keeping Ada 83 compatibility seems problematic.
After all, the problem is not just with whether Float_Type
is single or double precision, but you also need to know
the size of Fortran_Integer, Character_Set and perhaps some
other stuff as well.  I notice that in your binding you
suppose that Fortran_Integer and Integer are the same...
There is also the problem of link names.  For example, if
I compile the BLAS with g77, then the link names have an
underscore appended, and I need to tell Ada about this.
Pragma Import can handle this, but can pragma Interface?

How important do you think it is to keep Ada 83 compatibility?

Best wishes,

Duncan.







^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2000-05-18  0:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <391BC1F5.DFB47045@maths.unine.ch>
2000-05-12  0:00 ` BLAS Duncan Sands
2000-05-12  0:00   ` BLAS Gautier
2000-05-12  0:00   ` BLAS Robert A Duff
2000-05-13  0:00   ` BLAS Larry Kilgallen
2000-05-14  0:00     ` BLAS Gautier
2000-05-15  0:00       ` BLAS Larry Kilgallen
2000-05-15  0:00         ` BLAS Gisle S�lensminde
2000-05-15  0:00       ` BLAS Gisle S�lensminde
2000-05-13  0:00   ` BLAS Robert Dewar
2000-05-15  0:00 BLAS Duncan Sands
2000-05-15  0:00 ` BLAS Robert A Duff
2000-05-15  0:00   ` BLAS Robert Dewar
2000-05-16  0:00     ` BLAS Robert A Duff
2000-05-17  0:00       ` BLAS Robert Dewar
2000-05-17  0:00         ` BLAS Robert A Duff
2000-05-18  0:00           ` BLAS Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
2000-05-12  0:00 BLAS Duncan Sands
2000-05-12  0:00 ` BLAS Gautier

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