REDUCE: divided the execution in two parts and added barrier/mem_fence in kernels