# Thread: Is it possible to transfer value from kernel to other kernel?

1. ## Is it possible to transfer value from kernel to other kernel?

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);
}
}
}```

2. You can keep your Data in the global memory on your device.
1. create Buffer on GPU
2. fill Buffer from CPU
3. run Kernel 1 on that Buffer
4. run Kernel 2 on that Buffer

if you cant read from and write to the same buffer you can copy the buffer on the gpu and swap the buffers in kernel 1 and 2

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•