This patch adds the infrastructure for allocator support for target memory. Three allocators are introduced for device, host and shared memory. The corresponding API functions have the llvm_ prefix temporarily, until they become part of the OpenMP standard:
llvm_omp_target_alloc_device(size_t size, int device_num);
- Returns memory owned by device.
- Memory is only accessible by device.
llvm_omp_target_alloc_host(size_t size, int device_num);
- Returns non-migratable memory owned by host.
- Memory is accessible by host and device(s).
llvm_omp_target_alloc_shared(size_t size, int device_num);
- Returns migratable memory owned by host and device.
- Memory is accessible by host and device.
The corresponding host OpenMP runtime patch is D96669.
Ultimately, libomptarget needs support from each plugin to allocate memory using the desired method. __tgt_rtl_data_alloc has been extended with an extra kind argument which dictates the allocator to be used. The patch provides a trivial sample implementation using the generic-elf-64 plugin. For all other plugins, calling __tgt_rtl_data_alloc with a specific allocator (other than TARGET_ALLOC_DEFAULT) results in NULL being returned until said allocator has been implemented in the plugin.