Question:
How many Calculations can a modern computer do ?
2009-07-26 04:46:05 UTC
Say there is a 1 Mb file and i want to multiply successive bytes together and want to do it 20 times.How long will it take ?

Also in general how many calculations(not floating point) can a modern computer do ?
Three answers:
?
2009-07-26 05:00:19 UTC
We'll ignore multiple cores because they complicate things.



Assuming an almost perfect cache (which isn't too unlikely if we're talking about successive bytes), I believe it takes modern processors 3 cycles to do an integer multiplication. The new laptop I got is currently running at 2000 million cycles per second. Approximating 1Mb to 1 million bits, you can quickly work out that it takes about 0.15% of a second to multiply that. The bottleneck these days is in getting information to and from memory, especially the hard disk.



That is integer division. Floating point takes longer. It is more commonly used in benchmarks. See http://en.wikipedia.org/wiki/FLOPS .
?
2009-07-26 14:57:52 UTC
Several factors here to give you a specific answer as well as how to how to interpret your question. Do you want to store the result 20 times or over write the result into the same memory locations. This simple interpretation changes how much memory will be required for each multiplication. You need to specify more details specific to a processor type and its clock speed ut in general you can do a quick estimate



Since you want to do 8 bit integer math (1 Byte = 8 bits) this means that you will be multiplying values from 0 to 255 together. To store the answer will require 2 bytes since 255 x 255 = 65025 which requires 2 bytes to store.



So each multiplication needs 4 bytes of memory at a minimum to store the two (1 byte) multiplier values and the (2 byte) answer.

1Mb contains 1048576 bytes (2^20)

divide this by 4 bytes and you get 262144, the number of multiplication and answer sequences.



Next consideration is the number of clock cycles requires to execute each CPU instruction. This can vary from 1 to 4 cycles based upon the type of instruction. Any type of branch or memory transfer function requires more clock cycles than say to trigger a math function in the CPU



So you have to transfer 4 bytes of data to/from the memory so assume 16 clock cycles (4 per byte). There will be the need to handle pointers for memory access so there is at least one addition per byte so there is another 4 instruction cycles.

So far that is 20 instruction cycles per multiplication sequence



There are more delays to consider in memory transfer such as latency but this will give you a general best possible time to consider. Actual time will be longer as you consider additional instruction cycles and other delays that may be taken into account.



total number of cpu clock cycles is 20 * 262144 = 5242880

and you want to do this 20 times

20 * 5242880 = 104857600



Assuming a 4 Ghz clock (4,000,000,000 Hz)



104857600 / 4000000000 = 0.0262144 seconds

or 26.2 milliseconds



Faster than the blink of an eye.
billrussell42
2009-07-26 11:52:32 UTC
to do 20 multiplications will take a very brief time.



The time I found was 1µs for 1 million multiplications.



.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...