diff options
author | Ghjuvan Lacambre <lacambre@adacore.com> | 2021-09-14 10:49:08 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-05-13 08:04:43 +0000 |
commit | a2cff9e9af15b179ff7a2c7e147e88ec8ce52936 (patch) | |
tree | 875ff769e9ec405dc2eaca642428b1b63b5009d8 /gcc/ada/gnat_cuda.ads | |
parent | e3584606f5cb9bfc717a19e96731bc35ea11a40e (diff) | |
download | gcc-a2cff9e9af15b179ff7a2c7e147e88ec8ce52936.zip gcc-a2cff9e9af15b179ff7a2c7e147e88ec8ce52936.tar.gz gcc-a2cff9e9af15b179ff7a2c7e147e88ec8ce52936.tar.bz2 |
[Ada] CUDA: use binder to generate kernel-registration code
Compiling CUDA code requires compiling code for the host (= CPU) and for
the device (= GPU). Device code is embedded into the host code and must
be registered with the CUDA runtime by the host.
The original approach we took for registering CUDA kernels was to
generate the registration-code on a unit basis, i.e. each unit took care
of registering its own kernels. Unfortunately, this makes linking
kernels and device functions that belong to different units much harder.
We thus rework this approach in order to have GNAT generate kernel names
in ALI files. The binder reads the ALI files and generates kernel
registration code for each of the kernels found in ALI files.
gcc/ada/
* ali.adb: Introduce new 'K' line in ALI files, used to
represent CUDA kernel entries.
* ali.ads: Create new CUDA_Kernels table, which contains entries
of type CUDA_Kernel_Record. Each CUDA_Kernel_Record corresponds
to a K line in an ali file.
* bindgen.adb: Introduce new Gen_CUDA_Init procedure in the
binder, which generates CUDA kernel registration code.
* gnat_cuda.adb: Move Get_CUDA_Kernels spec to package spec to
make it available to bindgen.adb.
* gnat_cuda.ads: Likewise.
* lib-writ.adb: Introduce new Output_CUDA_Symbols procedure,
which generates one 'K' line in the ALI file per visible CUDA
kernel.
* opt.ads: Introduce Enable_CUDA_Expansion option, triggered by
using the -gnatd_c flag.
* switch-b.adb: Likewise.
* switch-c.adb: Likewise.
Diffstat (limited to 'gcc/ada/gnat_cuda.ads')
-rw-r--r-- | gcc/ada/gnat_cuda.ads | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/ada/gnat_cuda.ads b/gcc/ada/gnat_cuda.ads index b5fcf8f..e756162 100644 --- a/gcc/ada/gnat_cuda.ads +++ b/gcc/ada/gnat_cuda.ads @@ -92,4 +92,9 @@ package GNAT_CUDA is -- - Empty content of CUDA_Global procedures. -- - Remove declarations of CUDA_Device entities. + function Get_CUDA_Kernels (Pack_Id : Entity_Id) return Elist_Id; + -- Returns an Elist of all procedures marked with pragma CUDA_Global that + -- are declared within package body Pack_Body. Returns No_Elist if Pack_Id + -- does not contain such procedures. + end GNAT_CUDA; |