1. A method of optimizing collective communications within a parallel computer, the parallel computer comprising a plurality of hardware threads for executing software threads of a parallel application, the method comprising: determining for each software thread, by a processor of the parallel computer, an affinity of the software thread to a particular hardware thread, each affinity indicating an assignment of a software thread to a particular hardware thread; generating, based on the affinities of the software threads, one or more affinity domains, wherein an affinity domain indicates which software threads are assigned to hardware threads of the same hardware domain; generating, for each affinity domain, a topology of the affinity domain based on the affinities of the software threads to the hardware threads; and performing, based on the generated topologies of the affinity domains, a collective operation on one or more software threads.