comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Ada.Locales pseudo-string types
Date: Wed, 08 Aug 2012 16:05:54 +0200
Date: 2012-08-08T16:05:47+02:00	[thread overview]
Message-ID: <5022723b$0$6579$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <a8f17iF9j2U1@mid.individual.net>

On 08.08.12 13:35, Niklas Holsti wrote:
> In my professional area (worst-case execution-time analysis),
> compiler-generated implicit loops are often a problem, especially in Ada
> programs. A restriction identifier to forbid such loops (at least when
> the number of iterations is dynamic) could be useful here, and would let
> programmers choose between a restrictive or a permissive coding style.

Controlling the translation of array operations seems to be
a tricky business, with, apparently, many of the properties of
an Ada implementation being considered in addition to the
array itself. Maybe the pragmas would have to be rather
detailed?

In the following example, I get a plain loop for array assignment
only for a very specific array length, with an 8 bits component type,
even at very low optimization settings. The compiler seems to have
a rich repertoire from which to choose what to emit for assignments.

The assignment of array X to array Y has been isolated in
procedure Assign.

package Types is

   pragma Pure (Types);

   Does_Not_Unroll : constant := 129;
   --  Values below 129 will generate unrolled array assignment,
   --  four components at a time;
   --  Values 129 and above yield rep; movsq on Intel;
   --  Values 8193 and above will call _memcpy.

   type Idx is range 1 .. Does_Not_Unroll;
   type Vlu is mod 256;
   type Ary is array (Idx) of Vlu;

end Types;

with Ada.Numerics.Discrete_Random;
with Types;
package Bitmaker is new
  Ada.Numerics.Discrete_Random (Types.Vlu);

with Bitmaker;
with Types;  use Types;

procedure Hidden (Result : out Vlu) is

   G : Bitmaker.Generator;
   X, Y : Ary;

   procedure Assign is
   begin
      Y := X;
   end Assign;

begin
   for K in X'Range loop
      X (K) := Bitmaker.Random (G);
   end loop;

   Assign;

   declare
      Pick : constant Vlu := X (X'First);
      Position : constant Idx :=
	Idx'First + Idx'Min (Idx'Last - 1, Vlu'Pos (Pick));
   begin
      Result := Y (Position);
   end;
end Hidden;




  reply	other threads:[~2012-08-08 14:05 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-06 16:45 Ada.Locales pseudo-string types Marius Amado-Alves
2012-08-06 17:10 ` Marius Amado-Alves
2012-08-06 19:15   ` J-P. Rosen
2012-08-06 19:34     ` Simon Wright
2012-08-06 20:07       ` Marius Amado-Alves
2012-08-06 20:57         ` Simon Wright
2012-08-06 21:09           ` Vasiliy Molostov
2012-08-06 23:07             ` Adam Beneschan
2012-08-06 23:23               ` Vasiliy Molostov
2012-08-06 23:46                 ` Adam Beneschan
2012-08-07  1:17                   ` Vasiliy Molostov
2012-08-07  7:20               ` Dmitry A. Kazakov
2012-08-07  7:43               ` Jacob Sparre Andersen
2012-08-09 20:47                 ` Randy Brukardt
2012-08-07  8:44               ` Marius Amado-Alves
2012-08-07 13:14                 ` Marius Amado-Alves
2012-08-07 15:42                   ` Adam Beneschan
2012-08-07 18:22                     ` Marius Amado-Alves
2012-08-07 20:10                       ` Adam Beneschan
2012-08-07 20:42                         ` Marius Amado-Alves
2012-08-07 21:38                           ` Adam Beneschan
2012-08-08  7:04                           ` Niklas Holsti
2012-08-08  7:18                             ` Dmitry A. Kazakov
2012-08-08  7:37                               ` Niklas Holsti
2012-08-08  8:09                                 ` Dmitry A. Kazakov
2012-08-08 11:14                                   ` Niklas Holsti
2012-08-08 11:59                                     ` Dmitry A. Kazakov
2012-08-08 14:01                                       ` Niklas Holsti
2012-08-09  7:48                                         ` Dmitry A. Kazakov
2012-08-09  8:31                                           ` Niklas Holsti
2012-08-09 12:17                                             ` Dmitry A. Kazakov
2012-08-09 15:25                                               ` Niklas Holsti
2012-08-09 16:43                                                 ` Dmitry A. Kazakov
2012-08-08  8:28                                 ` J-P. Rosen
2012-08-08 11:35                                   ` Niklas Holsti
2012-08-08 14:05                                     ` Georg Bauhaus [this message]
2012-08-08  7:32                             ` J-P. Rosen
2012-08-08  8:17                               ` Niklas Holsti
2012-08-08  8:33                                 ` J-P. Rosen
2012-08-08 11:44                                   ` Niklas Holsti
2012-08-09 21:00                                   ` Randy Brukardt
2012-08-08  8:35                                 ` Dmitry A. Kazakov
2012-08-08  9:32                                   ` Marius Amado-Alves
2012-08-08 10:11                                     ` Dmitry A. Kazakov
2012-08-08 11:28                                       ` Marius Amado-Alves
2012-08-08 11:30                                         ` Marius Amado-Alves
2012-08-08 11:35                                       ` Marius Amado-Alves
2012-08-08 12:24                                         ` Dmitry A. Kazakov
2012-08-08 11:52                                   ` Niklas Holsti
2012-08-08 13:21                                     ` Dmitry A. Kazakov
2012-08-08  9:07                             ` Marius Amado-Alves
2012-08-07 20:43                         ` Marius Amado-Alves
2012-08-07 21:59                   ` Robert A Duff
2012-08-07 22:19                     ` Adam Beneschan
2012-08-08  0:37                       ` Robert A Duff
2012-08-07 15:26                 ` Adam Beneschan
2012-08-07 18:07                   ` Marius Amado-Alves
2012-08-07 17:51       ` Simon Wright
2012-08-06 20:00     ` Marius Amado-Alves
2012-08-06 19:49   ` Jacob Sparre Andersen
2012-08-06 20:11     ` Marius Amado-Alves
2012-08-06 17:37 ` Michael Rohan
2012-08-06 18:23   ` Marius Amado-Alves
2012-08-06 19:36     ` Michael Rohan
2012-08-09 21:15   ` Randy Brukardt
2012-08-07  5:57 ` Jeffrey R. Carter
2012-08-07 15:46   ` Adam Beneschan
2012-08-07 17:51     ` Jeffrey R. Carter
2012-08-09 21:17       ` Randy Brukardt
replies disabled

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