  Cosmic dust particles effectively attenuate starlight. Their absorption of
starlight produces emission spectra from the near- to far-infrared, which
depends on the sizes and properties of the dust grains, and spectrum of the
heating radiation field. The near- to mid-infrared is dominated by the
emissions by very small grains. Modeling the absorption of starlight by these
particles is, however, computationally expensive and a significant bottleneck
for self-consistent radiation transport codes treating the heating of dust by
stars. In this paper, we summarize the formalism for computing the stochastic
emissivity of cosmic dust, which was developed in earlier works, and present a
new library HEATCODE implementing this formalism for the calculation for
arbitrary grain properties and heating radiation fields. Our library is highly
optimized for general-purpose processors with multiple cores and vector
instructions, with hierarchical memory cache structure. The HEATCODE library
also efficiently runs on co-processor cards implementing the Intel Many
Integrated Core (Intel MIC) architecture. We discuss in detail the optimization
steps that we took in order to optimize for the Intel MIC architecture, which
also significantly benefited the performance of the code on general-purpose
processors, and provide code samples and performance benchmarks for each step.
The HEATCODE library performance on a single Intel Xeon Phi coprocessor (Intel
MIC architecture) is approximately 2 times a general-purpose two-socket
multicore processor system with approximately the same nominal power
consumption. The library supports heterogeneous calculations employing host
processors simultaneously with multiple coprocessors, and can be easily
incorporated into existing radiation transport codes.
