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.bat...@hotmail.com>
To:     "reviews+d28145+public+d89a609fe244d...@reviews.llvm.org"
            <reviews+d28145+public+d89a609fe244d...@reviews.llvm.org>
Cc:     Arpith C Jacob/Watson/IBM@IBMUS, Samuel F
            Antao/Watson/IBM@IBMUS, Carlo Bertolli/Watson/IBM@IBMUS,
            "kkw...@gmail.com" <kkw...@gmail.com>, Kevin K
            O'Brien/Watson/IBM@IBMUS, "gheorghe-teod.ber...@ibm.com"
            <gheorghe-teod.ber...@ibm.com>, "t...@google.com"
            <t...@google.com>, "jholewin...@nvidia.com"
            <jholewin...@nvidia.com>, "cfe-commits@lists.llvm.org"
            <cfe-commits@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
<revi...@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
>
>
>



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to