Skip to content

Commit

Permalink
ada: Improve CUDA host-side and device-side binder support
Browse files Browse the repository at this point in the history
Binder-generated code is not allowed to use Ada2012 syntax. In order to
specify an aspect, a pragma must be used.

gcc/ada/

	* bindgen.adb: When the binder is invoked for the device, specify
	the CUDA_Global aspect for the adainit and adafinal procedures via
	a pragma instead of via an aspect_specification.
  • Loading branch information
swbaird authored and marc-adacore committed Sep 26, 2022
1 parent 6b8e3ee commit 37645e2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gcc/ada/bindgen.adb
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ package body Bindgen is
-- Text for aspect specifications (if any) given as part of the
-- Adainit and Adafinal spec declarations.

function Aspect_Text return String is
(if Enable_CUDA_Device_Expansion then " with CUDA_Global" else "");

----------------------------------
-- Interface_State Pragma Table --
----------------------------------
Expand Down Expand Up @@ -2644,10 +2641,11 @@ package body Bindgen is
end if;

WBI ("");
WBI (" procedure " & Ada_Init_Name.all & Aspect_Text & ";");
WBI (" procedure " & Ada_Init_Name.all & ";");
if Enable_CUDA_Device_Expansion then
WBI (" pragma Export (C, " & Ada_Init_Name.all &
", Link_Name => """ & Device_Ada_Init_Link_Name & """);");
WBI (" pragma CUDA_Global (" & Ada_Init_Name.all & ");");
else
WBI (" pragma Export (C, " & Ada_Init_Name.all & ", """ &
Ada_Init_Name.all & """);");
Expand All @@ -2662,11 +2660,12 @@ package body Bindgen is

if not Cumulative_Restrictions.Set (No_Finalization) then
WBI ("");
WBI (" procedure " & Ada_Final_Name.all & Aspect_Text & ";");
WBI (" procedure " & Ada_Final_Name.all & ";");

if Enable_CUDA_Device_Expansion then
WBI (" pragma Export (C, " & Ada_Final_Name.all &
", Link_Name => """ & Device_Ada_Final_Link_Name & """);");
WBI (" pragma CUDA_Global (" & Ada_Final_Name.all & ");");
else
WBI (" pragma Export (C, " & Ada_Final_Name.all & ", """ &
Ada_Final_Name.all & """);");
Expand Down

0 comments on commit 37645e2

Please sign in to comment.