Skip to content

Commit f425cc3

Browse files
authored
Merge pull request #84 from AdaCore/review_tutorial
Review tutorial
2 parents 2ec8cc2 + ab3defd commit f425cc3

File tree

7 files changed

+17
-20
lines changed

7 files changed

+17
-20
lines changed

doc/tutorial.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ second to make the next steps meaningful.
5858
This code is currently fully native and single treaded. We're going to offload
5959
the computation to the GPU.
6060

61-
Open ``src/common/kernel.ads``. You'll see the specification of ``Native_Complex_Computation``:
61+
Open ``src/common/kernel.ads``. You'll see the specification of ``Complex_Computation``:
6262

6363
.. code-block:: ada
6464
65-
procedure Native_Complex_Computation
65+
procedure Complex_Computation
6666
(A : Float_Array;
6767
B : Float_Array;
6868
C : out Float_Array;
@@ -86,8 +86,8 @@ Introduce a new pointer type in the ``Kernel`` package:
8686
type Array_Device_Access is access Float_Array
8787
with Designated_Storage_Model => CUDA.Storage_Models.Model;
8888
89-
Note that this pointer has to be pool specific - e.g. it can't have the ``all``
90-
Ada reservered word. That means that it conceptually points to a specific
89+
Note that this pointer has to be pool specific - e.g. it can't be an ``access all``.
90+
That means that it conceptually points to a specific
9191
pool of data - the device memory - and that conversions with other
9292
pointers types are not allowed.
9393

@@ -139,7 +139,7 @@ and thread index:
139139
Note that these are expressed in terms of Interfaces.C.int, so the result
140140
needs to be converted explicly to Integer.
141141

142-
From there, the call to ``Native_Complex_Computation`` is trivial. The whole
142+
From there, the call to ``Complex_Computation`` is trivial. The whole
143143
kernel should now look like:
144144

145145
.. code-block:: ada
@@ -151,7 +151,7 @@ kernel should now look like:
151151
is
152152
I : Integer := Integer (Block_Dim.X * Block_IDx.X + Thread_IDx.X);
153153
begin
154-
Native_Complex_Computation (A.all, B.all, C.all, I);
154+
Complex_Computation (A.all, B.all, C.all, I);
155155
end Device_Complex_Computation;
156156
157157
We're done with the kernel - let's move to the host code. Open ``src/host/main.adb``.

tutorial/src/common/kernel.adb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ with Interfaces.C; use Interfaces.C;
33

44
package body Kernel is
55

6-
procedure Native_Complex_Computation
7-
(A : Float_Array;
8-
B : Float_Array;
9-
C : out Float_Array;
10-
I : Integer)
6+
procedure Complex_Computation
7+
(A : Float_Array; B : Float_Array; C : out Float_Array; I : Integer)
118
is
129
begin
1310
if I < A'Length then
@@ -17,6 +14,6 @@ package body Kernel is
1714
end loop;
1815
end loop;
1916
end if;
20-
end Native_Complex_Computation;
17+
end Complex_Computation;
2118

2219
end Kernel;

tutorial/src/common/kernel.ads

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ with CUDA.Storage_Models; use CUDA.Storage_Models;
44

55
package Kernel is
66

7-
type Float_Array is array (Integer range <>) of Float;
7+
type Float_Array is array (Integer range <>) of Float;
88

9-
procedure Native_Complex_Computation
9+
procedure Complex_Computation
1010
(A : Float_Array;
1111
B : Float_Array;
1212
C : out Float_Array;

tutorial/src/host/main.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ begin
4848
T0 := Clock;
4949

5050
for I in 0 .. Num_Elements - 1 loop
51-
Native_Complex_Computation (H_A.all, H_B.all, H_C.all, I);
51+
Complex_Computation (H_A.all, H_B.all, H_C.all, I);
5252
end loop;
5353

5454
Lapsed := Clock - T0;

tutorial/src_completed/common/kernel.adb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ with Interfaces.C; use Interfaces.C;
33

44
package body Kernel is
55

6-
procedure Native_Complex_Computation
6+
procedure Complex_Computation
77
(A : Float_Array;
88
B : Float_Array;
99
C : out Float_Array;
@@ -17,7 +17,7 @@ package body Kernel is
1717
end loop;
1818
end loop;
1919
end if;
20-
end Native_Complex_Computation;
20+
end Complex_Computation;
2121

2222
procedure Device_Complex_Computation
2323
(A : Array_Device_Access;
@@ -26,7 +26,7 @@ package body Kernel is
2626
is
2727
I : Integer := Integer (Block_Dim.X * Block_IDx.X + Thread_IDx.X);
2828
begin
29-
Native_Complex_Computation (A.all, B.all, C.all, I);
29+
Complex_Computation (A.all, B.all, C.all, I);
3030
end Device_Complex_Computation;
3131

3232
end Kernel;

tutorial/src_completed/common/kernel.ads

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package Kernel is
99
type Array_Device_Access is access Float_Array
1010
with Designated_Storage_Model => CUDA.Storage_Models.Model;
1111

12-
procedure Native_Complex_Computation
12+
procedure Complex_Computation
1313
(A : Float_Array;
1414
B : Float_Array;
1515
C : out Float_Array;

tutorial/src_completed/host/main.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ begin
5555
T0 := Clock;
5656

5757
for I in 0 .. Num_Elements - 1 loop
58-
Native_Complex_Computation (H_A.all, H_B.all, H_C.all, I);
58+
Complex_Computation (H_A.all, H_B.all, H_C.all, I);
5959
end loop;
6060

6161
Lapsed := Clock - T0;

0 commit comments

Comments
 (0)