cuda implementation