Added OpenMP support for gradient computations