This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][libomptarget] Add global memory data sharing support for master-worker sharing.
ClosedPublic

Authored by gtbercea on Mar 8 2018, 10:18 AM.

Details

Summary

This patch adds support for the sharing of variables from the master thread of a team to the worker threads of the team.
The runtime uses a stack structure implemented as a doubly-linked list of slots with each slot having the exact same size as the size requested. This implementation leverages existing data structures. The runtime functions are added as separate functions to avoid interfering with the current interface.

Limitations to be addressed in future patches:

  • This current patch only employs global memory. In a future patch we will enable to usage for shared memory as an optimization.
  • Allow the allocation of several requested sizes in the same slot.

Diff Detail

Repository
rOMP OpenMP

Event Timeline

gtbercea created this revision.Mar 8 2018, 10:18 AM
grokos added inline comments.Mar 8 2018, 10:57 AM
libomptarget/deviceRTLs/nvptx/src/data_sharing.cu
352

remove is

382

use ptrdiff_t for the difference between 2 `uintptr_t'.

418

removed --> removes

459

where does 100 come from?

476

will be passed

libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
99–100

Init() is never called throughout the code, so nArgs is never initialized to MAX_SHARED_ARGS. Add a constructor to this class which will call Init().

278

worker_rootS[wid].Prev = 0;?

gtbercea updated this revision to Diff 137620.Mar 8 2018, 11:14 AM

Address comments.

gtbercea marked 7 inline comments as done.Mar 8 2018, 11:17 AM
gtbercea added inline comments.
libomptarget/deviceRTLs/nvptx/src/data_sharing.cu
459

Removed it, was a leftover.

libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
99–100

Added the call in the stack initialization function.

gtbercea marked 2 inline comments as done.Mar 8 2018, 12:00 PM
grokos added inline comments.Mar 9 2018, 1:20 PM
libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
99–100

No, that's not a good idea. Initialization of the class members should be handled automatically via a constructor. If someone ever wants to reuse this class without having a constructor then they will need to keep in mind that Init() must be called explicitly - not a good style.

gtbercea added inline comments.Mar 12 2018, 7:57 AM
libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
99–100

Since this class is going to be instantiated as a device shared object, dynamic initialization is not supported. In general, it is not supported for device, constant and shared variables. The suggested solution is to have an empty or no constructor at all and explicitly handle initialization like it is being done in the Init() method.

gtbercea marked an inline comment as done.Mar 12 2018, 8:01 AM
grokos accepted this revision.Mar 12 2018, 8:05 AM

LGTM.

This revision is now accepted and ready to land.Mar 12 2018, 8:05 AM
This revision was automatically updated to reflect the committed changes.