[Openmp-dev] Malloc in target region
Johannes Doerfert via Openmp-dev
openmp-dev at lists.llvm.org
Wed Jun 24 21:35:03 PDT 2020
>>>> On 6/24/20 6:40 AM, Jon Chesterfield via Openmp-dev wrote:
>>>>> I can think of a few interpretations:
>>>>> - One heap per process. Malloc on target or host, free from
either. Writable from either, or some other device. Might mean
intercepting host libc. Convenient, slow.
>>>>> - One heap per device + one for host. Each independent, pointers
only valid on the thing that called malloc.
>>>>> - One heap per target offload region, inaccessible from host.
>>>>> - Some other granularity.
I think the only thing we can reasonably support and that makes sense in
the general picture is:
One heap per device + one for host
On 6/24/20 8:41 PM, Jeff Hammond via Openmp-dev wrote:
>>> On 6/24/20 7:26 PM, Jeff Hammond wrote:
>>> Does OpenMP 5 allow calling symbols that are not omp-declare-target?
>>
>> I'm not sure this is relevant because the implementation gets to
provide such symbols (and we depend on it doing so in other cases, such
as for math.h functions).
>>
> Is LLVM OpenMP going to assume one and only C RTL? Which one?
Yeah, that is a good question, ...
I think your last thought was the right starting point, you need to
declare target the symbol to access it on a device. That said, some
symbols the compiler will automagically provides as declare target
because people expect it. `math.h` is the poster child.
My first thought is that malloc on the device is provided and defined as
either
`omp_alloc(size, omp_default_mem_alloc)`, or
`omp_alloc(size, omp_cgroup_mem_allo)`.
free then with the respective `omp_free` call.
realloc and friends are available as soon as we have the counterparts in
OpenMP.
Cheers,
Johannes
P.S. Thursday & Friday we have our workshop :)
More information about the Openmp-dev
mailing list