First at all,i need to say sorry for my bad english....
I'm working on quasi-newton's BFGS method in CL,but the BFGS formula seems can't work in only 1 kernel for me....
So i'm just thinking if there are any solution that transfer the value to the second kernel without reading the value from memory buffer(clEnqueueReadBuffer)?


in my original code,the formula need to done in step..
any suggestions?.

Here is my code in c,
Code :
void BGFS(){
	double y[M],s[M],sTy,Hy[M],HysT[M][M],sHyT[M][M],yTHy,ssT[M][M];
	sTy=0.0;
	yTHy=0.0;
	b1[0]=fx1(x2[0],x2[1]);
	b1[1]=fx2(x2[0],x2[1]);
	for(i=0;i<M;i++){
		Hy[i]=0.0;
		s[i]=x2[i]-x1[i]; //sk=xk+1-xk
		y[i]=b1[i]-b[i]; //yk=∇f(x+1)-∇f(x)
	}
	for(i=0;i<M;i++){
		sTy+=s[i]*y[i];
		for(j=0;j<M;j++){
			Hy[i]+=H[i][j]*y[j];
			ssT[i][j]=s[i]*s[j];
		}
	}
	for(i=0;i<M;i++){
		yTHy+=y[i]*Hy[i];
		for(j=0;j<M;j++){
			HysT[i][j]=Hy[i]*s[j];
			sHyT[i][j]=s[i]*Hy[j];
		}
	}
 
	for(i=0;i<M;i++){
		for(j=0;j<M;j++){
			H1[i][j]=H[i][j]-((HysT[i][j]+sHyT[i][j])/sTy)+(1+(yTHy/sTy))*(ssT[i][j]/sTy);
		}
	}
}