This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Add Support for Mapping Names in Libomptarget RTL
ClosedPublic

Authored by jhuber6 on Oct 26 2020, 10:40 AM.

Details

Summary

This patch adds basic support for priting the source location and names for the mapped variables. This patch does not support names for custom mappers. This is based on D89802.

Diff Detail

Event Timeline

jhuber6 created this revision.Oct 26 2020, 10:40 AM
jhuber6 requested review of this revision.Oct 26 2020, 10:40 AM
jdoerfert added inline comments.Oct 26 2020, 4:15 PM
openmp/libomptarget/include/Ident.h
67 ↗(On Diff #300726)

Nit: getVariableNameFromNameT? or similar, getName is too generic

jhuber6 added inline comments.Oct 26 2020, 4:34 PM
openmp/libomptarget/include/Ident.h
67 ↗(On Diff #300726)

Do you think I should change all references from void ** to use some name_t in the runtime? I guess it makes it more obvious what it's supposed to be.

Let's split this:

  1. introduce ident.h, or source_info.h to be even more descriptive. Only declare source_loc_info_t (or similar) and use it instead of the void*.
  2. introduce mapped_var_info_t (or similar) and getMappedVariableName(mapped_var_info_t *). Use it everywhere when you extend the interface.
openmp/libomptarget/include/Ident.h
56 ↗(On Diff #300726)

This function is unused. Let's add it with a use. Also, we could make it a constructor while we are at it.

67 ↗(On Diff #300726)

Yeah, that sounds good. While at it, I would make name_t a const char *, though if we hide it anyway it's not that important.

jhuber6 updated this revision to Diff 301031.Oct 27 2020, 9:28 AM

Restructuring code to use type alias wrapper name_t to make it more obvious what the data is beyond a void *. Restructured Ident.h into a class with a constructor, this will have an extra constructor for the OpenMP Ident_t struct once D87946 is merged. Added a routine to print out the declaration site in the table dump using LIBOMPTARGET_INFO. For example, if I seg-fault in an OpenMP region using env LIBOMPTARGET_INFO=2 I will get this output for a sample program.

CUDA device 0 info: Device supports up to 65536 CUDA blocks and 1024 threads with a warp size of 32
Libomptarget device 0 info: Mapping exists (implicit) with HstPtrBegin=0x00007f12ce17a010, TgtPtrBegin=0x00007f12b1000000, Size=0, updated RefCount=2, Name=C
Libomptarget device 0 info: Mapping exists (implicit) with HstPtrBegin=0x00007f12e0498010, TgtPtrBegin=0x00007f12ae400000, Size=0, updated RefCount=2, Name=A
Libomptarget device 0 info: Mapping exists (implicit) with HstPtrBegin=0x00007f12cf0bd010, TgtPtrBegin=0x00007f12b0000000, Size=0, updated RefCount=2, Name=B
CUDA device 0 info: Launching kernel __omp_offloading_fd02_c53ebe3d__Z4gemmIiNSt3__17complexIdEEEvT_S3_S3_T0_PKS4_S3_S3_S6_S3_S3_S4_PS4_S3_S3__l53 with 504 blocks and 128 threads in SPMD mode
Libomptarget error: Failed to synchronize device.
Libomptarget error: Call to targetDataEnd failed, abort target.
Libomptarget error: Failed to process data after launching the kernel.
Device 0 Host-Device Pointer Mappings:
Host Ptr           Target Ptr         Size (B) Declaration
0x00007f12ce17a010 0x00007f12b1000000 16000000 matrixC[0:M * N] at gemm.cpp:76:24
0x00007f12cf0bd010 0x00007f12b0000000 16000000 matrixB[0:K * N] at gemm.cpp:75:24
0x00007f12e0498010 0x00007f12ae400000 16000000 matrixA[0:M * K] at gemm.cpp:74:24
0x00007ffd43f2fb58 0x00007f1271c00200 16       beta at kernel.h:34:19
0x00007ffd43f2fb68 0x00007f1271c00000 16       alpha at kernel.h:31:19
jhuber6 updated this revision to Diff 301050.Oct 27 2020, 10:20 AM

Changed name_t to map_var_info_t and renamed the Ident.h header.

jdoerfert accepted this revision.Oct 27 2020, 10:30 AM

LGTM

openmp/libomptarget/include/SourceInfo.h
3

Nit: format

82

Nit: Make the comments sentences with . at the end.

This revision is now accepted and ready to land.Oct 27 2020, 10:30 AM
This revision was landed with ongoing or failed builds.Oct 27 2020, 1:58 PM
This revision was automatically updated to reflect the committed changes.
This revision was landed with ongoing or failed builds.Nov 18 2020, 1:02 PM