Forum Discussion
Altera_Forum
Honored Contributor
11 years agoCompiling Altera-OpenCL code in Clang (using aocl-clang)
Hello,
- I am very new to Altera-openCL. I tried getting LLVM Itermediate representaion of an example Altera-opencl code by using Clang version 3.3. Though it compiles with warnings as below, I would like to know is there any proper way of getting LLVM IR.
- I also tried doing the same with aocl-clang but it resulted me the following.
- If I try to include --board option with aocl-clang, I receive the following
4 Replies
- Altera_Forum
Honored Contributor
Hello, I found a way. For those who had the same problem as me,
aocl-clang -cc1 -O3 -emit-llvm-bc -DALTERA_CL -Wuninitialized -triple fpga64 -mllvm -board -mllvm ~/tools/altera/14.1/hld/board/s5_ref/hardware/s5_ref/board_spec.xml -DACL_BOARD_s5_ref=1 -DAOCL_BOARD_s5_ref=1 matrix_mult.cl -o matrix_mult.pre.bc --- Quote Start --- Hello,- I am very new to Altera-openCL. I tried getting LLVM Itermediate representaion of an example Altera-opencl code by using Clang version 3.3. Though it compiles with warnings as below, I would like to know is there any proper way of getting LLVM IR.
- I also tried doing the same with aocl-clang but it resulted me the following.
- If I try to include --board option with aocl-clang, I receive the following
- Altera_Forum
Honored Contributor
--- Quote Start --- Hello, I found a way. For those who had the same problem as me, aocl-clang -cc1 -O3 -emit-llvm-bc -DALTERA_CL -Wuninitialized -triple fpga64 -mllvm -board -mllvm ~/tools/altera/14.1/hld/board/s5_ref/hardware/s5_ref/board_spec.xml -DACL_BOARD_s5_ref=1 -DAOCL_BOARD_s5_ref=1 matrix_mult.cl -o matrix_mult.pre.bc --- Quote End --- Hi, there I'm a newbie to Altera OpenCL. As neither the programming guide nor best practices provided by official mention LLVM IR, I'd like to know how can I found the exact IR during my aoc compilation derived from my kernel code?:confused: I have already tried aocl-clang but it seems not existing there (using AOCL 15.1). P.S: The reason I'd like to check IR is that I'm trying to compile my simple kernel to accommodate AOC requirement for pipeline execution, based on the optimization report. However I found that it was not clear enough to identify the problems during my various simple experiments, even after reading the programming guide or best practices.(curious whether I m the only one with such difficulty) As a result, I'd like to find another way to tackle down the frustration - dive into LLVM IR, to figure out why those kernels are rejected. even though I'm not sure whether it is a right direction. Appreciate for any help or direction.:) - Altera_Forum
Honored Contributor
--- Quote Start --- Hi, there I have already tried aocl-clang but it seems not existing there (using AOCL 15.1). --- Quote End --- I've found aocl-clang at <altera home>/15.1/hld/linux64/bin/ - Altera_Forum
Honored Contributor
--- Quote Start --- Hello, I found a way. For those who had the same problem as me, aocl-clang -cc1 -O3 -emit-llvm-bc -DALTERA_CL -Wuninitialized -triple fpga64 -mllvm -board -mllvm ~/tools/altera/14.1/hld/board/s5_ref/hardware/s5_ref/board_spec.xml -DACL_BOARD_s5_ref=1 -DAOCL_BOARD_s5_ref=1 matrix_mult.cl -o matrix_mult.pre.bc --- Quote End --- May I ask you where did you find such information ? I'm trying the same but with "-v" flag and I'm getting some errors: aocl-clang tries to generate its output in /tmp/<kernel>-xxx.o (<kernel> is the kernel name and XXX is some code generated for temp files) the linker then tries to link the /tmp/<kernel>-xxx.o with other libraries but cannot recognize the /tmp/<kernel>-xxx.o file I've tried to add the "-save-temps" flag, which compiles <kernel>.cl into <kernel>.i and then tries to compile <kernel>.i with aocl-clang, and I get a lots of "error: unknown type name 'half'" and "unknown type name 'size_t'" errors during aocl-clang, what makes me think that it is not generating the /tmp/<kernel>-xxx.o file. I would appreciate any information you could give on where there is some of this stuff documented or any help on the problem.