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

Add prepare_sim.Nthread_per_load parameter #145

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions abacusnbody/hod/prepare_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,9 +1094,14 @@ def main(
else:
shearmark = None
# N_dim = config['HOD_params']['Ndim']
nthread = int(
np.floor(multiprocessing.cpu_count() / config['prepare_sim']['Nparallel_load'])
)
nthread = config['prepare_sim'].get('Nthread_per_load', 'auto')
if nthread == 'auto':
nthread = (
len(os.sched_getaffinity(0)) // config['prepare_sim']['Nparallel_load']
)
print(f'prepare_sim inferred Nthread_per_load = {nthread}')
else:
nthread = int(nthread)

p = multiprocessing.Pool(config['prepare_sim']['Nparallel_load'])
p.starmap(
Expand Down
3 changes: 2 additions & 1 deletion scripts/hod/config/abacus_hod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ sim_params:
cleaned_halos: True # load cleaned halos?

prepare_sim:
Nparallel_load: 5 # number of thread for organizing simulation outputs (prepare_sim)
Nparallel_load: 5 # number of processes. peak memory usage will increase by this factor.
Nthread_per_load: 'auto' # number of threads per process (auto uses the affinity mask)

# HOD parameters
HOD_params:
Expand Down
1 change: 1 addition & 0 deletions scripts/hod/config/lc_hod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sim_params:

prepare_sim:
Nparallel_load: 1 # not sure if this makes a difference since we have a single slab
Nthread_per_load: 'auto'

# HOD parameters
HOD_params:
Expand Down