[LLVMdev] OpenCL SPIR/NVPTX code generation

Benyei, Guy guy.benyei at intel.com
Wed Jan 23 04:04:37 PST 2013


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>


More information about the llvm-dev mailing list