Re: speed of int vs bool for large matrix
From: jacob navia (jacob_at_jacob.remcomp.fr)
Date: 09/11/04
- Previous message: Christian Bau: "Re: speed of int vs bool for large matrix"
- In reply to: Keith Thompson: "Re: speed of int vs bool for large matrix"
- Next in thread: Randy Howard: "Re: speed of int vs bool for large matrix"
- Reply: Randy Howard: "Re: speed of int vs bool for large matrix"
- Reply: Keith Thompson: "Re: speed of int vs bool for large matrix"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 11 Sep 2004 19:37:02 +0200
Keith Thompson wrote:
> jacob navia <jacob@jacob.remcomp.fr> writes:
>
>
>>If you declare your table as a table of unsigned chars, memory
>>requitrements will be 1 000 000 bytes, in the other case will be
>>4 times as much (supposing a 32 bit machine), i.e. there is 4 times
>>as much data that will fit the Level 1 cache.
>
>
> You're assuming there is a "Level 1 cache".
>
I am assuming of course a modern CPU, either a PPC, x86 or similar.
Please lets be realistic: handling 1-4MB matrices in a DSP
with 4K of RAM would be ridiculous...
>
>>Input output requirements will be much more reduced and the
>>program will be surely much faster.
>
>
> What input output requirements? The OP didn't indicate that the
> matrix would be read from or written to an external file.
>
Input output to/from the CPU of course!
I am not speaking about file I/O but RAM I/O.
>
>>If you have a purely boolean matrix, I would use a packed
>>representation with 8 bits/byte, making your matrix just
>>125K, i.e. 8 times less than if you use the int data type.
>
>
> Which will likely make access to individual elements slower.
>
No, this is my point. If you have to read from RAM 8 times less
data, each read producing at least 10-20 wait states, the few
more instructions to access the individual bits would be
compensated by the smaller I/O.
>
>>Note that reducing space requirements increases speed, since
>>filling the cache from RAM introduces an enormous amount of wait
>>states. Memory access go through the bus at 300 MHZ, with a CPU
>>running at 3 000 MHZ, i.e. a memory access can be 10 times slower
>>when it doesn't hit the L1 cache.
>
>
> That's all very system-specific.
>
Not really. As the CPUs of modern micro computers go to
ever higher clock speeds, memory doesn't catch up at all,
and I/O from RAM becomes the limiting factor.
>
>>Of course this analysis implies a sequential access to each
>>element of the matrix. In other cases where you just access
>>randomly elements of the matrix, an integer representation would
>>beat all others since you are NOT limited by I/O.
>>
>>MAIN POINT
>>----------
>>Speculating about speed will never replace actual measurements.
>>
>>1: Build a test matrix.
>>2: Simulate the access pattern of your application.
>>3: Time it using unsigned char, int.
>>
>>Then you will know for sure.
>
>
> You could have safely skipped everything before "MAIN POINT".
>
No, I wanted to describe alternatives and leave the OP the choice
but of an informed choice.
- Previous message: Christian Bau: "Re: speed of int vs bool for large matrix"
- In reply to: Keith Thompson: "Re: speed of int vs bool for large matrix"
- Next in thread: Randy Howard: "Re: speed of int vs bool for large matrix"
- Reply: Randy Howard: "Re: speed of int vs bool for large matrix"
- Reply: Keith Thompson: "Re: speed of int vs bool for large matrix"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|