some optimizations to opencl algorithm