This is an archive of the discontinued LLVM Phabricator instance.

[NFC][libomptarget] move remaining device specific code out of omptarget-nvptx.h
ClosedPublic

Authored by JonChesterfield on Oct 24 2019, 11:31 PM.

Details

Summary

[NFC][libomptarget] move remaining device specific code out of omptarget-nvptx.h

Strictly there is one remaining difference wrt amdgcn - parallelLevel is
volatile qualified on amdgcn and not on nvptx. Determining whether this is
correct - and how to represent the different semantics of 'volatile' under
various conditions - is beyond the scope of this code motion patch.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2019, 11:31 PM
ABataev added inline comments.Oct 25 2019, 6:49 AM
openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
16

Do we need stdint.h include here?

34–37

Is this really target specific thing?

JonChesterfield marked 2 inline comments as done.Oct 25 2019, 8:34 AM

"Target specific" is suffering a little as an abstraction.

We have hardware specific (e.g. barrier implementation), language specific (e.g. attributes), driver specific (the above struct), vendor extensions (extra stuff one adds to the top level interface.h).

openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
16

Sure. There's uint32_t and similar in this header, which could reasonably be the first or only one included in a translation unit.

34–37

This one is a driver/plugin specific thing. The hsa struct has another couple of fields.

ABataev added inline comments.Oct 25 2019, 8:43 AM
openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
16

Then maybe include of stdint.h may be removed in omptarget-nvptx.h?

34–37

Why do you have different fields for hsa? Maybe we can use the same fields for NVPTX if they are useful?

JonChesterfield marked an inline comment as done.
  • Remove stdint.h from omptarget-nvptx.h
openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
34–37

The struct definition looks likely to be useful for nvptx, though the fields should probably then be wired up. Defined for gcn/hsa as:

struct omptarget_device_environmentTy {
  int32_t debug_level;   // gets value of envvar LIBOMPTARGET_DEVICE_RTL_DEBUG
                         // only useful for Debug build of deviceRTLs 
  int32_t num_devices;   // gets number of active offload devices 
  int32_t device_num;    // gets a value 0 to num_devices-1
};

where the fields are used by additional functions in libcall, e.g.

EXTERN int omp_get_num_devices(void) {
  PRINT(LD_IO, "call omp_get_num_devices() returns device_size %d\n",
        omptarget_device_environment.num_devices);
  return omptarget_device_environment.num_devices;
}

Would you like omp_get_num_devices / omp_get_device_num added to the generic interface? If so I'll write the patch, and reduce this diff to exclude the struct move.

JonChesterfield marked an inline comment as done.Oct 25 2019, 9:05 AM
JonChesterfield added inline comments.
openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
16

Removed. Thanks

  • Return device_environmentTy to original location, intending to implement num_devices calls for ptx
ABataev added inline comments.Oct 25 2019, 9:48 AM
openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
34–37

Are they required by the standard?

JonChesterfield marked an inline comment as done.Oct 25 2019, 10:07 AM
JonChesterfield added inline comments.
openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
34–37

I don't know. I'll find out before creating a diff which proposes said functions - in the meantime I've dropped it from this patch.

This revision is now accepted and ready to land.Oct 25 2019, 10:12 AM

Committed, thanks.

Leaving this open to find out whether phabricator notices and auto-closes it.

This revision was automatically updated to reflect the committed changes.