for loop speedup in grdients X