Memory size was too big for the GPU for the original CUDA method. This attempt gets rid of matrices like cor,cor_bi and cmatrix so that each thread has less memory. As of now,serial code is implemented here to check if the new method works