DPC++ access the the nonconst size buffer or access the shared memory pointer in class using MPI

86 views Asked by At

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?

0

There are 0 answers