]> git.ipfire.org Git - thirdparty/gcc.git/commit
Add runtime ISA check for amdgcn offloading
authorFrederik Harwath <frederik@codesourcery.com>
Mon, 20 Jan 2020 06:45:43 +0000 (07:45 +0100)
committerFrederik Harwath <frederik@codesourcery.com>
Tue, 21 Jan 2020 06:41:45 +0000 (07:41 +0100)
commit7d593fd672e5a01610d750c754213ea6c3e71ef1
tree07ec446c5c2b4c95404aa7be7318f97c26fc7a48
parentb313d3c49c2387b5e212df22a5e6ecc0c4e95c0a
Add runtime ISA check for amdgcn offloading

The HSA/ROCm runtime rejects binaries not built for the exact GPU device
present. So far, the libgomp amdgcn plugin does not verify that the GPU ISA
and the ISA specified at compile time match before handing over the binary to
the runtime.  In case of a mismatch, the user is confronted with an unhelpful
runtime error.

This commit implements a runtime ISA check. In case of an ISA mismatch, the
execution is aborted with a clear error message and a hint at the correct
compilation parameters for the GPU on which the execution has been attempted.

libgomp/
* plugin/plugin-gcn.c (EF_AMDGPU_MACH): New enum.
* (EF_AMDGPU_MACH_MASK): New constant.
* (gcn_isa): New typedef.
* (gcn_gfx801_s): New constant.
* (gcn_gfx803_s): New constant.
* (gcn_gfx900_s): New constant.
* (gcn_gfx906_s): New constant.
* (gcn_isa_name_len): New constant.
* (elf_gcn_isa_field): New function.
* (isa_hsa_name): New function.
* (isa_gcc_name): New function.
* (isa_code): New function.
* (struct agent_info): Add field "device_isa" and remove field
"gfx900_p".
* (GOMP_OFFLOAD_init_device): Adapt agent init to "agent_info"
field changes, fail if device has unknown ISA.
* (parse_target_attributes): Replace "gfx900_p" by "device_isa".
* (isa_matches_agent): New function ...
* (create_and_finalize_hsa_program): ... used from here to check
that the GPU ISA and the code-object ISA match.
libgomp/plugin/plugin-gcn.c