1. A computer-implemented method executed by at least one processor for allocating work to a hardware accelerator in a computer system that includes the hardware accelerator and at least one processor executing a computer program, the method comprising the steps of: reading an accelerator policy that specifies criteria that determines when a function is allocated to the hardware accelerator; analyzing the computer program; and allocating at runtime the function in the computer program to the hardware accelerator when the criteria in the accelerator policy is satisfied based on processor estimates of performance for the function and hardware accelerator estimates of performance for the function.