  In this paper, we present a new technique to dynamically determine the values
of program parameters in order to optimize the performance of a multithreaded
program P. To be precise, we describe a novel technique to statically build
another program, say, R, that can dynamically determine the optimal values of
program parameters to yield the best program performance for P given values for
its data and hardware parameters. While this technique can be applied to
parallel programs in general, we are particularly interested in programs
targeting manycore accelerators. Our technique has successfully been employed
for GPU kernels using the MWP-CWP performance model for CUDA.
