[LLVMdev] [cfe-dev] OpenCL SPIR/NVPTX code generation

Justin Holewinski justin.holewinski at gmail.com
Wed Jan 23 07:53:15 PST 2013


On Wed, Jan 23, 2013 at 6:44 AM, ankur deshwal <a.s.deshwal at gmail.com>wrote:

> Hi Guy,
>
> Thanks a lot for the clarification.
>
> I tried using the triple for SPIR as
>
> $ clang -x cl -fno-builtin -emit-llvm -c -Xclang -triple -Xclang
> spir-unknown-unknown Simple_Kernel.cl
>
> However I get the following error.
> error: unknown target triple 'spir-unknown-unknown', please use -triple or
> -arch
>
> I also tried with triple nvptx-unknown-unknown
> clang -x cl -fno-builtin -emit-llvm -S -Xclang -triple -Xclang
> nvptx-unknown-unknown Simple_Kernel.cl
>
> Then I get following error.
> error: unknown target CPU 'pentium4'
>

For some reason clang wants to use the default x86 CPU for the NVPTX
target; I need to look into that.  To fix this, just set the CPU to sm_20:

clang -x cl -fno-builtin -emit-llvm -c -Xclang -triple -Xclang
nvptx-unknown-unknown Simple_Kernel.cl -Xclang -target-cpu -Xclang sm_20

If you want to generate code for NV GPUs, this is the route to go.  Though
note that the IR you get will *not* be SPIR-conformant.  Use the SPIR
triple if you want/need SPIR.


>
> If I dont specify the triple, it compiles fine. However in the llvm
> generated, it shows the target triple as
> target triple = "i386-pc-linux-gnu"
>
> So it crashes with the llc ( due to the address space errors).
>
> I also tried building llvm with only nvptx target, still the target triple
> is the same.
>
> Please help.
>
> Thanks a ton,
> Ankur
>
>
>
>
> On Wed, Jan 23, 2013 at 1:20 PM, Benyei, Guy <guy.benyei at intel.com> wrote:
>
>> Hi Ankur,****
>>
>> SPIR generation is not yet fully supported in Clang. I’m working on this
>> task, but there are still some missing parts.****
>>
>> The correct way to generate SPIR by Clang is adding the “-triple
>> spir-unknown-unknown” or “-triple spir64-unknown-unknown” command line
>> options when running clang.****
>>
>> ** **
>>
>> Thanks****
>>
>>    Guy Benyei****
>>
>> [image: email_signature_guy_new2]****
>>
>> ** **
>>
>> *From:* cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu]
>> *On Behalf Of *ankur deshwal
>> *Sent:* Tuesday, January 22, 2013 11:09
>> *To:* cfe-dev at cs.uiuc.edu
>> *Subject:* [cfe-dev] OpenCL SPIR code generation****
>>
>> ** **
>>
>> Hi all,****
>>
>> ** **
>>
>> I am trying to compile a openCL code to SPIR with LLVM/Clang-3.2. ****
>>
>> ** **
>>
>> I see there is no backend for SPIR( which makes sense as SPIR is variant
>> of LLVM-IR). However this leads me clueless how to configure LLVM/Clang for
>> SPIR and what is the command I shall use to generate SPIR code from cl code.
>> ****
>>
>> ** **
>>
>> Thanks,****
>>
>> Ankur****
>>
>> ---------------------------------------------------------------------
>> Intel Israel (74) Limited
>>
>> This e-mail and any attachments may contain confidential material for
>> the sole use of the intended recipient(s). Any review or distribution
>> by others is strictly prohibited. If you are not the intended
>> recipient, please contact the sender and delete all copies.
>>
>>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>


-- 

Thanks,

Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130123/23b7e7ef/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 24800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130123/23b7e7ef/attachment.png>


More information about the llvm-dev mailing list