473,216 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

optimizing c++ code (on win32 platform), all the techniques you know?

Hi,

"What methods do you ever use to optimize the programs?"

We're developing a graphics chip emulator in C++, but it's very slow
for big scenes. Even though this is a cross-platform software, I only
want to optimize it on the Win32 (Windows 2000/XP) platform.

I've tried the following method to optimize it:

* Boost.Pool - a fast memory allocation algoritm, fixed-size chunks.
<http://www.boost.org/libs/pool/doc/index.html>

* Whole Program Optimization with Visual C++ .NET
<http://www.codeproject.com/tips/gloption.asp>
I almost turn on every possbile Visual C++ options to optimize the
speed.

* inline every possbile function
Not tried yet:

* Improving Runtime Performance with the Smooth Working Set Tool
<http://msdn.microsoft.com/msdnmag/issues/1000/bugslayer/default.aspx>
I don't think it will help much, because our program is about 500KB.
Or not?

* Recompile the CRT with _fastcall calling convetion

* Link single-thread CRT instead of multi-thread CRT
We don't use many CRT functions.

* Distributed Computing
<http://www-unix.mcs.anl.gov/mpi/>
Uh, not feasible. I am looking for "fast" approches, like a compiler
option, etc.

--
Tzu-Chien Chiu
XGI Technology, Inc - Extreme Graphics Innovaion
Jul 19 '05 #1
9 3899
Tzu-Chien Chiu <tz***********@xgitech.com> wrote in message
news:03*******@comp.compilers...
Hi,

"What methods do you ever use to optimize the programs?"
We're developing a graphics chip emulator in C++, but it's very slow
for big scenes. Even though this is a cross-platform software, I only
want to optimize it on the Win32 (Windows 2000/XP) platform.
This question isn't suitable for c.l.c++, at least where a specific
implementation is concerned.
I've tried the following method to optimize it:

* Boost.Pool - a fast memory allocation algoritm, fixed-size chunks.
<http://www.boost.org/libs/pool/doc/index.html>
Or ditch memory allocation altogether, at least in the most critical parts
of your code. Many firmware engineers manage to design their systems to
_never_ do a memory allocation except during initialization, since a
recurring memory leak, even a small one, means death for an embedded system.

* Whole Program Optimization with Visual C++ .NET
<http://www.codeproject.com/tips/gloption.asp>
I almost turn on every possbile Visual C++ options to optimize the
speed.
It goes without saying to generate the fastest code possible, but this is
off-topic here.

* inline every possbile function
Well, every one that could possibly have a significant effect, which would
be the ones that a) do or might return quickly, and b) are called very
often. There's no point in spending hours moving functions to header files
if a cursory analysis of the program shows that doing so will make an
insiginificant difference.

Not tried yet:

* Improving Runtime Performance with the Smooth Working Set Tool
<http://msdn.microsoft.com/msdnmag/issues/1000/bugslayer/default.aspx>
I don't think it will help much, because our program is about 500KB.
Or not?

* Recompile the CRT with _fastcall calling convetion

* Link single-thread CRT instead of multi-thread CRT
We don't use many CRT functions.

* Distributed Computing
<http://www-unix.mcs.anl.gov/mpi/>
Uh, not feasible. I am looking for "fast" approches, like a compiler
option, etc.


I don't see anything relevant to c.l.c++ in all this.

Have you thought of redesigning your algorithms so they work more
efficiently? That's more likely to make a bigger difference than squeezing
out 10% better performance by quick or mechanical means such as compiler
options or moving code about.

DW

Jul 19 '05 #2
"Tzu-Chien Chiu" <tz***********@xgitech.com> wrote in message
"What methods do you ever use to optimize the programs?"

We're developing a graphics chip emulator in C++, but it's very slow
for big scenes. Even though this is a cross-platform software, I only
want to optimize it on the Win32 (Windows 2000/XP) platform.


Actually, the most efficient method is detect your bottleneck first. Before
you know exactly where most of time is wasted, any speculations about
optimization are pointless. It can be that your program spend 1% of time in
allocations and 90% of time in buffer transfers, so even if the miracle will
happen and you'll succeed to accelerate allocations twice, then still you'll
gain only 0.5% in overall time. And you can spend hours and days by
optimizing not relevant parts of the program with negligible effect. I think
you got the idea. Here's the article for general reading:
"Optimization: Your Worst Enemy"
By Joseph M. Newcomer
<http://www.codeproject.com/tips/optimizationenemy.asp>

Jul 19 '05 #3
Tzu-Chien Chiu wrote:
"What methods do you ever use to optimize the programs?"

We're developing a graphics chip emulator in C++, but it's very slow
for big scenes. Even though this is a cross-platform software, I only
want to optimize it on the Win32 (Windows 2000/XP) platform.


If you application seems very slow on todays super fast GHz PC's, that
to me that suggests the application it is doing an awful lot of CPU
intensive stuff.

Have you profiled your application to check that the appliction is not
wasting time on a badly code algorithm or flow structure? Does you
machine have lots of spare RAM? RAM always helps speed up memory
hunger applications.

If you do have an optimal algorithm then your applicaiton is just CPU
intensive and I would be suprised if the any amount of optimazation
would greatly improve the speed.

Jussi Jumppanen
Author of: Zeus for Windows, Win32 (Brief, Emacs, etc) FTP Text Editor
"The C/C++, Java, HTML, FTP, Python, PHP, Perl programmer's editor"
Home Page: http://www.zeusedit.com
Jul 19 '05 #4
Jussi Jumppanen <ju****@zeusedit.com> writes:
Tzu-Chien Chiu wrote:
"What methods do you ever use to optimize the programs?"

We're developing a graphics chip emulator in C++, but it's very slow
for big scenes. Even though this is a cross-platform software, I only
want to optimize it on the Win32 (Windows 2000/XP) platform.


If you application seems very slow on todays super fast GHz PC's, that
to me that suggests the application it is doing an awful lot of CPU
intensive stuff.

[snip]

That is usually wrong. I/O speeds are hundres of thousands of times
slower than cpu speeds. The speed of a system is usually most
strongly dependent on the speed of its slowest parts. Many more
programs are I/O bound, and can be very slow even when only using
1 or 2% of cpu.

Memory-bound and system-call bound progams are also more common than
cpu-bound progams.
Jul 19 '05 #5
> * Boost.Pool - a fast memory allocation algoritm, fixed-size chunks.
<http://www.boost.org/libs/pool/doc/index.html>
when you use it wrong, you need much more memory than you actually need.
* Whole Program Optimization with Visual C++ .NET
<http://www.codeproject.com/tips/gloption.asp>
I almost turn on every possbile Visual C++ options to optimize the
speed.
Good idea, but some options can under certain circumstances create
errors in your executable
* inline every possbile function
That is very stupid. inlining very small functions that are called in
loops can be a good idea, but inlining every function in the program
is just stupid because it bloats the code which then makes code
caching very unefficient.
* Recompile the CRT with _fastcall calling convetion


This can lead to errors too. be very careful.

As the foreposter said, before you start wasting your time with
useless things like spending 90% time on things that comsumes 0.01% of
performance, detect what certain loops are slow, instead of
bit-fiddling rethink your algorithms.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu
Jul 19 '05 #6
Have you try V-Tune, to find the bottleneck or the Intel-Compiler
sometimes it's helpfull

Oliver Wesnigk

"Tzu-Chien Chiu" <tz***********@xgitech.com> wrote in message
"What methods do you ever use to optimize the programs?"

Jul 19 '05 #7

Tzu-Chien Chiu wrote:
"What methods do you ever use to optimize the programs?"


Don't optimize your programs before you design them.

--
= Jeff Kenton Consulting and software development =
= http://home.comcast.net/~jeffrey.kenton =
Jul 19 '05 #8
WW
Tzu-Chien Chiu wrote:

"What methods do you ever use to optimize the programs?"


http://magnonel.guild.net/~schwern/t...imization.html

Short URL: http://tinyurl.com/ncpc

--
WW aka Attila

Jul 19 '05 #9
Tzu-Chien Chiu wrote:
"What methods do you ever use to optimize the programs?"


Read any book by Jon Bentley or containing the words "Programming
Pearls".

Thanks. Take care, Brian Inglis Calgary, Alberta, Canada
--
Br**********@CSi.com (Brian dot Inglis at SystematicSw dot ab dot ca)
fake address use address above to reply

Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: A Future Computer Scientist | last post by:
A question: Is it really important to think about optimizing the native code or optimizing it for P Code? Or does the code you write make a difference?
3
by: David Douard | last post by:
Hi everybody, let me explain by problem: I am working on an application which consists in a C++ dll (numeric computations) and a Python IHM (Python/Tk), which must run under Linux and win32. My...
14
by: Ian Richardson | last post by:
I'm writing a large Javascript application (uncompressed source around 400K) which is doing almost all the initialisation it needs to in a just-in-time manner. However, I have included an option...
70
by: grün | last post by:
The MSDN techdocs are somewhat limited on this and I wanted more information. Is there any resource that says definitively which is faster /O2 or /Ox and by how much?
3
by: PWalker | last post by:
Hi, I have written code that I would like to optimize. I need to push it to the limit interms of speed as the accuracy of results are proportional to runtime. First off, would anyone know any...
6
by: Dylan | last post by:
Can anyone point me toward some decent sources that discuss code optimization for C++ code running on the WinXP platform? I'm interested in any discussion, books, URLs... *anything* related to...
7
by: Kenjis Kaan | last post by:
I would like to use the crypt function in a Win32 (ie. C program using Visual C++ 6.0 compiler). I wrote a little program to see if it will link but it didn't. So I guess maybe the function isn't...
6
by: KG21 | last post by:
Need help i have the source code but don't know how to make it into a program. Any kind hearted people can make the source code and become a run able program? the file is too big... any kind...
1
by: hyena | last post by:
Hi, is there a port to win32 platform of glibc? I am using mingw32 and seems it does not has a gnu c lib with it. Another quesion is, when making archive library, does the order of those...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.