C++ version using openmp