Accelerate code without using gpu?

Is there a way to accelerate code without using gpu acceleraton?
i'm just talking about loops, operators,and variable processing using those loops and operators...

Is it possible?
If so please explain how.
closed account (zb0S216C)
The GPU isn't used unless the program was designed to use it.

lindsey laho wrote:
"i'm just talking about loops, operators,and variable processing using those loops and operators..."

I'm not too sure what you mean by this.

Wazzak
i'm just talking about making those parts of programs run faster....
However i don't know how it would be possible, so that' s why i'm asking
What you're asking about is optimisation, for speed.

Firstly, make sure you've told the compiler you want to optimise for speed. It has choices, and if you tell it you're interested in sped, it'll do what it can.

Use a profiler to find out just where your code is actually spending the most time. It's silly to spend time optimising something that actually isn't a big part of the execution.

Your algorithm may be less tahn optimal. Are you doing anything expensive i.e. slow) repeatedly? Reading/writing files is expensive. Floating point operations are expensive. Sometimes there is a much more elegant solution that is much faster.

Loops; are you doing anything in every loop that actually doesn't need to be done every loop? Is there anything that can be done in one big burst at the start? Can the loop be "unrolled" i.e. instead of doing one thing a thousand times, can you do ten things a hundred times? There are many ways to make your code faster. If you can provide some sample code, we can make more suggestions, but the absolute first two things to do are ensure you've told the compiler what you want, and use a profiler to find out where the time is actually going.
closed account (zb0S216C)
So you want operators, loops, and variable processing to be performed faster? You have a few options:

1) Get a faster CPU.
2) Optimise your code so that fewer instructions are executed.
3) Effectively use the code cache.

There's not much you can do in terms of optimisations. Seemingly big changes in code could result in very small performance increases. You could try in-line-assembly as an option.

Wazzak
moschops had what i was looking for -compiler "optimisation"(optimization).
SOLVED
~Thanks
2a) Use good algorithms. A quicksort in Python will easily outperform hand-optimised bubblesort in assembly.
2b) Use caching / memoization to avoid recalculation of same thing over and over again.
2c) Parallelize computations.
2d) Don't use blocking operations (mutexes, monitors, blocking I/O).
2e) Avoid needless copying of objects (pass by reference or pointer wherever you can)
2f) Avoid random I/O.
...

4) Don't trust your compiler. Check its output.
5) Don't trust you intuition. Measure things.
The easiest way to parallelize loops, is with openMP. All you need to do is make sure the loop is appropriate for this, and put the following line before the for loop.

#pragma omp parallel for

Read up on it before using it so you know what your doing though.
Last edited on
closed account (1yR4jE8b)
profile, profile, profile

Use the right algorithms.

Understanding how your cpu's cache works can be helpful.

Don't always trust compiler optimizations, but don't assume you can always write inline assembly better than your compiler can either.
Topic archived. No new replies allowed.