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' 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. > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130123/442d4d30/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/442d4d30/attachment.png>
Hi Ankur, Since you use -Xclang, the clang executable passes multiple triples to "clang -cc1". You can see that if you add the -v option. I'm sure there is someone here who can explain it better than I... Anyhow, I think you better use clang -cc1. Make sure -cc1 is the first command line option you use. $ clang -cc1 -fno-builtin -emit-llvm-bc -triple spir-unknown-unknown Simple_Kernel.cl -o Simple_Kernel.bc should work for you. Thanks [email_signature_guy_new2] From: ankur deshwal [mailto:a.s.deshwal at gmail.com] Sent: Wednesday, January 23, 2013 13:44 To: Benyei, Guy; cfe-dev at cs.uiuc.edu; llvmdev at cs.uiuc.edu Subject: OpenCL SPIR/NVPTX code generation 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' 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<mailto: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 [email_signature_guy_new2] From: cfe-dev-bounces at cs.uiuc.edu<mailto:cfe-dev-bounces at cs.uiuc.edu> [mailto: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<mailto: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. --------------------------------------------------------------------- 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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130123/3b0e60f0/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 24800 bytes Desc: image001.png URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130123/3b0e60f0/attachment.png>
Justin Holewinski
2013-Jan-23 15:53 UTC
[LLVMdev] [cfe-dev] OpenCL SPIR/NVPTX code generation
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>
On Jan 23, 2013, at 4:04 , "Benyei, Guy" <guy.benyei at intel.com> wrote:> Hi Ankur, > Since you use –Xclang, the clang executable passes multiple triples to “clang -cc1”. You can see that if you add the -v option. I’m sure there is someone here who can explain it better than I… > Anyhow, I think you better use clang -cc1. Make sure -cc1 is the first command line option you use. > > $ clang -cc1 -fno-builtin -emit-llvm-bc -triple spir-unknown-unknown Simple_Kernel.cl -o Simple_Kernel.bc > > should work for you.clang -cc1 shouldn't ever be necessary for end users of clang, particularly because cc1 options are not guaranteed to be stable. You also lose all the default options that the driver normally passes down. It's possible this doesn't matter much for SPIR, at least not right now, but it's not something we should be recommending or supporting. -target is the driver version of -triple. This "worked" for me, where by "worked" I mean "generated some output but I don't know enough about SPIR to validate it". % clang -x cl -fno-builtin -target spir -c -emit-llvm Jordan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130123/10237ef5/attachment.html>
Apparently Analagous Threads
- [LLVMdev] OpenCL SPIR/NVPTX code generation
- [LLVMdev] [cfe-dev] OpenCL SPIR/NVPTX code generation
- [LLVMdev] [cfe-dev] OpenCL SPIR/NVPTX code generation
- [LLVMdev] [cfe-dev] OpenCL SPIR/NVPTX code generation
- [LLVMdev] [cfe-dev] SPIR Review Status: after Introduction and 32bits vs. 64bits discussions