First time here? Check out the FAQ!

Ask Your Question
1

How to maximize computing time

asked 7 years ago

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

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 7 years ago

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.

Preview: (hide)
link

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 ( 7 years ago )

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: 7 years ago

Seen: 431 times

Last updated: Nov 29 '17