implementing pairwise_pyopencl like gemm_pyopencl