[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

Arpith C Jacob via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 08:27:37 PST 2017


Alexey,

Thanks for the pointer.  I've updated the patch using
CGF.ConvertTypeForMem(CGM.getContext().BoolTy);
to get the type for 'bool'.

On my machine it returns i8.  The compiler produces code for a simple
OpenMP program that links and seems to run fine on the GPU with my runtime.

I also compiled the following C++ program to get the IR shown below:

bool test() {
    return true;
}

; Function Attrs: noinline nounwind
define zeroext i1 @_Z4testv() #0 {
entry:
  ret i1 true
}

For this program you can see i1 being generated.  I'm not quite sure what
the difference is...

Regards,
Arpith



From:	Alexey Bataev <a.bataev at hotmail.com>
To:	"reviews+D28145+public+d89a609fe244de18 at reviews.llvm.org"
            <reviews+D28145+public+d89a609fe244de18 at reviews.llvm.org>
Cc:	Arpith C Jacob/Watson/IBM at IBMUS, Samuel F
            Antao/Watson/IBM at IBMUS, Carlo Bertolli/Watson/IBM at IBMUS,
            "kkwli0 at gmail.com" <kkwli0 at gmail.com>, Kevin K
            O'Brien/Watson/IBM at IBMUS, "gheorghe-teod.bercea at ibm.com"
            <gheorghe-teod.bercea at ibm.com>, "tra at google.com"
            <tra at google.com>, "jholewinski at nvidia.com"
            <jholewinski at nvidia.com>, "cfe-commits at lists.llvm.org"
            <cfe-commits at lists.llvm.org>
Date:	01/09/2017 08:47 AM
Subject:	Re: [PATCH] D28145: [OpenMP] Basic support for a parallel
            directive in a target region on an NVPTX device.



Arpith, I'm afraid that bool type is translated to i8 or even to i32 type
rather than to i1. I believe you'd better to use CGF.ConvertTypeForMem
(Context.getBoolType())to get the correct return type for bool rather than
simply i1. You'd better to check how bool(...) function type is converted
to LLVM IR.

Best regards,
Alexey Bataev

> 9 янв. 2017 г., в 15:09, Arpith Jacob via Phabricator
<reviews at reviews.llvm.org> написал(а):
>
> arpith-jacob marked 2 inline comments as done.
> arpith-jacob added inline comments.
>
>
> ================
> Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:365
> +    llvm::FunctionType *FnTy =
> +        llvm::FunctionType::get(llvm::Type::getInt1Ty(CGM.getLLVMContext
()),
> +                                TypeParams, /*isVarArg*/ false);
> ----------------
> ABataev wrote:
>> Does it really return I1 type? Or I8?
> Alexey, the runtime function is called by every worker thread.  It
returns a 'bool' that indicates if the thread has been activated in the
parallel region, which is why I used an Int1Ty.  Please let me know if you
see problems with this.  Thanks.
>
>
> https://reviews.llvm.org/D28145
>
>
>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170109/f5ad2e75/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170109/f5ad2e75/attachment.gif>


More information about the cfe-commits mailing list