Temperature management is a key challenge for many-core platforms in the dark silicon era as all the cores cannot be powered-on together at the maximum frequency and either some cores should run at lower frequency or only a portion can be used without burning the device. In addition, due to process variations and/or design optimization, not all the integrated processing elements (PEs) are identical and each of them may feature a different power/temperature/frequency trade-off. Many works have been proposed to tackle the thermalaware task mapping problem in multicore devices, but none has yet demonstrated the capability to find optimal solutions within seconds for a large number of cores, with heterogeneous power/frequency operating points, while ensuring a safe transient thermal map. In this paper we propose a new Integer Linear Programming formulation, based on a coarse-grain dynamic thermal model, for this class of problems. Our solver finds optimal solutions in few seconds for a 64 core system. Furthermore, we show that by limiting the number of iterations in the solver, we achieve low optimality gaps, with times compatible to an on-line (execution time) use of the optimal allocator.