Author Topic: Does QB64 benefit from multiple CPU cores and threads at all?  (Read 1852 times)

0 Members and 1 Guest are viewing this topic.

Offline FilipeEstima

  • Newbie
  • Posts: 63
    • View Profile
I made a program that does many calculations and works with strings. It takes quite some time to execute in a number of files I have here, and this execution needs to be done frequently. My current PC uses an AMD CPU (Athlon 3000G), which has 2 physical cores, each of them capable of running 2 threads. I'm not sure QB64 takes any advantage from that; my assumption is that it uses only one of four possible threads. If that's the case, when upgrading I may want to look at a CPU that has better single thread performance. Am I correct, or is it possible to use some switch that enables automatic use of multiple cores/threads?

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: Does QB64 benefit from multiple CPU cores and threads at all?
« Reply #1 on: May 21, 2020, 09:32:19 am »
Technically QB64 does use multiple threads, but only one of those executes your program code; the others handle things like input buffers, sound and window rendering.

That said, you might gain some performance by opening internal/c/makeline_win.txt (I assume you're on windows, use whatever file is named for your platform) and adding the -O3 switch. If in doubt, just add it after -s.

That'll tell gcc to Optimise Harder and may produce code that runs faster. It'll still only run your code on a single thread, though.
« Last Edit: May 21, 2020, 09:34:06 am by luke »

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Does QB64 benefit from multiple CPU cores and threads at all?
« Reply #2 on: May 21, 2020, 09:59:15 am »
It should be noted, that adding the optimize switch will of course give you faster running code, but it also massivly increases the memory needs and the time needed for compiling.

Eg. I've once tried to compile source/qb64.bas with the -O2 switch in the hope that the IDE would then do its error checking and code formatting quicker on large code projects, but unfortunatly after running for a felt 10 minutes and massivly swapping out memory to the pagefile, it finally failed to compile due to lack of memory on my 4GB Win7 machine.

So keep this in mind, if you get C++ Complilation failures when compiling your programs, which formerly compiled error free, it might be the optimize switch.
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline FilipeEstima

  • Newbie
  • Posts: 63
    • View Profile
Re: Does QB64 benefit from multiple CPU cores and threads at all?
« Reply #3 on: May 21, 2020, 05:24:24 pm »
Thanks luke for the tip and RhoSigma for the heads up. I'm using Windows 10 Pro x64 in this PC, which has 32 GB of DDR4 RAM. I think my only bottleneck is the CPU, which for my current needs is OK (Athlon 3000G). I plan to purchase the new Ryzen 3 3300X - if Asus confirms my motherboard will accept it - which has extremely good single thread performance, even better than all Ryzen 5, losing only to Ryzen 7 3800X and all Ryzen 9 (according do PassMark https://www.cpubenchmark.net/singleThread.html).

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Re: Does QB64 benefit from multiple CPU cores and threads at all?
« Reply #4 on: May 23, 2020, 03:34:20 pm »
Thanks for reminding me about an old fixed bug in QB64.  At one time not too long ago.  Using "END" command in a QB64 would make qb64 hit the gas and go full throttle on all CPU's until you banged a key to exit.  Using "END" is a hold over from old days of basic.  Using "SYSTEM" is cleaner and does not require a key hit to exit.
BTW, I never did find the "Any" key on my keyboard.