In this dissertation, we show that source-to-source optimization is an efficient method to generate a high performance program for irregular and heterogeneous code from a basic implementation. After describing the evolution of processor architectures, we provide two methods. The first one extract codelets from an irregular code, optimizing these codelets, and predicting the performance of the modified program. The other one limits the impact of alignment issues due to vectorization or bank conflicts. We also present two parallelization technics, one generating parallel codelets, the other scheduling a task graph on an heterogeneous system.