1. A method for assigning a computer program having a plurality of threads and data to a processor having a plurality of processor cores and memory organized over a plurality of hardware locality groups, comprising: profiling the computer program to generate a data thread interaction graph representing the computer program, the graph showing interactions between the threads of the computer program and the data of the computer program; organizing the threads and the data of the computer program over a plurality of clusters using the data thread interaction graph and based on one or more constraints, the constraints comprising user-defined constraints and automatically generated constraints, each cluster encompassing at least one of the threads and some of the data of the computer program; displaying the data thread interaction graph to a user and permitting the user to modify the constraints on which basis the threads and the data of the computer program are organized over the clusters, such that where the user modifies the constraints, the threads and the data of the computer program are reorganized over the clusters; mapping each cluster onto one of the hardware locality groups of the processor by solving a stochastic integer programming problem, such that the at least one of the threads encompassed by the cluster are executed using the processor cores and the memory of the processor encompassed by the one of the hardware locality groups to which the cluster has been mapped; regenerating the computer program based on the mapping of each cluster onto one of the hardware locality groups of the processor; at run-time of the computer program, performing one or more optimizations to improve performance of execution of the computer program; and, executing the at least one of the threads encompassed by each cluster using the processor cores and the memory of the processor encompassed by the one of the hardware locality groups to which the cluster has been mapped.