ada: Rework CUDA host-side invocation of device-side elaboration code
authorSteve Baird <baird@adacore.com>
Fri, 14 Oct 2022 00:07:31 +0000 (17:07 -0700)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 7 Nov 2022 08:36:34 +0000 (09:36 +0100)
commitaa0e7d31a803f948504f8692c4ae48e3ba1b677b
tree7a82b4350c1fb82382de5fe668bf0fdc38c00476
parent7dee088c9db6a420b60379dd576493d12c055ffd
ada: Rework CUDA host-side invocation of device-side elaboration code

When the binder is invoked with a "-d_c" switch, add an argument to that
switch which is the library name on the device side; so "-d_c" becomes
"-d_c=some_library_name". This does not effect the case where "-d_c" is
specified as a switch for compilation (as opposed to binding). Use this
new piece of information in the code generated by the binder to invoke
elaboration code on the device side from the host side.

gcc/ada/

* opt.ads: Declare new string pointer variable, CUDA_Device_Library_Name.
Modify comments for existing Boolean variable Enable_CUDA_Device_Expansion.
* switch-b.adb: When "-d_c" switch is encountered, check that the next
character is an "'='; use the remaining characters to initialize
Opt.CUDA_Device_Library_Name.
* bindgen.adb: Remove (for now) most support for host-side invocation of
device-side finalization. Make use of the new CUDA_Device_Library_Name
in determining the string used to refer (on the host side) to the
device-side initialization procedure. Declare the placeholder routine
that is named in the CUDA_Execute pragma (and the CUDA_Register_Function
call) as an exported null procedure, rather than as an imported procedure.
It is not clear whether it is really necessary to specify the link-name
for this should-never-be-called subprogram on the host side, but for now it
shouldn't hurt to do so.
gcc/ada/bindgen.adb
gcc/ada/opt.ads
gcc/ada/switch-b.adb