Jon Chesterfield d0b312955f [libomptarget] Implement host plugin for amdgpu
[libomptarget] Implement host plugin for amdgpu

Replacement for D71384. Primary difference is inlining the dependency on atmi
followed by extensive simplification and bugfixes. This is the latest version
from https://github.com/ROCm-Developer-Tools/amd-llvm-project/tree/aomp12 with
minor patches and a rename from hsa to amdgpu, on the basis that this can't be
used by other implementations of hsa without additional work.

This will not build unless the ROCM_DIR variable is passed so won't break other
builds. That variable is used to locate two amdgpu specific libraries that ship
as part of rocm:
libhsakmt at https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface
libhsa-runtime64 at https://github.com/RadeonOpenCompute/ROCR-Runtime
These libraries build from source. The build scripts in those repos are for
shared libraries, but can be adapted to statically link both into this plugin.

There are caveats.
- This works well enough to run various tests and benchmarks, and will be used
  to support the current clang bring up
- It is adequately thread safe for the above but there will be races remaining
- It is not stylistically correct for llvm, though has had clang-format run
- It has suboptimal memory management and locking strategies
- The debug printing / error handling is inconsistent

I would like to contribute this pretty much as-is and then improve it in-tree.
This would be advantagous because the aomp12 branch that was in use for fixing
this codebase has just been joined with the amd internal rocm dev process.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D85742
2020-08-15 23:58:28 +01:00

39 lines
1.6 KiB
Modula-2

// name, header width, reader, [lower, upper] encoding
X(posfixint, 1, read_embedded_u8, 0x00, 0x7f)
X(negfixint, 1, read_embedded_s8, 0xe0, 0xff)
X(fixmap, 1, read_via_mask_0xf, 0x80, 0x8f)
X(fixarray, 1, read_via_mask_0xf, 0x90, 0x9f)
X(fixstr, 1, read_via_mask_0x1f, 0xa0, 0xbf)
X(nil, 1, read_zero, 0xc0, 0xc0)
X(never_used, 1, read_zero, 0xc1, 0xc1)
X(f, 1, read_via_mask_0x1, 0xc2, 0xc2)
X(t, 1, read_via_mask_0x1, 0xc3, 0xc3)
X(bin8, 2, read_size_field_u8, 0xc4, 0xc4)
X(bin16, 3, read_size_field_u16, 0xc5, 0xc5)
X(bin32, 5, read_size_field_u32, 0xc6, 0xc6)
X(ext8, 3, read_size_field_u8, 0xc7, 0xc7)
X(ext16, 4, read_size_field_u16, 0xc8, 0xc8)
X(ext32, 6, read_size_field_u32, 0xc9, 0xc9)
X(float32, 5, read_zero, 0xca, 0xca)
X(float64, 9, read_zero, 0xcb, 0xcb)
X(uint8, 2, read_size_field_u8, 0xcc, 0xcc)
X(uint16, 3, read_size_field_u16, 0xcd, 0xcd)
X(uint32, 5, read_size_field_u32, 0xce, 0xce)
X(uint64, 9, read_size_field_u64, 0xcf, 0xcf)
X(int8, 2, read_size_field_s8, 0xd0, 0xd0)
X(int16, 3, read_size_field_s16, 0xd1, 0xd1)
X(int32, 5, read_size_field_s32, 0xd2, 0xd2)
X(int64, 9, read_size_field_s64, 0xd3, 0xd3)
X(fixext1, 3, read_zero, 0xd4, 0xd4)
X(fixext2, 4, read_zero, 0xd5, 0xd5)
X(fixext4, 6, read_zero, 0xd6, 0xd6)
X(fixext8, 10, read_zero, 0xd7, 0xd7)
X(fixext16, 18, read_zero, 0xd8, 0xd8)
X(str8, 2, read_size_field_u8, 0xd9, 0xd9)
X(str16, 3, read_size_field_u16, 0xda, 0xda)
X(str32, 5, read_size_field_u32, 0xdb, 0xdb)
X(array16, 3, read_size_field_u16, 0xdc, 0xdc)
X(array32, 5, read_size_field_u32, 0xdd, 0xdd)
X(map16, 3, read_size_field_u16, 0xde, 0xde)
X(map32, 5, read_size_field_u32, 0xdf, 0xdf)