1. A computing method, comprising: accepting a notification of a computing task for execution by a group of compute nodes interconnected by a communication network, which has a given interconnection topology and includes network switching elements; identifying, based on the given interconnection topology and on a criterion derived from the computing task, a set of preferred paths in the communication network that connect the compute nodes in the group via at least a subset of the network switching elements to one or more root switching elements; and configuring the network switching elements in the subset to forward node-level results of the computing task produced by the compute nodes in the group to the root switching elements over the preferred paths, so as to cause the root switching elements to calculate and output an end result of the computing task based on the node-level results.