ytree.utilities.parallel.parallel_tree_nodes(tree, group='forest', njobs=0, dynamic=False)[source]

Iterate over nodes in a single tree in parallel.

Nodes are divided up between the available processor groups. Analysis field values can then be assigned to each node (halo).

Note, unlike the parallel_trees and parallel_nodes function, no saving is performed internally. Results saving with the save_arbor must be done manually.

This uses the yt parallel_objects function, which is parallelized with MPI underneath and so is suitable for parallelism across compute nodes.

  • tree (TreeNode) – The tree whose nodes will be iterated over.
  • group (optional, str ("forest", "tree", or "prog")) – Determines the nodes to be iterated over in the tree: “forest” for all nodes in the forest, “tree” for all nodes in the tree, or “prog” for all nodes in the line of main progenitors. Default: “forest”
  • njobs (optional, int) – The number of process groups for parallel iteration. Set to 0 to make the same number of process groups as available processors. Hence, each node will be allocated to a single processor. Set to a number less than the total number of processors to create groups with multiple processors, which will allow for further parallelization. For example, running with 8 processors and setting njobs to 4 will result in 4 groups of 2 processors each. Default: 0
  • dynamic (optional, bool) – Set to False to divide iterations evenly among process groups. Set to True to allocate iterations with a task queue. If True, the number of processors available will be one fewer than the total as one will act as the task queue server. Default: False


>>> import ytree
>>> a = ytree.load("arbor/arbor.h5")
>>> a.add_analysis_field("test_field", default=-1, units="Msun")
>>> trees = list(a[:])
>>> for tree in trees:
...     for node in ytree.parallel_tree_nodes(tree):
...         node["test_field"] = 2 * node["mass"] # some analysis