  Obtaining good performance when programming heterogeneous computing platforms
poses significant challenges for the programmer. We present a program
transformation environment, implemented in Haskell, where architecture-agnostic
scientific C code with semantic annotations is transformed into functionally
equivalent code better suited for a given platform. The transformation steps
are formalized (and implemented) as rules which can be fired when certain
syntactic and semantic conditions are met. These conditions are to be fulfilled
by program properties which can be automatically inferred or, alternatively,
stated as annotations in the source code. Rule selection can be guided by
heuristics derived from a machine learning procedure which tries to capture how
run-time characteristics (e.g., resource consumption or performance) are
affected by the transformation steps.
