partially working cuda implementation