llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.9k stars 11.51k forks source link

/lib64/libclangFrontend.so(+0x8401c)[0x555e67c01c] free(): invalid pointer: 0x0000005561711800 #42008

Open llvmbot opened 5 years ago

llvmbot commented 5 years ago
Bugzilla Link 42663
Version 3.8
OS Linux
Attachments OpenCL Programming Guide - Chapter 2 Exercise Code
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid,@atanasyan

Extended Description

Recently, I'm learnning the OpenCL Programming Guide adn use clang+llvm3.8.1 to compile the exercise code in Chapter 2 of the book. During the execution of the program, I encountered a serious bug about clang.

My Error info:


[root@localhost HelloWorld]# ./HelloWorld Error in `./HelloWorld': free(): invalid pointer: 0x0000005562f65800 ======= Backtrace: ========= /lib64/libc.so.6(+0x9f854)[0x555fb1b854] /lib64/libc.so.6(__libc_free+0x804)[0x555fb2c22c] /lib64/libstdc++.so.6(_ZdlPv+0x20)[0x555f8128f0] /lib64/libstdc++.so.6(_ZNSs4_Rep10_M_destroyERKSaIcE+0x20)[0x555f8a8298] /lib64/libclangFrontend.so(+0x8401c)[0x555fed001c] ======= Memory map: ======== 120000000-120004000 r-xp 00000000 08:02 4719230 /root/TarAll/src/Chapter_2/HelloWorld/HelloWorld 120010000-120014000 r--p 00000000 08:02 4719230 /root/TarAll/src/Chapter_2/HelloWorld/HelloWorld 120014000-120018000 rw-p 00004000 08:02 4719230 /root/TarAll/src/Chapter_2/HelloWorld/HelloWorld 123604000-1236c8000 rwxp 00000000 00:00 0 [heap] 555f730000-555f758000 r-xp 00000000 08:02 4863976 /usr/lib64/ld-2.20.so 555f758000-555f764000 rw-p 00000000 00:00 0 555f764000-555f768000 rw-p 00024000 08:02 4863976 /usr/lib64/ld-2.20.so 555f784000-555f7a0000 r-xp 00000000 08:02 4863583 /usr/lib64/libOpenCL.so.1.0.0 555f7a0000-555f7ac000 ---p 0001c000 08:02 4863583 /usr/lib64/libOpenCL.so.1.0.0 555f7ac000-555f7b0000 rw-p 00018000 08:02 4863583 /usr/lib64/libOpenCL.so.1.0.0 555f7b0000-555f8e8000 r-xp 00000000 08:02 4862493 /usr/lib64/libstdc++.so.6.0.20 555f8e8000-555f8f4000 ---p 00138000 08:02 4862493 /usr/lib64/libstdc++.so.6.0.20 555f8f4000-555f900000 r--p 00134000 08:02 4862493 /usr/lib64/libstdc++.so.6.0.20 555f900000-555f908000 rw-p 00140000 08:02 4862493 /usr/lib64/libstdc++.so.6.0.20 .... .....


My platform info


architecture info: [root@localhost HelloWorld]# uname -a Linux localhost 3.10.84-21.fc21.loongson.18.mips64el #​1 SMP PREEMPT Tue Apr 16 18:41:34 CST 2019 mips64 mips64 mips64 GNU/Linux

[root@localhost HelloWorld]# lscpu Architecture: mips64 Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 NUMA node(s): 1 Model name: ICT Loongson-3A R3 (Loongson-3A3000) @ 1399MHz CPU max MHz: 1399.9860 CPU min MHz: 349.9960 NUMA node0 CPU(s): 0-3 &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& rpm packages info: [root@localhost HelloWorld]# rpm -qa | grep llvm llvm-devel-3.8.1-3.fc21.loongson.2.mips64el llvm-static-3.8.1-3.fc21.loongson.2.mips64el llvm-libs-3.8.1-3.fc21.loongson.2.mips64el llvm-3.8.1-3.fc21.loongson.2.mips64el llvm-debuginfo-3.8.1-3.fc21.loongson.2.mips64el

[root@localhost HelloWorld]# rpm -qa | grep clang clang-libs-3.8.1-1.fc21.loongson.2.mips64el clang-devel-3.8.1-1.fc21.loongson.2.mips64el clang-analyzer-3.8.1-1.fc21.loongson.2.noarch clang-debuginfo-3.8.1-1.fc21.loongson.2.mips64el clang-3.8.1-1.fc21.loongson.2.mips64el

[root@localhost HelloWorld]# rpm -qa | grep libclc libclc-0.0.1-11.20150918git4346c30.fc21.loongson.mips64el libclc-devel-0.0.1-11.20150918git4346c30.fc21.loongson.mips64el

[root@localhost HelloWorld]# rpm -qa | grep libOpenCL mesa-libOpenCL-11.1.0-5.20151218.fc21.loongson.6.mips64el mesa-libOpenCL-devel-11.1.0-5.20151218.fc21.loongson.6.mips64el


other info: [root@localhost HelloWorld]# llc -version LLVM (http://llvm.org/): LLVM version 3.8.1 Optimized build. Built Jul 8 2019 (07:52:07). Default target: mips64el-redhat-linux Host CPU: (unknown)

Registered Targets: amdgcn - AMD GCN GPUs bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) cpp - C++ backend mips - Mips mips64 - Mips64 [experimental] mips64el - Mips64el [experimental] mipsel - Mipsel nvptx - NVIDIA PTX 32-bit nvptx64 - NVIDIA PTX 64-bit r600 - AMD GPUs HD2XXX-HD6XXX systemz - SystemZ

[root@localhost HelloWorld]# llc -version LLVM (http://llvm.org/): LLVM version 3.8.1 Optimized build. Built Jul 8 2019 (07:52:07). Default target: mips64el-redhat-linux Host CPU: (unknown)

Registered Targets: amdgcn - AMD GCN GPUs bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) cpp - C++ backend mips - Mips mips64 - Mips64 [experimental] mips64el - Mips64el [experimental] mipsel - Mipsel nvptx - NVIDIA PTX 32-bit nvptx64 - NVIDIA PTX 64-bit r600 - AMD GPUs HD2XXX-HD6XXX systemz - SystemZ [root@localhost HelloWorld]# clinfo Number of platforms 1 Platform Name Clover Platform Vendor Mesa Platform Version OpenCL 1.1 MESA 11.1.0 Platform Profile FULL_PROFILE Platform Extensions cl_khr_icd Platform Extensions function suffix MESA

Platform Name Clover Number of devices 1 Device Name AMD CAICOS (DRM 2.49.0, LLVM 3.8.1) Device Vendor AMD Device Vendor ID 0x1002 Device Version OpenCL 1.1 MESA 11.1.0 Driver Version 11.1.0 Device OpenCL C Version OpenCL C 1.1 Device Type GPU Device Profile FULL_PROFILE Max compute units 2 Max clock frequency 775MHz Max work item dimensions 3 Max work item sizes 256x256x256 Max work group size 256 Preferred work group size multiple 64 Preferred / native vector sizes char 16 / 16 short 8 / 8 int 4 / 4 long 2 / 2 half 0 / 0 (n/a) float 4 / 4 double 0 / 0 (n/a) Half-precision Floating-point support (n/a) Single-precision Floating-point support (core) Denormals No Infinity and NANs Yes Round to nearest Yes Round to zero No Round to infinity No IEEE754-2008 fused multiply-add No Support is emulated in software No Correctly-rounded divide and sqrt operations No Double-precision Floating-point support (n/a) Address bits 32, Little-Endian Global memory size 1073741824 (1024MiB) Error Correction support No Max memory allocation 268435456 (256MiB) Unified memory for Host and Device Yes Minimum alignment for any data type 128 bytes Alignment of base address 1024 bits (128 bytes) Global Memory cache type None Image support No Local memory type Local Local memory size 32768 (32KiB) Max constant buffer size 268435456 (256MiB) Max number of constant args 13 Max size of kernel argument 1024 Queue properties Out-of-order execution No Profiling Yes Profiling timer resolution 0ns Execution capabilities Run OpenCL kernels Yes Run native kernels No Device Available Yes Compiler Available Yes Device Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store

NULL platform behavior clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) Clover clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) Success [MESA] clCreateContext(NULL, ...) [default] Success [MESA] clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1) Platform Name Clover Device Name AMD CAICOS (DRM 2.49.0, LLVM 3.8.1) clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (1) Platform Name Clover Device Name AMD CAICOS (DRM 2.49.0, LLVM 3.8.1)

ICD loader properties ICD loader Name OpenCL ICD Loader ICD loader Vendor OCL Icd free software ICD loader Version 2.2.7 ICD loader Profile OpenCL 1.2

llvmbot commented 5 years ago

@​Simon Atanasyan Thank you very much for your tips. Now I have solved the problem of the HelloWorld (opencl program) program crash in the attachment.At the same time, when running C++ HelloWorld with clang 3.8.1 environment, the "ld-musl-mipsel.so.1" dynamic library can't be found, which can be solved by creating the following software link.

****[loongson@localhost Downloads]$ sudo ln -s /lib64/ld-2.20.so /lib64/ld-musl-mipsel.so.1


Although the problem was solved in this way, I did not understand the mechanism. After many attempts, the last version of mesa I chose was mesa-18.0.5.

For the combination of clang 3.8.1 + mesa 11, if my work plan for the second half of the year goes well, I will do further research, but I don't know what it means? Can you give me some guidance? Should I give up this combination? Looking forward to your reply.

At this point, everything is going well, thank you again for your mention and guidance.

 You can choose to turn off this bug or minimize its priority. Thanks.
atanasyan commented 5 years ago

Your teacher was right - bugs in standard libraries rarely happens. More often the problem is in the code which use/call libraries routines.

As to the "/lib64/ld-musl-mipsel.so.1: bad ELF interpreter: No such file or directory" error - Clang driver passes incorrect arguments to the linker "-dynamic-linker /lib64/ld-musl-mipsel.so.1". This is a bug in the Clang which has been fixed. That's why Clang 8 works ok.

I think you have to resolve problems in compilation your HelloWorld OpneCL example using Clang 8.0. This version of compiler has a lot of fixed bugs in comparison with the Clang 3.0. I'm not an expert in Mesa, but it looks like you need to update its version. The same problem described here https://bugs.freedesktop.org/show_bug.cgi?id=98627.

llvmbot commented 5 years ago

In the clang 3.8.1 environment, the error reported by the C++ HelloWorld program is maybe related to libstdc++. But the program compiled by clang8.0.0 can run normally, which makes me feel confused? Because during in two compilation, I just updated the llvm+clang rpm packages to 8.0.0 version.


​1.compile method

[root@localhost Hello]# clang++ --save-temps -g -o Hello Hello.cpp

​2.Error info

[root@localhost Hello]# ./Hello -bash: ./Hello: /lib64/ld-musl-mipsel.so.1: bad ELF interpreter: No such file or directory

​3.Related links about above issue from google

(1)https://gist.github.com/mscdex/06e39ba86de0585e92ed (2)https://git.realms.tech/JTRealms/lede- wrt1900v1/commit/5ae9a4f830f369b4e8cf20d5bc569946f7cae06e


llvmbot commented 5 years ago

Thank you very much for your suggestion. I have never doubted that libstdc++ will have problems. Just because graduated from college, my teacher tole me a "Truth" that the probability of a bug found in the C library code is almost zero. Meantime, this sentence also hampers my thinking.

Compile the C++ Hello World program with a and b respectively. The compilation steps and results are as follows: clang 3.8.1 compiling log

​1.vresion info

[root@localhost llvm-compile-procedure]# clang --version clang version 3.8.1 (tags/RELEASE_381/final) Target: mips64el-redhat-linux Thread model: posix InstalledDir: /usr/bin [root@localhost llvm-compile-procedure]# clang++ --version clang version 3.8.1 (tags/RELEASE_381/final) Target: mips64el-redhat-linux Thread model: posix InstalledDir: /usr/bin


​2.Print Compile phases

[root@localhost llvm-compile-procedure]# clang -ccc-print-phases Hello.cpp 0: input, "Hello.cpp", c++ 1: preprocessor, {0}, c++-cpp-output 2: compiler, {1}, ir 3: backend, {2}, assembler 4: assembler, {3}, object 5: linker, {4}, image


​3. Internal operation command

[root@localhost llvm-compile-procedure]# clang -### Hello.cpp -o Hello.o clang version 3.8.1 (tags/RELEASE_381/final) Target: mips64el-redhat-linux Thread model: posix InstalledDir: /usr/bin "/usr/bin/clang-3.8" "-cc1" "-triple" "mips64el-redhat-linux" "-S" "-disable-free" "-disable-llvm-verifier" "-main-file-name" "Hello.cpp" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-no-integrated-as" "-mconstructor-aliases" "-fuse-init-array" "-target-cpu" "mips64r2" "-target-abi" "n64" "-mfloat-abi" "hard" "-dwarf-column-info" "-debugger-tuning=gdb" "-resource-dir" "/usr/bin/../lib64/clang/3.8.1" "-c-isystem" "." "-c-isystem" "/usr/include/c++/4.9.3/mips64el-redhat-linux" "-c-isystem" "/usr/include/c++/4.9.3" "-cxx-isystem" "." "-cxx-isystem" "/usr/include/c++/4.9.3/mips64el-redhat-linux" "-cxx-isystem" "/usr/include/c++/4.9.3" "-internal-isystem" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../include/c++/4.9.3" "-internal-isystem" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../include/c++/4.9.3/mips64el-redhat-linux" "-internal-isystem" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../include/c++/4.9.3/backward" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/bin/../lib64/clang/3.8.1/include" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdeprecated-macro" "-fno-dwarf-directory-asm" "-fdebug-compilation-dir" "/root/TarAll/llvm-compile-procedure" "-ferror-limit" "19" "-fmessage-length" "132" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "/tmp/Hello-4888b6.s" "-x" "c++" "Hello.cpp"

"/usr/bin/as" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-KPIC" "-EL" "-o" "/tmp/Hello-c5d20e.o" "/tmp/Hello-4888b6.s"

"/usr/bin/ld" "--eh-frame-hdr" "-m" "elf64ltsmip" "-dynamic-linker" "/lib64/ld-musl-mipsel.so.1" "-o" "Hello.o" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../lib64/crt1.o" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../lib64/crti.o" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/crtbegin.o" "-L/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3" "-L/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../lib64" "-L/usr/bin/../lib64" "-L/lib/../lib64" "-L/usr/lib/../lib64" "-L/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3" "-L/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../.." "-L/usr/bin/../lib" "-L/lib" "-L/usr/lib" "/tmp/Hello-c5d20e.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/crtend.o" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../lib64/crtn.o"


​4. Preprocess stage

[root@localhost llvm-compile-procedure]# clang++ -E Hello.cpp [root@localhost llvm-compile-procedure]# echo $? 0


​5. Lexical Analysis

[root@localhost llvm-compile-procedure]# clang++ -fmodules -fsyntax-only -Xclang -dump-tokens Hello.cpp [root@localhost llvm-compile-procedure]# echo $? 0


​6. Semantic Analysis

[root@localhost llvm-compile-procedure]# clang++ -fmodules -fsyntax-only -Xclang -ast-dump Hello.cpp [root@localhost llvm-compile-procedure]# echo $? 0


​7. Code Generation(Generate an IR code with a .bc and a .ll suffix)

[root@localhost llvm-compile-procedure]# clang++ -emit-llvm -c Hello.cpp -o Hello.bc Opts.Triple is: mips64el-redhat-linux [root@localhost llvm-compile-procedure]# ls Hello.bc Hello.bc [root@localhost llvm-compile-procedure]# file Hello.bc Hello.bc: LLVM IR bitcode

[root@localhost llvm-compile-procedure]# clang++ -O3 -S -emit-llvm Hello.cpp -o Hello.ll Opts.Triple is: mips64el-redhat-linux [root@localhost llvm-compile-procedure]# file Hello.ll Hello.ll: C source, ASCII text, with very long lines


​8. Assemble Code

clang++ -S Hello.cpp -o Hello.s


​9. Generate executables and run

[root@localhost llvm-compile-procedure]# clang++ -g -o Hello Hello.cpp Opts.Triple is: mips64el-redhat-linux [root@localhost llvm-compile-procedure]# ./Hello -bash: ./Hello: /lib64/ld-musl-mipsel.so.1: bad ELF interpreter: No such file or directory


​10. Simplify the above [4-9] stages

clang++ -save-temps Hello.cpp -o Hello

clang 8.0.0 compiling log

​1. clang version info

[root@localhost Hello]# clang --version clang version 8.0.0 Target: mips64el-redhat-linux Thread model: posix InstalledDir: /usr/bin [root@localhost Hello]# clang++ --version clang version 8.0.0 Target: mips64el-redhat-linux Thread model: posix InstalledDir: /usr/bin


​2.Print Compile phases

[root@localhost Hello]# clang -ccc-print-phases Hello.cpp 0: input, "Hello.cpp", c++ 1: preprocessor, {0}, c++-cpp-output 2: compiler, {1}, ir 3: backend, {2}, assembler 4: assembler, {3}, object 5: linker, {4}, image


​3. Internal operation command

[root@localhost Hello]# clang -### Hello.cpp -o Hello.o clang version 8.0.0 Target: mips64el-redhat-linux Thread model: posix InstalledDir: /usr/bin "/usr/bin/clang-8" "-cc1" "-triple" "mips64el-redhat-linux" "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "Hello.cpp" "-mrelocation-model" "pic" "-pic-level" "1" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-fuse-init-array" "-target-cpu" "mips64r2" "-target-feature" "-noabicalls" "-target-abi" "n64" "-mfloat-abi" "hard" "-dwarf-column-info" "-debugger-tuning=gdb" "-resource-dir" "/usr/lib64/clang/8.0.0" "-c-isystem" "." "-c-isystem" "/usr/include/c++/4.9.3/mips64el-redhat-linux" "-c-isystem" "/usr/include/c++/4.9.3" "-cxx-isystem" "." "-cxx-isystem" "/usr/include/c++/4.9.3/mips64el-redhat-linux" "-cxx-isystem" "/usr/include/c++/4.9.3" "-internal-isystem" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../include/c++/4.9.3" "-internal-isystem" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../include/c++/4.9.3/mips64el-redhat-linux" "-internal-isystem" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../include/c++/4.9.3/backward" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib64/clang/8.0.0/include" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdeprecated-macro" "-fdebug-compilation-dir" "/root/TarAll/llvm-compile-procedure/Hello" "-ferror-limit" "19" "-fmessage-length" "132" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "/tmp/Hello-99daa5.o" "-x" "c++" "Hello.cpp" "-faddrsig" "/usr/bin/ld" "--eh-frame-hdr" "-m" "elf64ltsmip" "-dynamic-linker" "/lib64/ld.so.1" "-o" "Hello.o" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../lib64/crt1.o" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../lib64/crti.o" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/crtbegin.o" "-L/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3" "-L/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../lib64" "-L/usr/bin/../lib64" "-L/lib/../lib64" "-L/usr/lib/../lib64" "-L/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3" "-L/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../.." "-L/usr/bin/../lib" "-L/lib" "-L/usr/lib" "/tmp/Hello-99daa5.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/crtend.o" "/usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3/../../../../lib64/crtn.o"


The operation steps 4-9 are omitted here, but the execution results are correct.


​10. Simplify the above [4-9] stages

clang++ -save-temps Hello.cpp -o Hello [root@localhost Hello]# clang++ -save-temps Hello.cpp -o Hello [root@localhost Hello]# ./Hello Hello World!

atanasyan commented 5 years ago

All crashes are related to libstdc++ and unrelated to Mesa and/or OpenCL. Can you:

a) Compile any trivial C++ "hello world" application like below using clang 3.8.1?

include

using namespace std; int main() { cout << "Hello, World!"; return 0; }

b) Build Clang 8.0 and compile the same trivial application?

llvmbot commented 5 years ago

@​Simon Atanasyan To be honest, this above problem with the Mesa 11 package and is caused by upgrading llvm. Which is the just version of mesa that matches llvm8.0, so that the OpenCL development environment can be successfully built on the Fedora 21 platform.

For the "Free invalid pointer" problem of clang 3.8.1 mentioned in the previous comment, I made the following changes to the source code by patching:


/ Create a default constructor for the TargetOptions class on the mips64el platform, and skip the assignment to Opts.Triple by macro detection in the ParseTargetArgs function of the file CompilerInvocation.cpp./

diff -Nuar a/cfe-3.8.1.src/include/clang/Basic/TargetOptions.h b/cfe-3.8.1.src/include/clang/Basic/TargetOptions.h --- a/cfe-3.8.1.src/include/clang/Basic/TargetOptions.h 2015-06-11 10:53:41.000000000 -0400 +++ b/cfe-3.8.1.src/include/clang/Basic/TargetOptions.h 2019-07-09 11:29:00.359434024 -0400 @@ -47,6 +47,9 @@ std::vector Features;

std::vector Reciprocals; +#if defined(__mips64) && defined(_LP64)

diff -Nuar a/cfe-3.8.1.src/lib/Frontend/CompilerInvocation.cpp b/cfe-3.8.1.src/lib/Frontend/CompilerInvocation.cpp --- a/cfe-3.8.1.src/lib/Frontend/CompilerInvocation.cpp 2016-01-12 16:01:56.000000000 -0500 +++ b/cfe-3.8.1.src/lib/Frontend/CompilerInvocation.cpp 2019-07-09 11:31:14.402400117 -0400 @@ -44,6 +44,7 @@

include

include <sys/stat.h>

include

+#include using namespace clang;

//===----------------------------------------------------------------------===// @@ -2027,11 +2028,14 @@ Opts.FPMath = Args.getLastArgValue(OPT_mfpmath); Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature); Opts.LinkerVersion = Args.getLastArgValue(OPT_target_linker_version);


Although the above modification is not flexible enough, it solves the problem of Triple parsing, and the compilation process begins to enter the CodeGeneration phase.

Although the above modification is not flexible enough, it solves the problem of Triple parsing, and the compilation process begins to enter the CodeGeneration phase. The new problems that come with it are as follows: The complete GDB stack information is shown below:


​0 0x0000005555936a5c in __GI_raise (sig=) at ../sysdeps/unix/sysv/linux/raise.c:55

​1 0x0000005555938be0 in __GI_abort () at abort.c:89

​2 0x000000555597b860 in __libc_message (do_abort=, fmt=) at ../sysdeps/posix/libc_fatal.c:175

​3 0x000000555598c22c in malloc_printerr (ptr=, str=0x5555a77f50 "free(): invalid pointer", action=3)

at malloc.c:4974

​4 _int_free (have_lock=0, p=, av=) at malloc.c:3841

​5 __GI___libc_free (mem=) at malloc.c:2951

​6 0x000000555888df00 in operator delete(void*) () from /lib64/libLLVM-3.8.so

​7 0x00000055588fe004 in std::string::_M_mutate(unsigned long, unsigned long, unsigned long) () from /lib64/libLLVM-3.8.so

​8 0x0000005558908214 in std::string::replace(unsigned long, unsigned long, char const*, unsigned long) ()

from /lib64/libLLVM-3.8.so

​9 0x00000055577307e0 in replace (k2=, k1=, i2=..., i1=..., this=0x1200f8aa8)

at /usr/include/c++/4.9.3/bits/basic_string.h:1671

​10 assign<char const*> (last=, first=, this=0x1200f8aa8)

at /usr/include/c++/4.9.3/bits/basic_string.h:1176

​11 llvm::Timer::init (this=0x1200f8a68, N=..., tg=...) at /root/rpmbuild/BUILD/llvm-3.8.1.src/lib/Support/Timer.cpp:104

​12 0x0000005557730864 in llvm::Timer::init (this=0x1200f8a68, N=...)

at /root/rpmbuild/BUILD/llvm-3.8.1.src/lib/Support/Timer.cpp:99

​13 0x0000005556279300 in Timer (N=..., this=0x1200f8a68) at /usr/include/llvm/Support/Timer.h:88

​14 BackendConsumer (CoverageInfo=0x0, C=..., OS=, LinkModules=..., InFile="input.cl", TimePasses=false,

LangOpts=..., TargetOpts=..., CodeGenOpts=..., PPOpts=..., HeaderSearchOpts=..., Diags=..., Action=clang::Backend_EmitNothing,
this=0x1200f8a20) at /root/rpmbuild/BUILD/cfe-3.8.1.src/lib/CodeGen/CodeGenAction.cpp:78

​15 clang::CodeGenAction::CreateASTConsumer (this=0xffffff2db0, CI=..., InFile=...)

at /root/rpmbuild/BUILD/cfe-3.8.1.src/lib/CodeGen/CodeGenAction.cpp:723

​16 0x0000005555d5904c in clang::FrontendAction::CreateWrappedASTConsumer (this=, CI=..., InFile=...)

at /root/rpmbuild/BUILD/cfe-3.8.1.src/lib/Frontend/FrontendAction.cpp:140

​17 0x0000005555d5a7a0 in clang::FrontendAction::BeginSourceFile (this=, CI=..., Input=...)

at /root/rpmbuild/BUILD/cfe-3.8.1.src/lib/Frontend/FrontendAction.cpp:319

​18 0x0000005555d28678 in clang::CompilerInstance::ExecuteAction (this=0xffffff2ca0, Act=...)

at /root/rpmbuild/BUILD/cfe-3.8.1.src/lib/Frontend/CompilerInstance.cpp:839

​19 0x0000005555b4710c in (anonymous namespace)::compile_llvm (llvm_ctx=...,

source="\n__kernel void hello_kernel(__global const float *a,\n\t\t\t\t\t\t__global const float *b,\n\t\t\t\t\t\t__global float *result)\n{\n    int gid = get_global_id(0);\n\n    result[gid] = a[gid] + b[gid];\n}\n",
headers=std::vector of length 0, capacity 0, name="input.cl", triple="r600--", processor="caicos", opts="",
address_spaces=..., optimization_level=@0xffffff3a88: 2, r_log="") at llvm/invocation.cpp:259

​20 0x0000005555b4809c in clover::compile_program_llvm (

source="\n__kernel void hello_kernel(__global const float *a,\n\t\t\t\t\t\t__global const float *b,\n\t\t\t\t\t\t__global float *result)\n{\n    int gid = get_global_id(0);\n\n    result[gid] = a[gid] + b[gid];\n}\n",
headers=std::vector of length 0, capacity 0, ir=<optimized out>, target="caicos-r600--", opts="", r_log="")
at llvm/invocation.cpp:864

​21 0x0000005555b3c7d8 in clover::program::build (this=0x120093090, devs=..., opts=0x5555b9c558 "",

headers=std::vector of length 0, capacity 0) at core/program.cpp:63

​22 0x0000005555b1fa98 in clBuildProgram (d_prog=, num_devs=, d_devs=0x0, p_opts=,

pfn_notify=0x0, user_data=0x0) at api/program.cpp:184

​23 0x00000055555ee4ac in clBuildProgram (program=0x120093098, num_devices=, device_list=0x0, options=0x0,

pfn_notify=0x0, user_data=<optimized out>) at ocl_icd_loader_gen.c:386

​24 0x0000000120001d8c in CreateProgram (context=0x120018018, device=0x120041d38, fileName=0x120002e68 "HelloWorld.cl")

at /root/TarAll/src/Chapter_2/HelloWorld/HelloWorld.cpp:158

​25 0x00000001200022f8 in main (argc=1, argv=0xffffffb3a8) at /root/TarAll/src/Chapter_2/HelloWorld/HelloWorld.cpp:255

In response to the above questions, I am still doing source code analysis, trying to solve this problem. Can you give me some good tips? Thanks again.

llvmbot commented 5 years ago

@​Simon Atanasyan Many thanks for your advices. As you can see from Mesa's rpmbuild SPEC file, there is a compilation dependency between the Mesa package and llvm/clang, as shown below.

This compilation dependency causes the high version of the mesa package to be compiled, while the early compilations such as "libclc", "clinfo", and "ocl-icd" will not be available, and there is also no way to accurately determine the version of Mesa that need to compile.


setction of mesa.spec

%if 0%{?with_llvm} %if 0%{?with_private_llvm} BuildRequires: mesa-private-llvm-devel %else BuildRequires: llvm-devel >= 3.5.0 %if 0%{?with_opencl} BuildRequires: clang-devel >= 3.0 %endif %endif %endif


At 11 o'clock last night, I completed the compilation of llvm-clang 8.0 and started to compile the mesa 11 package according to your suggestions. However, under the Fedora 21 system, there are too many mesa API compatibility issues, one of which is shown below, and because the mesa needs to be recompiled, the number of available Openc Platform returned by the clinfo command is 0.


The llvm 8.0

[root@localhost ~]# llc -version LLVM (http://llvm.org/): LLVM version 8.0.0 Optimized build. Default target: mips64el-redhat-linux Host CPU: (unknown)

Registered Targets: amdgcn - AMD GCN GPUs mips - MIPS (32-bit big endian) mips64 - MIPS (64-bit big endian) mips64el - MIPS (64-bit little endian) mipsel - MIPS (32-bit little endian) nvptx - NVIDIA PTX 32-bit nvptx64 - NVIDIA PTX 64-bit r600 - AMD GPUs HD2XXX-HD6XXX


The clang 8.0

[root@localhost ~]# clang++ --version clang version 8.0.0 Target: mips64el-redhat-linux Thread model: posix InstalledDir: /usr/bin


Compatibility issues with mesa and llvm api versions

In file included from draw/draw_llvm.c:45:0: ./gallivm/lp_bld_intr.h:63:20: error: unknown type name 'LLVMAttribute' LLVMAttribute attr); ^ draw/draw_llvm.c: In function 'create_jit_sampler_type': draw/draw_llvm.c:178:22: warning: unused variable 'target' [-Wunused-variable] LLVMTargetDataRef target = gallivm->target; ^ draw/draw_llvm.c: In function 'create_jit_context_type': draw/draw_llvm.c:218:22: warning: unused variable 'target' [-Wunused-variable] LLVMTargetDataRef target = gallivm->target; ^ draw/draw_llvm.c: In function 'create_jit_vertex_header': draw/draw_llvm.c:377:22: warning: unused variable 'target' [-Wunused-variable] LLVMTargetDataRef target = gallivm->target; ^ draw/draw_llvm.c: In function 'draw_llvm_generate': draw/draw_llvm.c:1580:10: error: implicit declaration of function 'LLVMAddAttribute' [-Werror=implicit-function-declaration] LLVMAddAttribute(LLVMGetParam(variant_func, i), ^ draw/draw_llvm.c:1581:27: error: 'LLVMNoAliasAttribute' undeclared (first use in this function) LLVMNoAliasAttribute); ^ draw/draw_llvm.c:1581:27: note: each undeclared identifier is reported only once for each function it appears in draw/draw_llvm.c: In function 'draw_gs_llvm_generate': draw/draw_llvm.c:2123:27: error: 'LLVMNoAliasAttribute' undeclared (first use in this function) LLVMNoAliasAttribute); ^ cc1: some warnings being treated as errors Makefile:2115: recipe for target 'draw/draw_llvm.lo' failed make[3]: [draw/draw_llvm.lo] Error 1 make[3]: Waiting for unfinished jobs.... make[3]: Leaving directory '/root/rpmbuild/BUILD/mesa-20151218/src/gallium/auxiliary' Makefile:580: recipe for target 'all-recursive' failed make[2]: [all-recursive] Error 1 make[2]: Leaving directory '/root/rpmbuild/BUILD/mesa-20151218/src/gallium' Makefile:674: recipe for target 'all-recursive' failed make[1]: [all-recursive] Error 1 make[1]: Leaving directory '/root/rpmbuild/BUILD/mesa-20151218/src' Makefile:619: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1 error: Bad exit status from /var/tmp/rpm-tmp.wvfWMM (%build)

RPM build errors: Bad exit status from /var/tmp/rpm-tmp.wvfWMM (%build)


The number of OpenCL platfoms

[root@localhost SPECS]# clinfo Number of platforms 0


[root@localhost SPECS]# rpm -qa | grep libOpenCL mesa-libOpenCL-devel-11.1.0-5.20151218.fc21.loongson.6.mips64el mesa-libOpenCL-11.1.0-5.20151218.fc21.loongson.6.mips64el [root@localhost SPECS]# yum info mesa-libOpenCL Loaded plugins: auto-update-debuginfo, langpacks Installed Packages Name : mesa-libOpenCL Arch : mips64el Version : 11.1.0 Release : 5.20151218.fc21.loongson.6 Size : 1.0 M Repo : installed From repo : /mesa-libOpenCL-11.1.0-5.20151218.fc21.loongson.6.mips64el Summary : Mesa OpenCL runtime library URL : http://www.mesa3d.org License : MIT Description : Mesa OpenCL runtime library.

atanasyan commented 5 years ago

Unfortunately I can not reproduce the bug on the recent version of LLVM/Clang because I have no access to MIPS host with appropriate video subsystem. LLVM/Clang 3.8 was released three years ago. Could you check the problem using LLVM/Clang 7.x or 8.x?

llvmbot commented 5 years ago

When I compiled the clang package, the following warning message reported. Figuring out the warnings would be my job this Saturday.


[root@localhost SPECS]# rpmbuild -bb clang.spec Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.viOlsk

-- Generating done CMake Warning: Manually-specified variables were not used by the project:

CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS_RELEASE
CMAKE_Fortran_FLAGS_RELEASE
INCLUDE_INSTALL_DIR
LIB_INSTALL_DIR
LIB_SUFFIX
SHARE_INSTALL_PREFIX
SYSCONF_INSTALL_DIR
llvmbot commented 5 years ago

when I debug the "HelloWorld" with GNU debuger, The complete function call stack information is as follows:


(gdb) bt

​0 0x0000005555936a5c in __GI_raise (sig=) at ../sysdeps/unix/sysv/linux/raise.c:55

​1 0x0000005555938be0 in __GI_abort () at abort.c:89

​2 0x000000555597b860 in __libc_message (do_abort=, fmt=) at ../sysdeps/posix/libc_fatal.c:175

​3 0x000000555598c22c in malloc_printerr (ptr=, str=0x5555a77f50 "free(): invalid pointer", action=3)

at malloc.c:4974

​4 _int_free (have_lock=0, p=, av=) at malloc.c:3841

​5 __GI___libc_free (mem=) at malloc.c:2951

​6 0x00000055556728f0 in operator delete (ptr=) at ../../../../libstdc++-v3/libsupc++/del_op.cc:46

​7 0x0000005555708298 in deallocate (this=, __p=)

at /builddir/build/BUILD/gcc-4.9.3/obj-mips64el-redhat-linux/mips64el-redhat-linux/libstdc++-v3/include/ext/new_allocator.h:110

​8 std::string::_Rep::_M_destroy (this=, __a=...)

at /builddir/build/BUILD/gcc-4.9.3/obj-mips64el-redhat-linux/mips64el-redhat-linux/libstdc++-v3/include/bits/basic_string.tcc:449

​9 0x0000005555d3001c in std::string::_Rep::_M_dispose (this=, __a=...)

at /usr/include/c++/4.9.3/bits/basic_string.h:249

​10 0x0000005555d44148 in _M_dispose (__a=..., this=) at /usr/include/c++/4.9.3/bits/basic_string.h:240

​11 ~basic_string (this=0xffffff1d70, __in_chrg=) at /usr/include/c++/4.9.3/bits/basic_string.h:547

​12 ParseTargetArgs (Args=..., Opts=...) at /root/rpmbuild/BUILD/cfe-3.8.1.src/lib/Frontend/CompilerInvocation.cpp:2034

​13 clang::CompilerInvocation::CreateFromArgs (Res=..., ArgBegin=0x120098570, ArgEnd=, Diags=...)

at /root/rpmbuild/BUILD/cfe-3.8.1.src/lib/Frontend/CompilerInvocation.cpp:2072

​14 0x0000005555b46a44 in (anonymous namespace)::compile_llvm (llvm_ctx=...,

source="\n__kernel void hello_kernel(__global const float *a,\n\t\t\t\t\t\t__global const float *b,\n\t\t\t\t\t\t__global float *result)\n{\n    int gid = get_global_id(0);\n\n    result[gid] = a[gid] + b[gid];\n}\n",
headers=std::vector of length 0, capacity 0, name="input.cl", triple="r600--", processor="caicos", opts="",
address_spaces=..., optimization_level=@0xffffff3a88: 1437349920, r_log="") at llvm/invocation.cpp:179

​15 0x0000005555b4806c in clover::compile_program_llvm (

source="\n__kernel void hello_kernel(__global const float *a,\n\t\t\t\t\t\t__global const float *b,\n\t\t\t\t\t\t__global float *result)\n{\n    int gid = get_global_id(0);\n\n    result[gid] = a[gid] + b[gid];\n}\n",

---Type to continue, or q to quit--- headers=std::vector of length 0, capacity 0, ir=, target="caicos-r600--", opts="", r_log="") at llvm/invocation.cpp:864

​16 0x0000005555b3c7a8 in clover::program::build (this=0x120093060, devs=..., opts=0x5555b9c528 "",

headers=std::vector of length 0, capacity 0) at core/program.cpp:63

​17 0x0000005555b1fa68 in clBuildProgram (d_prog=, num_devs=, d_devs=0x0, p_opts=,

pfn_notify=0x0, user_data=0x0) at api/program.cpp:184

​18 0x00000055555ee4ac in clBuildProgram (program=0x120093068, num_devices=, device_list=0x0, options=0x0,

pfn_notify=0x0, user_data=<optimized out>) at ocl_icd_loader_gen.c:386

​19 0x0000000120001d8c in CreateProgram (context=0x120018018, device=0x120041d08, fileName=0x120002e68 "HelloWorld.cl")

at /root/TarAll/src/Chapter_2/HelloWorld/HelloWorld.cpp:158

​20 0x00000001200022f8 in main (argc=1, argv=0xffffffb3a8) at /root/TarAll/src/Chapter_2/HelloWorld/HelloWorld.cpp:255


I noticed the Frame 12, Further information is shown below:

static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args) { 2024 using namespace options; 2025 Opts.ABI = Args.getLastArgValue(OPT_target_abi); 2026 Opts.CPU = Args.getLastArgValue(OPT_target_cpu); 2027 Opts.FPMath = Args.getLastArgValue(OPT_mfpmath); 2028 Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature); 2029 Opts.LinkerVersion = Args.getLastArgValue(OPT_target_linker_version); 2030 Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple)); 2031 Opts.Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ); 2032 // Use the default target triple if unspecified. 2033 if (Opts.Triple.empty()) 2034 Opts.Triple = llvm::sys::getDefaultTargetTriple(); 2035 }

In order to get default Triple, the function “llvm::sys::getDefaultTargetTriple()” was called and a c++ string "mips64el-redhat-linux" returned, After the assignment to the variable -- Opts.Triple-- is completed, the program crashes.

llvmbot commented 2 months ago

@llvm/issue-subscribers-opencl

Author: None (llvmbot)

| | | | --- | --- | | Bugzilla Link | [42663](https://llvm.org/bz42663) | | Version | 3.8 | | OS | Linux | | Attachments | [OpenCL Programming Guide - Chapter 2 Exercise Code](https://user-images.githubusercontent.com/60944935/143759497-f7321d82-1a29-43ba-a618-42dba4939b7a.gz) | | Reporter | LLVM Bugzilla Contributor | | CC | @DougGregor,@zygoloid,@atanasyan | ## Extended Description Recently, I'm learnning the OpenCL Programming Guide adn use clang+llvm3.8.1 to compile the exercise code in Chapter 2 of the book. During the execution of the program, I encountered a serious bug about clang. My Error info: *********************************************************************************** [root@localhost HelloWorld]# ./HelloWorld *** Error in `./HelloWorld': free(): invalid pointer: 0x0000005562f65800 *** ======= Backtrace: ========= /lib64/libc.so.6(+0x9f854)[0x555fb1b854] /lib64/libc.so.6(__libc_free+0x804)[0x555fb2c22c] /lib64/libstdc++.so.6(_ZdlPv+0x20)[0x555f8128f0] /lib64/libstdc++.so.6(_ZNSs4_Rep10_M_destroyERKSaIcE+0x20)[0x555f8a8298] /lib64/libclangFrontend.so(+0x8401c)[0x555fed001c] ======= Memory map: ======== 120000000-120004000 r-xp 00000000 08:02 4719230 /root/TarAll/src/Chapter_2/HelloWorld/HelloWorld 120010000-120014000 r--p 00000000 08:02 4719230 /root/TarAll/src/Chapter_2/HelloWorld/HelloWorld 120014000-120018000 rw-p 00004000 08:02 4719230 /root/TarAll/src/Chapter_2/HelloWorld/HelloWorld 123604000-1236c8000 rwxp 00000000 00:00 0 [heap] 555f730000-555f758000 r-xp 00000000 08:02 4863976 /usr/lib64/ld-2.20.so 555f758000-555f764000 rw-p 00000000 00:00 0 555f764000-555f768000 rw-p 00024000 08:02 4863976 /usr/lib64/ld-2.20.so 555f784000-555f7a0000 r-xp 00000000 08:02 4863583 /usr/lib64/libOpenCL.so.1.0.0 555f7a0000-555f7ac000 ---p 0001c000 08:02 4863583 /usr/lib64/libOpenCL.so.1.0.0 555f7ac000-555f7b0000 rw-p 00018000 08:02 4863583 /usr/lib64/libOpenCL.so.1.0.0 555f7b0000-555f8e8000 r-xp 00000000 08:02 4862493 /usr/lib64/libstdc++.so.6.0.20 555f8e8000-555f8f4000 ---p 00138000 08:02 4862493 /usr/lib64/libstdc++.so.6.0.20 555f8f4000-555f900000 r--p 00134000 08:02 4862493 /usr/lib64/libstdc++.so.6.0.20 555f900000-555f908000 rw-p 00140000 08:02 4862493 /usr/lib64/libstdc++.so.6.0.20 .... ..... *********************************************************************************** My platform info *********************************************************************************** architecture info: [root@localhost HelloWorld]# uname -a Linux localhost 3.10.84-21.fc21.loongson.18.mips64el #&#8203;1 SMP PREEMPT Tue Apr 16 18:41:34 CST 2019 mips64 mips64 mips64 GNU/Linux [root@localhost HelloWorld]# lscpu Architecture: mips64 Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 NUMA node(s): 1 Model name: ICT Loongson-3A R3 (Loongson-3A3000) @ 1399MHz CPU max MHz: 1399.9860 CPU min MHz: 349.9960 NUMA node0 CPU(s): 0-3 &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& rpm packages info: [root@localhost HelloWorld]# rpm -qa | grep llvm llvm-devel-3.8.1-3.fc21.loongson.2.mips64el llvm-static-3.8.1-3.fc21.loongson.2.mips64el llvm-libs-3.8.1-3.fc21.loongson.2.mips64el llvm-3.8.1-3.fc21.loongson.2.mips64el llvm-debuginfo-3.8.1-3.fc21.loongson.2.mips64el [root@localhost HelloWorld]# rpm -qa | grep clang clang-libs-3.8.1-1.fc21.loongson.2.mips64el clang-devel-3.8.1-1.fc21.loongson.2.mips64el clang-analyzer-3.8.1-1.fc21.loongson.2.noarch clang-debuginfo-3.8.1-1.fc21.loongson.2.mips64el clang-3.8.1-1.fc21.loongson.2.mips64el [root@localhost HelloWorld]# rpm -qa | grep libclc libclc-0.0.1-11.20150918git4346c30.fc21.loongson.mips64el libclc-devel-0.0.1-11.20150918git4346c30.fc21.loongson.mips64el [root@localhost HelloWorld]# rpm -qa | grep libOpenCL mesa-libOpenCL-11.1.0-5.20151218.fc21.loongson.6.mips64el mesa-libOpenCL-devel-11.1.0-5.20151218.fc21.loongson.6.mips64el *********************************************************************************** other info: [root@localhost HelloWorld]# llc -version LLVM (http://llvm.org/): LLVM version 3.8.1 Optimized build. Built Jul 8 2019 (07:52:07). Default target: mips64el-redhat-linux Host CPU: (unknown) Registered Targets: amdgcn - AMD GCN GPUs bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) cpp - C++ backend mips - Mips mips64 - Mips64 [experimental] mips64el - Mips64el [experimental] mipsel - Mipsel nvptx - NVIDIA PTX 32-bit nvptx64 - NVIDIA PTX 64-bit r600 - AMD GPUs HD2XXX-HD6XXX systemz - SystemZ [root@localhost HelloWorld]# llc -version LLVM (http://llvm.org/): LLVM version 3.8.1 Optimized build. Built Jul 8 2019 (07:52:07). Default target: mips64el-redhat-linux Host CPU: (unknown) Registered Targets: amdgcn - AMD GCN GPUs bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) cpp - C++ backend mips - Mips mips64 - Mips64 [experimental] mips64el - Mips64el [experimental] mipsel - Mipsel nvptx - NVIDIA PTX 32-bit nvptx64 - NVIDIA PTX 64-bit r600 - AMD GPUs HD2XXX-HD6XXX systemz - SystemZ [root@localhost HelloWorld]# clinfo Number of platforms 1 Platform Name Clover Platform Vendor Mesa Platform Version OpenCL 1.1 MESA 11.1.0 Platform Profile FULL_PROFILE Platform Extensions cl_khr_icd Platform Extensions function suffix MESA Platform Name Clover Number of devices 1 Device Name AMD CAICOS (DRM 2.49.0, LLVM 3.8.1) Device Vendor AMD Device Vendor ID 0x1002 Device Version OpenCL 1.1 MESA 11.1.0 Driver Version 11.1.0 Device OpenCL C Version OpenCL C 1.1 Device Type GPU Device Profile FULL_PROFILE Max compute units 2 Max clock frequency 775MHz Max work item dimensions 3 Max work item sizes 256x256x256 Max work group size 256 Preferred work group size multiple 64 Preferred / native vector sizes char 16 / 16 short 8 / 8 int 4 / 4 long 2 / 2 half 0 / 0 (n/a) float 4 / 4 double 0 / 0 (n/a) Half-precision Floating-point support (n/a) Single-precision Floating-point support (core) Denormals No Infinity and NANs Yes Round to nearest Yes Round to zero No Round to infinity No IEEE754-2008 fused multiply-add No Support is emulated in software No Correctly-rounded divide and sqrt operations No Double-precision Floating-point support (n/a) Address bits 32, Little-Endian Global memory size 1073741824 (1024MiB) Error Correction support No Max memory allocation 268435456 (256MiB) Unified memory for Host and Device Yes Minimum alignment for any data type 128 bytes Alignment of base address 1024 bits (128 bytes) Global Memory cache type None Image support No Local memory type Local Local memory size 32768 (32KiB) Max constant buffer size 268435456 (256MiB) Max number of constant args 13 Max size of kernel argument 1024 Queue properties Out-of-order execution No Profiling Yes Profiling timer resolution 0ns Execution capabilities Run OpenCL kernels Yes Run native kernels No Device Available Yes Compiler Available Yes Device Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store NULL platform behavior clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) Clover clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) Success [MESA] clCreateContext(NULL, ...) [default] Success [MESA] clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1) Platform Name Clover Device Name AMD CAICOS (DRM 2.49.0, LLVM 3.8.1) clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (1) Platform Name Clover Device Name AMD CAICOS (DRM 2.49.0, LLVM 3.8.1) ICD loader properties ICD loader Name OpenCL ICD Loader ICD loader Vendor OCL Icd free software ICD loader Version 2.2.7 ICD loader Profile OpenCL 1.2