2

I have a console application that is doing intense calculations, and it takes several hours to complete. I can run as many as I want at a given moment, and they all run at exactly the same speed. That means my computer has the ability to go faster, so why isn't it? I want my computer to take 100% of its processing power and dedicate it to this one program.

I can easily cut time in half by putting half of the work in one program and half of the work in another, and have them communicate through a txt file or something. Is there any way I can make it go faster without doing that? Task Manager's priority doesn't change anything.

Nicholas Pipitone
  • 4,002
  • 4
  • 24
  • 39
  • 1
    [Parallelization](https://www.google.com/search?q=Parallelization) – Captain Obvlious Aug 03 '13 at 18:59
  • one approach can be creating several exe files each doing a part of calcuations and running them simulatneously. – Minimus Heximus Aug 03 '13 at 19:01
  • @MinimusHeximus "I can easily cut time in half by putting half of the work in one program and half of the work in another, and have them communicate through a txt file or something." I know that, but that is annoying for the user. – Nicholas Pipitone Aug 03 '13 at 19:07
  • do you want to have only one exe file?! you can have a moderating exe file which runs other exe files or dlls and shows the results they collect! – Minimus Heximus Aug 03 '13 at 19:10

1 Answers1

2

Well... There's always multithreading: Stack Overflow, for example.

But it's always a complicated process, especially for C++. I'm afraid you'll have to google some tutorials for your particular case.

Here are some: tutorialspoint, codebase, plenty more around. There are a lot of methods, achieved by many distinct libraries, and none of them could be considered simple.

Community
  • 1
  • 1
Fenixp
  • 645
  • 5
  • 22
  • #include was really easy, already implemented and now its running an order of magnitude faster :) (Says I have to wait 6 minutes to accept your answer) – Nicholas Pipitone Aug 03 '13 at 19:05
  • @Nicholas Pipitone In that case, I was either rubbish at it or it wasn't implemented as well at the time. Do be careful tho - there are many pitfalls which might result in unexpected behavior. – Fenixp Aug 03 '13 at 19:09
  • Lol, maybe in my case it was just really easy to implement. My program is deeply nested in 26 for loops, so I just took the nested part and split it into four functions, threaded each one, and put a *.join() at the end and it sped through the whole thing. – Nicholas Pipitone Aug 03 '13 at 19:13