Various types of compiler optimisations? [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have come across loop-unrolling but what other types of compiler optimization are there for C++ code?
If possible, I'd be interested specifically for the Intel Compiler and GNU Compiler.
If I could obtain a list I can google for the explanation upon each type of optimization.

if you are talking generically, beyond loop unrolling, there is also the basic:
remove unchanging variables out of a loop.
optimizing away unused but initialized objects/variables/instances.(dead code removal)
expanding function calls in line, like strlen();
using processor specific directives/commands.
thats off the top of my head... I will be back with some scientific (wikipedia lol) answers
heres more:
5. static variable inlining
6. complex branch optimization
ok, tired lol heres a decent link i was just looking at :)
http://www.eetimes.com/electronics-products/embedded-tools/4086427/Advanced-Compiler-Optimization-Techniques

Related

Navigating arrays in C (performance)? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Is it better to use a pointer to navigate an array of values,or is it better to use a subscripted array name?
How does the compiler treat both approaches?
Any modern compiler should produce an equivalent assembly code for both methods.
I did a short test. I created int arr[10] and set all cells to 10 using normal for loop indexed by int and one using int*.
What was strange form me (I accept Midhun MP arguments) pointer indexed loop assembly code was larger then normal approach (1 line more). But when I turn O3 optimization output was exactly the same.
IMO code should be easy to read and work without errors on the first place. Micro optimization can be done only if you really need them. In other cases readability beats performance.
If you are curious how it works. Just do this test yourself. Prepare 2 versions of code, compile it with gcc -S and diff outputs.

Anyone have the algorithm for determine if a hand of Mahjong game wins or not? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am reading some introduction of an ancient Chinese game called Mahjong (a bit like poker but far more complicated). I have been spending couple days in writing a program to determine if a given hand is a win hand or not. Do anyone have any idea or know where can I find the free code for that? I only need the part to determine win/lose, I am not looking for the entire project. Thanks.
There is this cool Python library that can be used for scoring of a Mahjong hand given a situation. I know you are working in C++, but since python is highly readable, even to non-python coders, maybe you'll be able to copy/paste and edit the relevant part so you'll be able to use them.
Hope that helps you in some way.

CPU caches aware C++ / C programming [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I was going through Scott Meyer's podcast on CPU CACHES AND WHY YOU CARE It seems this will make code run faster, is there any open source where such coding is done for reference.
Or anybody has example of design of data structures/algorithms based on CPU caches aware
Sure, the entire Linux kernel is implemented to be cache-aware.
For more details there is highly recommended paper What Every Programmer Should Know About Memory.
Linear algebra is sensitive to cache problems. The BLAS subroutines allow one to abstract away from these concerns

What are your techniques of optimizing your code in c++? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
What are your techniques of optimizing your code in c++?
Write code
Profile code
Tweak performance hot spots
If still not fast enough, go to step 2
1) Write the cleanest and most straightforward code I can.
2) Use a modern compiler with optimized settings.
3) Be done.
Optional:
4) If I think something is noticeably slow, profile my application.
5) Use my profile results to find out what's slow, and fix it.
6) Make sure it's still as clean and straightforward as possible.
7) Be done.
The most important technique is not optimising until you know it's a bottleneck.
Follow coding standards. Have a look at http://sourcemaking.com/

Of these four libraries, which are you most likely to use? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I'm trying to pick out my next hackery project. It'll likely be one of the following:
A sparse radix trie Implementation with extremely fast set operations
A really good soft heap implementation
A bloomier filter implementation
A collection of small financial algorithms, such as deriving total returns given a set of dividends and minimal information about them.
But I can't choose. So I thought I'd put my fate in the hands of my peers. Which of those four would you find most useful? Most interesting to work on? Which do you think is the most needed?
I didn't know what a bloomier (maybe Bloom?) filter is until reading your question. Sounds cool and useful.