[Openmp-dev] 32-bit target device support

Andreas Hommel via Openmp-dev openmp-dev at lists.llvm.org
Wed Aug 14 01:36:43 PDT 2019


Hi,

 

I am currently adding support for an experimental 32-bit OpenMP target
device using x86_64 as a host. There seems to be a bug in

 

bool Sema::Sema::isOpenMPCapturedByRef(.,) {

.

  if (!IsByRef &&

      (Ctx.getTypeSizeInChars(Ty) >

           Ctx.getTypeSizeInChars(Ctx.getUIntPtrType()) ||

       Ctx.getDeclAlign(D) > Ctx.getTypeAlignInChars(Ctx.getUIntPtrType())))
{

    IsByRef = true;

  }

  return IsByRef;

}

 

The above code assumes that the target device's UIntPtr size is the same as
the host's UIntPtr which is not true in my case. So, if you pass a 64-bit
double to a 32-bit device the host compilation pass uses by-value argument
passing, because the value fits into the 64-bit pointers. However, if you
build for the target (-fopenmp-is-device), the 64-bit float does not fit
into the 32-bit pointer, so the target assumes that the value is passed
by-reference and the device does not pick up the correct argument value.

 

A possible fix would to use something like this

 

  if (!IsByRef &&

      (Ctx.getTypeSizeInChars(Ty) >

           DCtx.getTypeSizeInChars(DCtx.getUIntPtrType()) ||

       Ctx.getDeclAlign(D) >
DCtx.getTypeAlignInChars(DCtx.getUIntPtrType()))) {

    IsByRef = true;

  }

 

where DCtx is the context of the target device. But that context does not
seem to be available in the host's Sema.

 

Sema.LangOpts.OMPTargetTriples seems to be the only available starting point
to get to a device's context, or am I missing something?

 

Thanks,

Andreas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20190814/2002a510/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 9859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20190814/2002a510/attachment-0001.bin>


More information about the Openmp-dev mailing list