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

Parallel calculation of PDOS and (fat)bands #367

Merged
merged 4 commits into from
Aug 20, 2021
Merged

Conversation

pfebrer
Copy link
Contributor

@pfebrer pfebrer commented Aug 18, 2021

Now if pathos is available, PDOS and (fat)bands calculated from a hamiltonian are computed in parallel over k-points using the functionality of the BrillouinZone applies.

If someone doesn't want parallelization they can control it through the SISL_NPROCS env variable by setting it to 1, so I didn't add any settings for it.

@zerothi
Copy link
Owner

zerothi commented Aug 18, 2021

Please remove commits changing files submodules needs a bit more care...

Also, it should already be there in the latest files commit?

sisl/viz/plots/bands.py Outdated Show resolved Hide resolved
sisl/viz/plots/bands.py Outdated Show resolved Hide resolved
sisl/viz/plots/bands.py Outdated Show resolved Hide resolved
sisl/viz/plots/bands.py Show resolved Hide resolved
sisl/viz/plots/fatbands.py Show resolved Hide resolved
sisl/viz/plots/fatbands.py Show resolved Hide resolved
sisl/viz/plots/pdos.py Outdated Show resolved Hide resolved
@pfebrer
Copy link
Contributor Author

pfebrer commented Aug 18, 2021

Please remove commits changing files submodules needs a bit more care...

I don't understand how the submodule works exactly, sometimes things get pushed, sometimes they don't 😕

@zerothi
Copy link
Owner

zerothi commented Aug 18, 2021

Please remove commits changing files submodules needs a bit more care...

I don't understand how the submodule works exactly, sometimes things get pushed, sometimes they don't

Yeah, I generally do a commit only with the hash to ensure I do stuff correctly.

@pfebrer
Copy link
Contributor Author

pfebrer commented Aug 19, 2021

Yes, I thought of this too, but then a user will get this warning even if everything they want to do is to plot a geometry or plot the bands from a .bands file :(

@zerothi
Copy link
Owner

zerothi commented Aug 19, 2021

Yes, I thought of this too, but then a user will get this warning even if everything they want to do is to plot a geometry or plot the bands from a .bands file :(

true... hmm... Perhaps could we make it a decorator to make it portable and use the same strings, I think the warning system should catch that as "same warning"?

@pfebrer
Copy link
Contributor Author

pfebrer commented Aug 19, 2021

Which may cause unnecesary confusion and will probably be seen as a drawback for using the visualization module: "I don't use it because it says it might break my computer, I'd rather be safe" 😅

@zerothi
Copy link
Owner

zerothi commented Aug 19, 2021

Which may cause unnecesary confusion and will probably be seen as a drawback for using the visualization module: "I don't use it because it says it might break my computer, I'd rather be safe"

They will so too if it is needlessly slow if they are oversubscribing. So no good solution.... :(

But probably the decorator is the best way?

@pfebrer
Copy link
Contributor Author

pfebrer commented Aug 19, 2021

true... hmm... Perhaps could we make it a decorator to make it portable and use the same strings, I think the warning system should catch that as "same warning"?

Yes that definitely makes sense, although it is not until the point where I wrote it now that you are 100% sure the calculation is going to happen. Otherwise they will get the warning because the entry point has been attempted even if it's not going to work because there's no Hamiltonian.

@pfebrer
Copy link
Contributor Author

pfebrer commented Aug 19, 2021

Probably the warning could be issued when you do BrillouinZone.apply.renew(pool=True)? As this will also be a problem for users that do the parallellization on their own

@pfebrer
Copy link
Contributor Author

pfebrer commented Aug 19, 2021

And what about using a context manager that sets OMP_NUM_THREADS to 1 temporarily? That would work, wouldn't it?

Something similar to https://stackoverflow.com/a/34333710/11991536

@zerothi
Copy link
Owner

zerothi commented Aug 19, 2021

And what about using a context manager that sets OMP_NUM_THREADS to 1 temporarily? That would work, wouldn't it?

Something similar to https://stackoverflow.com/a/34333710/11991536

Hmm. True. I don't know of the best place... In principle BLAS is used many, many places.
I have to say I don't really think the warning will be too much of a problem. Otherwise as you say the context should take care of sharing resources the best possible way. But then again that should issue a warning telling the user that sisl is overriding this?

You could for instance imagine a user doing SISL_NPROCS=2 ; OMP_NUM_THREADS=2 with 4 cores in total. This shouldn't issue a warning since the total core-count is <=4.

If it isn't a warning but an info then it doesn't sound as severe?

@zerothi
Copy link
Owner

zerothi commented Aug 19, 2021

Perhaps we should make a 2nd round of this warning, so feel free to leave it out here. Otherwise lets keep it as is and get it in.

@pfebrer
Copy link
Contributor Author

pfebrer commented Aug 19, 2021

But then again that should issue a warning telling the user that sisl is overriding this?

I was thinking it could set the OMP_NUM_THREADS variable only if it's not defined.

Perhaps we should make a 2nd round of this warning, so feel free to leave it out here. Otherwise lets keep it as is and get it in.

I'll remove it for now then.

@pfebrer
Copy link
Contributor Author

pfebrer commented Aug 19, 2021

I've removed all spin indices for spin kinds other than unpolarized and all the tests pass, so I'd say this is ready.

@pfebrer
Copy link
Contributor Author

pfebrer commented Aug 19, 2021

I found a bug, don't merge yet!

@pfebrer
Copy link
Contributor Author

pfebrer commented Aug 19, 2021

Now it's all good! Added some more tests to make sure this bug is catched in the future :)

@zerothi zerothi merged commit 4e8aeb8 into zerothi:master Aug 20, 2021
@pfebrer pfebrer deleted the parallel branch August 20, 2021 07:45
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

Successfully merging this pull request may close these issues.

2 participants