Re: Efficient Programming



In article <d9p8ul$lt9$1@xxxxxxxxxxxxxxxxxxxxxxxxxx>,
Salomon Turgman <sturgman@xxxxxxxxx> wrote:

> Joost wrote:

> > without even worrying about the program at all ... I think you'll be
> > accessing the memory in a different and less effective way in program
> > 2.
> >
> But wouldnt the less amount of looping in program 2 be much better?
> That was my initial logic initially. And also there are no if checks in
> program 2.

I haven't taken the time to study the actual code, but in current
systems, performance is often dominated by memory access issues.
Certainly other things can be important, but memory access patterns are
typically the first thing to look for.

Do note that this has *NOT* always been the case. If you picked up
performance tuning tricks from a few decades ago, you need to realize
that they are no longer current. Yes, there are some general principles
that still apply (including the universal one that getting a good
algorithm is more important than any other kind of performance tuning),
but some of the details are really quite different. We used to do things
like count floating point operations (flops), which now are often
negligible.

Anyway, I need to run now, but I'd say that if you really want to
understand the performance differences here, you should start by looking
at memory access patterns. How many memory access are there and how many
of those are likely to be satisfied from cache?

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.



Relevant Pages

  • RfD: Memory Access - v2 (Long)
    ... RfD - Memory access ... It is assumed that bytes do not require address alignment. ... Store the 8 LSBs of x at addr. ...
    (comp.lang.forth)
  • Re: Results of the memswap() smackdown from the thread "Sorting" assignment
    ... Use in C is memswap; a, b are pointers to a block of memory, n is ... The memory access is serial: one read and one write access per location, ... registers, and taking care of the unaligned first 16 bytes with movdqu, ... If you want to get even more extreme you can tweak the MTRR for very ...
    (comp.programming)
  • Re: Memory ordering and flag/state variables
    ... one-byte memory access always result in bus locking. ... be seen by all CPUs before the function returns? ... barriers as I'd expect and I wonder why it works. ...
    (microsoft.public.development.device.drivers)
  • Re: How hard is socket programming?
    ... you will never have 100% full exclusive control of MEMORY ACCESS - never. ... That gives other threads in your process, if it was multi-thread to do the same type of memory access work. ... Now comes a MULTI-CORE, and you have two or more threads, the SPEED is that there is NO CONTEXT SWITCHING - you still may have the same memory access, but that would be no slower if it was single cpu. ...
    (microsoft.public.vc.mfc)
  • Re: How hard is socket programming?
    ... You have a quantum based context switching you can't stop, ... will never have 100% full exclusive control of MEMORY ... multi-thread to do the same type of memory access work. ... The INTEL Multi-Core chips has advanced technology to help ...
    (microsoft.public.vc.mfc)