Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with mspectrum? #459

Open
Rogerthatx opened this issue Mar 2, 2024 · 9 comments
Open

Problem with mspectrum? #459

Rogerthatx opened this issue Mar 2, 2024 · 9 comments

Comments

@Rogerthatx
Copy link

Hello all, when I run the mspectrum function I noticed that all the cores get 100% load after doing an htop.

htop
htop_simple

I am running ChiantiPy in my persona computer and in a server and I get the same behavior. (see attached images). On my personal setup I am just trying to run an example from the notebooks (see test_code.png). This happens even if I lower the number of processor to 3 for example.
test_code

Do you have any idea of why this could be happening?

Cheers,

-Rogelio.

@Rogerthatx
Copy link
Author

Rogerthatx commented Mar 2, 2024

Update: apparently, the problem happens when mspectrum starts to calculate emission lines. If I calculate only the continuum, then the calculations are faster. But if I set DoLines = True the routine takes every available core.

@kdere
Copy link
Contributor

kdere commented Mar 2, 2024

Hi Rogelio,

in mspectrum you can set the keyword argument proc = 2, or whatever number of cores you want it to use. The current default value is 3.

hope this helps,

Ken

@Rogerthatx
Copy link
Author

This happens even if I set to 2 the number of cores. Does the keyword argument proc refers to the physical processors of the machine? Or is meant to be the total number of available cpus? When I run the routine in a machine with 48 cpus and I set proc = 10, this happens, again only when I set Dolines = True. If I only calculate the continuum, the mspectrum respects the maximum number of processes I set with the proc argument.

-Rogelio.

@kdere
Copy link
Contributor

kdere commented Mar 3, 2024

It should set the number of cores that you want to use.

Ken

@wtbarnes
Copy link
Member

wtbarnes commented Mar 3, 2024

@Rogerthatx What happens if you compute the intensity for a single ion, ie without using the mspectrum class? I think it may be that the NumPy linalg.solve call used for the level populations may implicitly use all available cores depending on how you've installed NumPy. As such, you would see all cores being used independent of what option you're passing to nproc

@Rogerthatx
Copy link
Author

When I calculate the intensity for a single ion with ch.ion, it does not change the cpu load, the calculations are done instantly. I did another test,first I calculated the intensity, and then I calculated the spectrum of a single ion with my_ion.spectrum(wvl). The calculations are done almost instantly but this function seem to be taking all the cores for a moment to do the calculations.

@kdere
Copy link
Contributor

kdere commented Mar 4, 2024

I checked whether setting proc is effective and it seems that it is now working correctly. On my cpu, setting proc=4 and all 6 cores are used.

I am looking into this.

@kdere
Copy link
Contributor

kdere commented Mar 4, 2024

also, if you only calculate the line radiations (doLine = False), the only a single core is involved.

still checking

@kdere
Copy link
Contributor

kdere commented Mar 7, 2024

I have been looking into the matter and doing some testing. It seems that it is not possible to limit the multiprocessing queues to a single core. Also, sometimes you do not get increased speed for some problems. You might want to time the single processor spectrum vs. mspectrum for a small problems (set minAbund = 1.e-4, a small number of wavelengths ...) and see which is faster etc.

There is a bug in mspectrum and will try to chase that down

Ken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants