Speed of math calculations

I need to perform trillions of calculations (order 10^9-10^10), which are quite repetitive: calculation of distances, angles (sin, cos), etc. I was wondering if C/C++ could do the task in a reasonable amount of time, or should I choose to programm it in assembler code, or even if I could try that code with direct calls in C/C++ (there is a part of calculation and the other would be graphically rendering the solution - just a few dozens of results). So I don't know if it would be more convenient to learn assembler, make the calculations, store them in a text file, and, now with C/C++ process the data file for graphics purposes instead of doing all in C/C++, as I have just a laptop and don't want to spend several months for the data to be calculated. Thanks!!

C++ supports the insertion of assembly code directly, and it is a quite fast language capable of making direct calls to the processor.

Aceix.
Thanks for your reply. So your advice would be to create full code in assembler embedded into the C++ code? I used assembler code in Basic and Pascal for making the internal speaker of the PC to beep, nothing else (just a single command). I guess from your reply that I can insert a complete program and could have the complete program with graphic rendering, etc., all in the same *.exe. Right?
I also deduct that C++ alone with math.h or any other library wouldn't be powerful or fast enough to compete with assembler?
Last edited on
you can do in C++.
for graphics you can use SDL\SFML

10^9
is a billion.
Keep in mind that a modern processor can execute around a billion instructions per second on a single core so 10^9 or 10^10 calculations is like a light jog if you code it right.

You say that you have trillions of repetitive calculations. Do you have trillions of input values? If not, then see if you can cut down on the amount of computation that you need to do. If you post the problem, you may find that someone can help speed things up. That way you won't even need to drop into assembly language.

Finally, note that modern optimizers are really good. I'd code it in C++ and compile with optimization turned all the way up. If necessary, you can tell the compiler to generate assembly code for you and then tweak the result.

Sounds like an interesting problem!
Topic archived. No new replies allowed.