Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ways to improve the time performance of C programming?

Status
Not open for further replies.

ufochina

Banned
Joined
Dec 11, 2009
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Austin
Activity points
0
List ways to improve the time performance of a critical portion of C programming language?
 

Depends upon the code.

Put the variables in registers.
 

    ufochina

    Points: 2
    Helpful Answer Positive Rating
Thanks, but is there any extra ways?

Another question is:
Is there any format for storing a floating point in two 16 bit word?
 

loop unrolling, duff's device, .... and of course it depends on the processor you want to use (simple risc based microcontroller, intel-based PC, ...)


for float : it should be 32 bit, so it will take two 16 bit words. For double, 64 bit becomes 4 16 bit words. I think your compiler should store this for you in the correct place and format?

Stefaan
 

To Stefaan,
thanks. It is a floating point, but could you give me detail about the format on how to storing a floating point in two 16 bit words?
 

2 16-bit is 32-bit. That is float. The question is put in this way just to confuse.

You can also look at half precision floating point numbers.

Again code optimization depends upon code. There are a lot of ways e.g.

use registers for variables that are often accessed (usually done automatically by compilers).
use bit operations where possible instead of arithmetic operations e.g. multiply by 2 should be a done as a 1b-it left shift.
use a+=n instead of a = a + n;
Use switch statement if the decision is based upon an integer instead of a lot of if-else
use inline functions (compiler dependent)
Try to make/use constant time functions, or O(n) or O(nlogn).


exploit multithreading
 

To MicroKernel,
Thanks! there is one question about design a system, maybe you can help me on that, the question is:

Describe a system for measuring phase changes at one frequency in S band with a dynamic range of 100 dB. The desired accuracy for this system is 0.5. Elaborate on what you think are the major problems
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top