From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a40f6d312191b68e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.97.198 with SMTP id ec6mr8282197wib.5.1356811182524; Sat, 29 Dec 2012 11:59:42 -0800 (PST) Path: i11ni335078wiw.0!nntp.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: A thicker binding for Lapack Date: Sat, 29 Dec 2012 19:59:46 +0000 Organization: A noiseless patient Spider Message-ID: References: <9242b176-7050-46f8-a65d-6091aa4b2de8@googlegroups.com> <0bc6a851-8eea-4279-b616-3f7895049d4b@googlegroups.com> <6638b519-7fad-4908-9b80-3a43e6a0b8f7@googlegroups.com> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="585248293da7adcafb924c79c19cf5ec"; logging-data="2998"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oKgqtl+COz8MI11CAs/Q2VCHztgtRgfo=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (darwin) Cancel-Lock: sha1:p0moFW29qLFnpj9m9ueCIzxn7qA= sha1:/PSmszjfb2hznTRrMWZe+MRT6Ko= Content-Type: text/plain Date: 2012-12-29T19:59:46+00:00 List-Id: jpwoodruff@gmail.com writes: > Conclusion: transpose appears necessary. For info, the compiler (well, GNAT) will automatically transpose when doing assignment between arrays with different conventions. And it's quicker (not by very much at -O2, though). with Ada.Calendar; use Ada.Calendar; with Ada.Text_IO; use Ada.Text_IO; with Ada.Numerics.Float_Random; with Interfaces.Fortran; with System.Generic_Array_Operations; procedure Sauvage_Timing is package BLAS is -- Copied from old GNAT Interfaces.Fortran.BLAS. -- Vector types type Real_Vector is array (Integer range <>) of Interfaces.Fortran.Real; type Complex_Vector is array (Integer range <>) of Interfaces.Fortran.Complex; type Double_Precision_Vector is array (Integer range <>) of Interfaces.Fortran.Double_Precision; type Double_Complex_Vector is array (Integer range <>) of Interfaces.Fortran.Double_Complex; -- Matrix types type Real_Matrix is array (Integer range <>, Integer range <>) of Interfaces.Fortran.Real; type Double_Precision_Matrix is array (Integer range <>, Integer range <>) of Interfaces.Fortran.Double_Precision; type Complex_Matrix is array (Integer range <>, Integer range <>) of Interfaces.Fortran.Complex; type Double_Complex_Matrix is array (Integer range <>, Integer range <>) of Interfaces.Fortran.Double_Complex; end BLAS; procedure Transpose is new System.Generic_Array_Operations.Transpose (Scalar => Interfaces.Fortran.Double_Precision'Base, Matrix => BLAS.Double_Precision_Matrix); type Double_Precision_Matrix is array (Integer range <>, Integer range <>) of Interfaces.Fortran.Double_Precision; pragma Convention (Fortran, Double_Precision_Matrix); A, B : BLAS.Double_Precision_Matrix (1 .. 100, 1 .. 100); C : Double_Precision_Matrix (1 .. 100, 1 .. 100); pragma Volatile (B); pragma Volatile (C); Gen : Ada.Numerics.Float_Random.Generator; Start, Finish : Time; use type Interfaces.Fortran.Double_Precision; begin Ada.Numerics.Float_Random.Reset (Gen); for J in A'Range (1) loop for K in A'Range (2) loop A (J, K) := Interfaces.Fortran.Double_Precision (J * K) * Interfaces.Fortran.Double_Precision (Ada.Numerics.Float_Random.Random (Gen)); end loop; end loop; Start := Clock; for J in 1 .. 100 loop Transpose (A, B); end loop; Finish := Clock; Put_Line ("Transpose took " & Duration'Image (Finish - Start)); Start := Clock; for J in 1 .. 100 loop C := Double_Precision_Matrix (A); end loop; Finish := Clock; Put_Line ("Assignment took" & Duration'Image (Finish - Start)); declare Same : Boolean := True; begin for J in 1 .. 100 loop for K in 1 .. 100 loop if B (J, K) /= C (K, J) then Same := False; end if; end loop; end loop; Put_Line ("B = ~C: " & Same'Img); end; end Sauvage_Timing;