Skip to content

Commit

Permalink
run 10 times
Browse files Browse the repository at this point in the history
  • Loading branch information
agoscinski committed Sep 20, 2024
1 parent 286966c commit d28bb99
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions docs/gallery/howto/autogen/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,6 @@ def parallel_add(nb_iterations):
# We can see that the time is less than 6 seconds which means that the two additions
# were performed in parallel

# %%
# We can also look at the total time and see the overhead costs.
print(
"Time for running parallelized graph builder",
parallel_add_task.mtime - parallel_add_task.ctime,
)

# %%
# Increasing number of daemon workers
# -----------------------------------
Expand All @@ -231,29 +224,49 @@ def parallel_add(nb_iterations):

from aiida.engine.daemon.client import get_daemon_client

# %%
# We run the 10 iterations with one daemon

client = get_daemon_client()
print(f"Number of current daemon workers {client.get_numprocesses()['numprocesses']}")
wg = WorkGraph("wg_daemon_worker_2")
parallel_add_task = wg.add_task(parallel_add, name="parallel_add", nb_iterations=10)
wg.to_html()

# %%

wg.submit(wait=True)

# %%
# We rerun the last graph builder with 2 damon workers
# And look at the total time and see the overhead costs.

print(
"Time for running parallelized graph builder",
parallel_add_task.mtime - parallel_add_task.ctime,
)



# %%
# We rerun it now with 2 damon workers
client.increase_workers(1)
print(f"Number of current daemon workers {client.get_numprocesses()['numprocesses']}")
wg = WorkGraph("wg_daemon_worker_2")
parallel_add_task_2 = wg.add_task(parallel_add, name="parallel_add", nb_iterations=2)
parallel_add_task_2 = wg.add_task(parallel_add, name="parallel_add", nb_iterations=10)
wg.to_html()

# %%
wg.submit(wait=True)

# %%
print(
"Time for running parallelized graph builder with 2 daemons",
parallel_add_task_2.mtime - parallel_add_task_2.ctime,
)

# %%
# The overhead time has shortens a bit as the handling of the CalcJobs and
# WorkGraphs could be parallelized. One can increase the number of iterations
# to see a more significant difference.
# The time has not change as the handling of the CalcJobs. If one can increase
# the number of iterations to see a more significant difference.


# %%
Expand All @@ -270,7 +283,9 @@ def parallel_add(nb_iterations):
#
# verdi config set daemon.worker_process_slots 200
# verdi daemon restart

#
# For more information about improving the performance please refer to the
# `"Tuning performance" section in the official AiiDA documentation <https://aiida.readthedocs.io/projects/aiida-core/en/latest/howto/installation.html#tuning-performance>`_

# %%
# Further reading
Expand Down

0 comments on commit d28bb99

Please sign in to comment.