How to run an ARM multi-threaded program in Ruby system - c++

I fully implemented the content of the following webpage:
http://www.gem5.org/documentation/learning_gem5/part3/running/
The program can be compiled under X86 according to webpage requirements,however I want to get an ARM binary file,so I use the following code to compile it:
aarch64-linux-gnu-g++ -o threads threads.cpp -pthread -std = c ++ 11 -static
I can compile and get the binary file, but I get the following error during running:
erminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted
Since the compiled ARM binary file is not provided in gem5's bin folder, does it mean that gem5 does not support running ARM multi-threaded programs, or my compilation options are wrong?

That program fails to run with -static on both qemu-aarch64 and Ubuntu 20.04 amd64 native (always check other more stable platforms :-))
It is known that there are some nongem5-specific problems with -static and threads, see e.g.: when g++ static link pthread, cause Segmentation fault, why?
If workaround mentioned there don't work, you can now also run with dynamic linking as mentioned at: How to run a dynamically linked executable syscall emulation mode se.py in gem5? I've just tested it now and it worked with that example.
And at last note that there is a serious multithread SE Ruby problem which we are not sure how to solve: https://gem5.atlassian.net/browse/GEM5-676

Related

Facing "the application was unable to start correctly 0xc00007b." after i compiled my code with g++ compiler on command prompt in Windows 10

I compiled a simple "Hello World" C++ code in command prompt (Windows 10), and then tried to run a.exe file, but got this well known error. Then I created a project in VS2019, and was able to run same code without any problem. Upon doing ldd a.exe all the dependent dlls were inside "/cygdrive/c/WINDOWS/SYSTEM32", so i copied executable over there, but still faced the same issue.
I also tried running in administrator mode, changing/troubleshooting the compatibility option to Windows 7/8 but none of them worked.
A couple of months back I was able to compile and run a code in this manner, but since then many software have been changed, so I kind off lost track which software change can cause this issue.
g++ -v ==>
Target: x86_64-w64-mingw32
{Several configurations}...
Thread model: win32
gcc version 4.6.3
Is there some common solution which I can try?

Cannot enable pthreads for Netbeans

When I try to use the c++11 thread library in Netbeans (g++ 4.8.2 ubuntu 14.04 LTS) I get the following error:
##Failure Location unknown## : Error
Test name: Array2DTest::testArray2D
uncaught exception of type std::system_error
- Enable multithreading to use std::thread: Operation not permitted
I tried enabling pthreads by adding -pthread as a additional option for the compilation line as suggested by similar questions and the output seems to show the option is getting passed:
I've also tried compiling simple "hello world" type tests directly from the terminal and they actually work! For some reason I just can't get netbeans to enable it. The only thing I can think of is I'm trying to test out some multithreading functions in a cppunit test so is it possible this is messing up the pthread option?
EDIT: I found that taking out pkg-config --libs opencv results in the -pthreads switch working correctly, but I still cant figure out how to get both of them working correctly together.
EDIT2: I was able to get it to compile by removing the -pthread switch and inserting -lpthread before pkg-config --libs opencv. The solution only worked by directly linking to the lpthread library and it had to be before the opencv libraries. Have no idea why, and it also took me a good 4 hours/blood shot eyes to figure this out.
I think this was possibly a bug with my version of gcc. The only thing that worked consistently was using the flag:
-Wl,--no-as-needed
Adding -pthread didn't work at all. Adding -lpthread made some compilations work, failed for others, and just generally gave strange behavior.

Application segmentation fault, only when compiling on Windows with MinGW

I'm trying to compile one of my games on Windows, but unfortunately, no matter what, I'm getting this segmentation fault every time I run the program.
Compilation is successful, and without any warning.
Program received signal SIGSEGV, Segmentation fault.
__chkstk_ms () at ../../../../../src/gcc-4.8.1/libgcc/config/i386/cygwin.S:172
172 ../../../../../src/gcc-4.8.1/libgcc/config/i386/cygwin.S: No such file or directory.
I've tried:
Compiling on a Windows x86 machine
Compiling on a Windows x64 machine
nuwen.net's MinGW distro
TDM MinGW 4.8.1 SJLJ
MinGW builds x86 SJLJ
MinGW builds x64 SJLJ
MinGW builds x86 DW2
I've built all dependencies from source multiple times, tried linking both statically and dynamically.
Debugging doesn't help either - GDB gives me that error message just upon entering main(). I've used -g3 and -O0 flags.
How can I figure out what's happening?
On Windows, the default stack size is smaller than Linux. __chkstk_ms appears to be a function that crashes if you overflow your stack.
You may try to figure out where in your code you are creating huge stack variables or doing very deep recursion, and fix that.
Alternately, you may be able to add a compile flag to increase the stack size. See http://trac.sagemath.org/ticket/13960.
Try to increase stack size. Don't ask me how, I don't know.
The failing call (__chkstk_ms) looks like internal routine which checks if there is enough stack space for the function about to be executed.

How do I use Instruments Time Profiler with clang compiled from the command line?

I am currently running OS X Mavericks on this machine, and am compiling a C++ scientific computing application. I would prefer not to convert it to XCode build if I dont have to.
What I am trying to do is to profile the program to find what sections of code are causing it to run slowly. It is a fairly simple build- roughly 15 source files, and the only flags I am adding are: -g -O2 -ftree-vectorize. For example
clang++ MySource.cpp -g -O2 -ftree-vectorize -o MySource.o
I run the program and launch instruments and attach a time profiler to my application. This all works fine. HOWEVER, the hot spot in the code it is identifying makes zero sense, as it is highlighting a line of code that is only called when the class is constructed, and is a fault in construction which logs an error and throws an exception on the following line. No error is being logged, and no exception being thrown, so I am confident this line of code is not actually the one being executed. Am I compiling things properly to be used with instruments? Are there other flags I need to add? I have noticed that it doesnt automatically link to my source code in instruments- I have to go manually find the source code file in question.

running an executable c++ program in solaris

I compiled my class Transfer correctly in Solaris. There is the executable file transfer. If i were in Linux, I would to ./transfer and the program would execute perfectly. However, when I run ./transfer in Solaris I get:
bash: ./transfer: invalid argument
Does someone know how to run an executable in Solaris?
Sounds like compilation was done targeting a different architecture than the host machine.
See related thread - x86 binary on a SPARC machine.
Please have a look at the follwing pages that I append here:
https://unix.stackexchange.com/questions/36376/what-does-invalid-argument-mean-in-solaris
I am trying to excute java from solaris, getting invalid argument error
and also consider correct folder of files and file permissions, sometimes these issues can make problems.