DPC++ & MPI、缓冲区、共享内存、变量声明

Mac*_*ooo 0 c++ mpi sycl intel-oneapi dpc++

我是 DPC++ 的新手,我尝试开发一个基于 MPI 的 DPC++ 泊松解算器。我读了这本书,对缓冲区和指针与共享或主机内存感到非常困惑。这两件事有什么区别,我开发代码时应该使用什么。

现在,我使用由具有 const 大小的 std::array 初始化的缓冲区作为串行代码,并且效果良好。然而,当我将 DPC++ 代码与 MPI 耦合时,我必须为每个设备声明本地长度,但我没有这样做。这里我附上我的代码

    define nx 359
    define ny 359
    constexpr int local_len[2];
    global_len[0] = nx + 1;
    global_len[1] = ny + 1;

    for (int i = 1; i < process; i++)
    {
        if (process % i == 0)
        {
            px = i;
            py = process / i;
            config_e = 1. / (2. * (global_len[1] * (px - 1) / py + global_len[0] * (py - 1) / px));
        }
        if (config_e >= cmax)
        {
            cmax = config_e;
            cart_num_proc[0] = px;
            cart_num_proc[1] = py;
        }
    }
    local_len[0] = global_len[0] / cart_num_proc[0];
    local_len[1] = global_len[1] / cart_num_proc[1];
    
    constexpr int lx = local_len[0];
    constexpr int ly = local_len[1];
    queue Q{};
    double *m_cellValue = malloc_shared<double>(size, Q);
Run Code Online (Sandbox Code Playgroud)

我收到错误

error: default initialization of an object of const type 'const int[2]'
error: cannot assign to variable 'local_len' with const-qualified type 'const int[2]'
main.cpp:52:18: error: cannot assign to variable 'local_len' with const-qualified type 'const int[2]'
Run Code Online (Sandbox Code Playgroud)

有没有办法只定义一个可变大小的数组来在 DPC++ 中进行并行?

Vic*_*out 5

你太急于使用了constexpr。删除此代码中的所有三个匹配项,它应该可以编译。所以这与DPC++无关。