dpc++访问非Conconst大小缓冲区或使用MPI访问类中的共享存储器指针
我尝试根据MPI&制定代码。 DPC ++用于大规模模拟。该问题可以总结为:我想声明数据大小,分配我的类构造函数的数据存储器,然后尝试在我的课堂内的功能中使用它们。然后,我意识到,如果我想使用访问者,我必须为缓冲区提供一个const大小,但是MPI在每个等级上都有不同尺寸的数组。然后,我发现也无法使用共享内存,因为在DPC ++中,我不能使用此指针,并且在类中分配的数组或矩阵不能在子函数中使用。我很困惑,对此一无所知。
代码是这样的:
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([&](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=ua[id[0]];
int aa=eee[id[1]];
double cc=ttt[id[2]];
}
}
可以访问E和T,因为它们具有const大小,我可以使用缓冲区。但是UA具有局部大小,这取决于MPI,因此我不能使用缓冲区,并且共享内存也不能在子功能中使用。
有帮助吗?
I try to develop a code based on MPI & DPC++ for large-scale simulation. The problem can be summarized as: I want to declare the data size, allocate the data memory inside of my class constructor, and then try to use them in the functions inside of my class. Then I realize that I have to provide a const size to the buffer if I want to use an accessor, but MPI makes an array of different sizes on each rank. Then I find that it is also not possible to use shared memory, because in DPC++ I cannot use this pointer, and the array or matrix allocated in the class cannot be used in subfunction. I am confused and have no idea about that.
the code is like this:
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([&](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=ua[id[0]];
int aa=eee[id[1]];
double cc=ttt[id[2]];
}
}
e and t can be accessed because they have const size, and I can use the buffer. But ua has local size, and it depends on MPI, so I cannot use buffer, and shared memory also cannot be used in sub-function.
Any help with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论