When I want to capture the this pointer or outside variable in DPC++ code, I have to write it in my lambda function explicitly
class abc{
queue Q{};
std::array<int, constsize> e;
std::array<double, constsize>t;
abc(){
ua = malloc_shared<double>(local_size, this->Q);
}
void b();
}
void abc::b(){
for(int i=0;i<constsize;i++){
e[i]=i;
t[i]=2*i;
}
buffer<int> ee{e};
buffer<double> tt{t};
auto ini2 = this->Q.submit([&,uq=this->ua](handler &h)
{ accessor eee{ee, h, read_only};
accessor ttt{tt, h, read_only};
h.parallel_for(range{size1, size2, size3}, [=](id<3> idx)
double eu=uq[id[0]];
int aa=eee[id[1]];
double cc=ttt[id[2]];
}
}
But, now I have a lot of variables that need to be captured in the lambda function, do I have to use the same method to write them explicitly? Or there are some other tricks to make this?
When I want to capture the this pointer or outside variable in DPC++ code, I have to write it in my lambda function explicitly
But, now I have a lot of variables that need to be captured in the lambda function, do I have to use the same method to write them explicitly? Or there are some other tricks to make this?