Ask Your Question
1

How to maximize computing time

asked 2017-11-26 12:25:40 +0100

Gianni Petrella gravatar image

Hello everyone, I am running a short bruteforce program, and python is not using more than 40% of my CPU power, although there is no other software running and the RAM is at 20%... Since my software is quite heavy, I would like to force sage to use more CPU power. How can I do so? I am using Sagemath 8.0 for Windows

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-11-29 16:40:09 +0100

Richard_L gravatar image

Windows reports the total percentage of the CPU, that is, over all cores taken together. So, if your program runs one thread and it saturates one core of a four core machine, Windows will report 25%.

If your task is parallelizable, you can try adding

Parallelism().set(nproc=NN)

somewhere above the calculation. For "NN" substitute the number of threads you want to use.

Note that not all algorithms can be parallelized, so the directive might or might not help.

edit flag offensive delete link more

Comments

I would add that without knowing what the program is, it's hard to say whether the algorithm is purely CPU-bound. Since you the OP wrote that it's a "bruteforce" program I would think probably that it is, but depending on where data is coming from, or where results are written to, the use of exceptions/interrupts etc. there may be other bottlenecks preventing full CPU usage. But yes, one needs to make sure whether it's actually using 100% of a single core.

Iguananaut gravatar imageIguananaut ( 2018-01-05 14:03:39 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-11-26 12:25:40 +0100

Seen: 389 times

Last updated: Nov 29 '17