Comparison of 2 schemes to implement OpenMP 5.0 declare mapper codegen

Hi Lingda, thanks for your comments.
We can allocate the buffer either by allocating it on the stack or calling OpenMP allocate function.
With this solution, we allocate memory only once (no need to resize buffer after push_backs) and we do not need to call the runtime function to put map data to the buffer, compiler generated code can do it.
But anyway, I agree, it would be good to hear some other opinions.

graycol.gif

ecblank.gif

Hi, Alexey, Lingda,

I haven’t been following this closely, so a few questions/comments:

  1. Recursive mappers are not supported in OpenMP 5, but do we expect that to change in the future?

  2. Our experience so far suggests that the most important optimization in this space is to limit the number of distinct host-to-device transfers (or data copies) on systems where data needs to be copied. In these schemes, where does that coalescing occur?

  3. So long as the mappers aren’t recursive, I agree with Alexey that the total number of to-be-mapped components should be efficient to calculate. The counting function should simplify to a trivial expression in nearly all cases. The only case where it might not is where the type contains an array section with dynamic bounds, and the element type also has a mapper with an array section with dynamic bounds. In this case (similar to the unsupported recursive cases, which as an aside, we should probably support it as an extension) we could need to walk the data structure twice to precalculate the number of total components to map. However, this case is certainly detectable by static analysis of the declared mappers, and so I think that we can get the best of both worlds: we could use Alexey’s proposed scheme except in cases where we truly need to walk the data-structure twice, in which case we could use Lingda’s combined walk/push_back scheme. Is there any reason why that wouldn’t work?

Thanks again,

Hal

Recursive data structures are important if you consider linked lists important.

Supporting these is challenging but not impossible, I would expect that if someone manages to implement a cost effective way to support linked lists we would add support to OpenMP with ease.

Recursive data structures are important if you consider linked lists important.

I definitely agree, and I do.

Supporting these is challenging but not impossible, I would expect that if someone manages to implement a cost effective way to support linked lists we would add support to OpenMP with ease.

In the context of the current proposal, supporting recursion seems to have two effects:

1. You would not want to use a two-pass traversal to precalculate the size of the mapping table (because if you did two passes, you would traverse the list twice, and hat would be unnecessarily expensive).

2. We'd need to also maintain a "visited addresses" hash table to prevent infinite recursion. As we build up the array of mapping descriptors, we would also add the addresses to the hash table, and should the address already be present , we'd avoid recursing (i.e., just use a regular visited set as one does with a graph traversal).

Am I overlooking something?

-Hal

Best regards,
Alexey Bataev

In this case we should review 2 remaining schemes: the original from Lingda and alternative scheme with functional part moved to the runtime and mappers called indirectly by the runtime (see the description provided by Lingda).