Does LLVM support or ever support PathProfiling well? - profiling

Our project needs a tool to gather path profiling information of a program, so I turn to LLVM for help.
However, it seems the function we need is removed since version 3.4. I try the version 3.3 instead, and I find that edge profiling, optimal edge profiling works well. When it comes to path profiling, it simply doesn't work.
And I can't find libprofile_rt.so in version 3.3 build, I download one from http://rpmfind.net/ instead.
The command I use:
opt -insert-path-profiling -o example.pp.bc example.bc
lli -load WHERE_YOUR_LIBPROFILE_RE_SO_LIES/libprofile_rt.so example.pp.bc
#it produces llvmprof.out successfully
llvm-prof example.pp.bc
#then following error occurs : llvm-prof: Unknown packet type #5!
So, my question is :
1.Is there a new version that support PathProfiling again?
2.Any historical version of LLVM support PathProfiling well? If any, please tell me the version number ...
I've checked some old dev mails. The answer to my questions seems to be "NO". But the newest mails were written 2 years ago. Since LLVM is pretty hot these years and a long time passed, I want to make sure the questions above again and get the up-to-date answer.
I hope I make the problem I met clear. Your comments are very welcome.
Thanks

Related

Upgrading gcc to 8/9 trigger "Error: unsupported instruction `vmovdqu'" while gcc-7 runs fine

I compile Apache Arrow (https://arrow.apache.org/) with CMake 3.15 and gcc/g++-7 (7.5.0) and it goes well. However, when I upgrade gcc/g++ to 8(8.4.0) and 9(9.3.0) with the same CMake version, I got the following errors:
/tmp/ccrlCxYO.s: Assembler messages:
/tmp/ccrlCxYO.s:5651: Error: unsupported instruction `vmovdqu'
make[2]: *** [src/parquet/CMakeFiles/parquet_objlib.dir/build.make:194: src/parquet/CMakeFiles/parquet_objlib.dir/encoding.cc.o] Error 1
The target file (encoding.cc) is a pure C++ file. It uses Intel Intrinsics, but does not contain any assembly code.
This is the first time I see an "Assembler message" error. So I request some help understanding what it means. My question:
When would the assembler complain about unsupported instruction? I have seen unsupported instruction at runtime before, but not this "Assembler message". As this happens after upgrading GCC, I guess this is a new feature of the new compiler/assembler? I cannot find any document, so if anyone can point to me any doc explaining this it would be very appreciated.
Adding "-mavx" to target_compile_options does not solve the problem. Anyone has a suggestion of solution to the problem?
Thank you!
TLDR: I found the solution is to add "-mavx512bw" to target_compile_options
Please continue reading if you want to hear more detail about the root cause, and how I found it.
After googling a bit I found this webpage talking about a bug of GNU AS. https://www.mail-archive.com/bug-binutils#gnu.org/msg30524.html
That webpage reports that AS does not recognize "vmovdqu16", which needs the support of AVX512VL+AVX512BW. However, the assembler reports an error message saying "vmovdqu" is not supported.
This reminds me that I may encounter the same issue. The AS actually receives "vmovdqu8/16/32" but it reports "vmovdqu". This error message is very misleading because "vmovdqu" and "vmovdqu16" need different instruction set supports. The former only need AVX, but the latter need AVX512BW+AVX512VL.
I decided to give it a try and add -mavx512bw to the compile option ( I already have avx512vl before). It actually fixes the problem.
So I think the whole story is: the newer version of GCC uses some new SIMD instruction, which the old GCC did not use.
Hope this helps someone who also run into similar problems.

Calling a c++ function on Rstudio on a MAC and getting (clang: error: unsupported option '-fopenmp')

I know how to code but I really do not know my way around a computer.
I have a program that I have to run for my master thesis. It is a code with multiple collabs and runs perfectly on Linux. However, it is a very complex simulational code and therefore it takes time to run for multiple parameters. I've been using my Linux at the university to run it but would like to run some of it on my personal computer (MAC OS). It works by using the R language to call upon c++ functions as follows (being filename a code on c++).
On a Rstudio script:
Sys.setenv("PKG_CPPFLAGS" = "-fopenmp -DPARALLEL")
system("rm filename.so")
system("rm filename.o")
system ("R CMD SHLIB filename.cpp")
dyn.load("filename.so")
After system ("R CMD SHLIB filename.cpp") I get error:
clang: error: unsupported option '-fopenmp'
make: *** [filename.o] Error 1
I've researched on the subject and found this
Enable OpenMP support in clang in Mac OS X (sierra & Mojave)
I've Installed LLVM, yet I do not know how to use it in this case.
How do I use it in this case?
Thank you in advance.
"Don't do it that way." Read up on R and Rcpp and use the proper tools (especially for packaging and/or compiling) which should pick up OpenMP where possible. In particular,
scan at least the Rcpp Introduction vignette
also look at the Rcpp Attributes vignette
"Just say no" to building the compilation commands by hand unless you know what you are doing with R and have read Writing R Extensions carefully a few times. It can be done, I used to show how in tutorials and workshops (see old slides from 12-15 years ago on my website) but we first moved to package inline which helps here, and later relied on the much better Rcpp Attributes.
Now, macOS has some extra hurdles in which tools work and which ones don't. The rcpp-devel mailing list may be of help, the default step is otherwise to consult the tutorial by James.
Edit: And of course if you "just want the above to work" try the obvious step of removing the part causing the error, i.e. use
Sys.setenv("PKG_CPPFLAGS" = "")
as your macOS box appears to have a compiler but not OpenMP (which, as I understand it, is the default thanks to some "surprising" default choices at Apple -- see the aforementioned tutorial for installation help.)

How to Change LLDB Version CLion Uses?

TL;DR: I want to change the version of LLDB that CLion (v2016.3.5) uses to LLDB v3.8.1. Can I do this? If so, how?
Longer explanation of the question:
CLion is a C++ IDE that I've been using for a few years now. Recently, they released version 2016.3.X. When they went from 2016.2 to 2016.3, they changed the "built in lldb" version from v3.8.1 to v3.9.0. This has caused a problem for me as v3.9.0 doesn't seem to want to work correctly.
When I, say, "print some_var_name" (while at a break point) I get an error (below):
Assertion failed: (D->getCachedLinkage() == LV.getLinkage()), function
getLVForDecl, file
/Applications/buildAgent/work/92515a49514b3993/lldb/llvm/tools/clang/lib/AST/Decl.cpp,
line 1360.
The source of this file can be found here: https://clang.llvm.org/doxygen/Decl_8cpp_source.html
My options are
(1) Figure out why that error is happening. Creating a simple "hello world"program and debugging seems to work. This tells me that it has something to do with my code base, I suppose. But I have over 20,000 lines of code. So figuring out what's doing it would be extremely time consuming. LLDB version 3.8.1 seems like a faster/easier fix since it was doing me just fine in the past.
(2) Use an old version of CLion (which, by default, utilizes LLDB version 3.8.1)
(3) Get the new(er) version(s) of CLion to use LLDB version 3.8.1.
Thanks for any help/guidance.
I assumed you could just enter the path in this preferences page:

Simulation terminated with exit code: 132

I am Mac OS 10.11 (El Capitan) user. I used 4.6 and when I tried to build some simulation I always get "Simulation terminated with exit code: 139" and couldn’t do nothing at all with that. I thought that when I install 5.0 then everything will be fine, but now I get something like that:
Simulation terminated with exit code: 132
Working directory: /Users/JL_Data/omnetpp-5.0/samples/tictoc
Command line: tictoc -r 0 --debug-on-errors=false omnetpp.ini
Environment variables:
PATH=/Users/JL_Data/omnetpp-5.0/bin::/usr/bin:/bin:/usr/sbin:/sbin
DYLD_LIBRARY_PATH=/Users/JL_Data/omnetpp-5.0/lib::
OMNETPP_IMAGE_PATH=/Users/JL_Data/omnetpp-5.0/images
And when I tried open some simulation in terminal I get:
Illegal instruction: 4
Do you have some idea what can I do with that problem? I tried to find something on the internet, but after one day I do not get any idea.
If you need some more information, please let me know.
As it is right now, your question is not completely clear, since it requires one to be familiar with omnet++ and probably some experience installing and setting it up. However, let me make a couple guesses.
First, Illegal instruction. This usually occurs when the binary was built for an architecture different than the one it's being run on; e.g. when then SSE2 or AVX instructions are present in the binary code, but are missing on the CPU.
See, for example, this SO question:
Find which assembly instruction caused an Illegal Instruction error without debugging
There is also a question that discusses exactly your problem, namely, "Illegal instruction: 4" on OS X:
What is the "Illegal Instruction: 4" error and why does "-mmacosx-version-min=10.x" fix it?
Now, since omnet++ appears to be an open source project, I expect it to have a mailing list and / or an IRC channel. Indeed, here is the communications page on the official website that links to a Google Groups-based mailing list:
https://omnetpp.org/get-involved
https://groups.google.com/forum/#!forum/omnetpp
I advise you to get in touch with the developers with a thorough description of your problem, since the chances of them knowing the solution are significantly higher compared to the chances of there being a user on SO who has faced similar problems when installing an identical version of omnet++ on an identical version of Mac OS X.

"Compile Server Error." while building OpenCL kernels

I am trying to compile OpenCL kernels on OS X. Everything is ok when there are just a few lines. However, after the code grows over 1.5k lines, clGetProgramBuildInfo with CL_PROGRAM_BUILD_LOG flag returned "Compile Server Error." every time. I googled but found nothing about it. Could anyone help me?
You can learn the meaning of OpenCL error codes by searching in cl.h. In this case, -11 is just what you'd expect, CL_BUILD_PROGRAM_FAILURE. It's certainly curious that the build log is empty. Two questions:
1.) What is the return value from clGetProgramBuildInfo?
2.) What platform are you on? If you are using Apple's OpenCL implementation, you could try setting CL_LOG_ERRORS=stdout in your environment. For example, from Terminal:
$ CL_LOG_ERRORS=stdout ./myprog
It's also pretty easy to set this in Xcode (Edit Scheme -> Arguments -> Environment Variables).
Please find the original answer by #James
This unhelpful error message indicates that there is bug in Apple's compiler. You can inform them of such bugs by using the Apple Bug Reporting System.