Automatic use of multi-threading in Linux [closed] - c

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I have following problem:
I work on powerful Intel CPU (8 cores). For this target I compile from source an old in-house C application using gcc. It's single-threded application, so created binary doesn't take any advantage from having multi-core cpu and single core runs at nearly 100% load. Is there some way to utilize other cores without changing source code?
How do I prompt gcc to automatically parallelize the program without explicit multithreaded programming? What hints can I give the compiler in the program?

You could try the gcc flags to auto-parallelize loops (-floop-parallelize-all -ftree-parallelize-loops=8) which uses pthreads. You have to be careful how you write your code of course, the compiler has to know there's no dependance between each iteration of your loop in order to be able to parallelize it.
But to be honest, you get nothing for free, unless your code is designed for multiple processors then you will never gain much.

Related

Is it beneficial to use glibc's strlen()/strcmp() or roll your own based on SSE4.2? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
According to "Schema Validation with Intel® Streaming SIMD Extensions 4 (Intel® SSE4)" (Intel, 2008) [they] added instructions to assist in character searches and comparison on two operands of 16 bytes at a time. I wrote some basic strlen() and strcmp() functions in C, but they seem slower than glibc.
I would like to maybe experiment with using inline assembly to see how my project behaves with inputting/outputting XML.
I've read (on here) that using SMID on things like strlen() is rife with potential problems (memory alignment), so I'm a little concerned about using it in production code.
glibc's implementations will be hard to beat. These functions are carefully optimized and include pieces hand written in assembly. Here is glibc's x86_64 implementation of strcmp, using AVX2 instructions. Be warned, it is 800 lines:
https://github.com/lattera/glibc/blob/master/sysdeps/x86_64/multiarch/strcmp-avx2.S
For more detail, read also Peter Codes' fantastic explanation about glibc's implementation.

Is there a C implementation for GNU ARM NEON intrinsics? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm not looking for a portable SIMD implementation.
All I need is: a bit-accurate implementation. Performance doesn't matter very much as long as it's not extremely slow.
I want to use it for early stage developing and testing, so that I can compile and run on a host computer for the first 10+ iterations. Then cross-compile and fine tune performance on the ARM target.
I'm pretty used to this development cycle when I work with TI DSP like described here . I want to carry this on when I move to ARM NEON.
Is this already done, or do I need to invent the wheel?
Intel has a useful set of macros, neon2sse.h which translate NEON intrinsics to SSE. This enables you to build and test your C/C++ code with NEON intrinsics on an x86 platform.

Cygwin or Gnuwin32 or MYSYS? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I've tried to google it and I understood some stuff, but still don't know which one is suitable for my needs.
all I want to do is to compile C file (or C++) under Unix environment (so I can use Fork and stuff that don't work on windows) and run these files after compiling it.
to be more exact, I need to use Fork+Semaphores and to use OpenMPI. I know I can do these with Cygwin (or that's what I understood), but it seems like it has a very large size, so I thought if this Gnuwin32 or MYSYS can do what I want to do and they have less size then Cygwin, then it's better ?
If you are absolutely sure you require fork and cannot instead use a more platform independent way of multiprocessing (a thin fork/CreateProcess wrapper) or multithreading (pthreads, Boost.Thread, C++11 std::thread, ...), then you are forcing yourself to use Cygwin.
Note that Cygwin's fork is pretty much as efficient as fork can get on Windows, which is not very, as the OS wasn't designed with that operation in mind, hence the kernel level support is missing.
Cygwin itself is not that big: it's only a DLL you link to that provides the POSIX interface. But do note that Cygwin is GPL and linking to the Cygwin DLL will force copyleft on your project as well.

small c compiler for educational purpose [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Is there any small c compiler which follows ansi c extensions and still it has less than 10,000 LOC. Basically 'm trying to port such small compiler to one of such educational OS kernel known as xv6. Thanks.
I don't think that's possible. You might try something like https://github.com/alexfru/SmallerC , a very small compiler for a subset of C. (See the wiki for the language)
Or look at pcc, but that is significantly larger.
It turns out xv6 badly needs several improvements in order to host a decent C compiler or just an assembler and a linker:
larger maximum file size (currently capped at around 64KB)
lseek
FPU state saving/restoring on context switches
A few other minor improvements may be needed.
Links:
Increasing the filesystem block size in the xv6 OS
system calls & toolchains
The smallest one I know is TCC http://bellard.org/tcc/ which has around 30 000 LOC.

Seeking C unit test system [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
It has been a few years since I coded any C (or C++) and now I have to code an application to run on a micro-controller. Development will be on a Windows 7, 64-bit PC, which is where the unit tests will run.
Last time out I was using CppUnit, but am not sure of what might have changegd in the past few years and Wikipedia offers so many choices that I might spend weeks trying them all out.
What meets this wish-list?
can handle plain C (gcc under Cygwin)
quick learning curve
good documentation, including examples, and support (forums)
can generate stubs (mocks?) from header files
I am using NetBeans as IDE if that makes any difference
Integrates with Hudson is a bonus
a GUI might be nice, all other things being equal
I am slowly coming round to TDD, if that makes any difference
Plus anything else you can think of. Thanks in advance

Resources