如何用mpic++并行化函数
How to parallelize function with MPI c++
我是MPI的新手,在学习了基础知识之后,我仍然不明白如何利用MPI并行执行两个函数,一个用于元素的第一部分,第二个用于第二部分。例如:
for(int i = 0; i < argc/2; i++){
function(el[i]);
}
for(int i = 0; i < argc-1; i++){
function(el[i]);
}
如何使用MPI_Send, MPI_recv ecc ?
MPI是一个多处理器库,而不是多线程库。因此,数据被分割,不能被看作是一个单一的数组,内核可以处理其中的一部分。
在这里,为了处理数据,每个核心需要有一个包含一半数据的数组。使用MPI_SEND和MPI_RECV,它看起来像这样
Get rank and number of proc
Create subarray
Pass parts of initial array from proc 0 to other procs (With MPI_SEND for proc 0 and MPI_RECV for others)
Each proc do the calculation
Reunite the results with a new set of send/recv
之后,还存在一些函数,使数据的传播和统一更加容易
好运相关文章:
- 如何在Elixir中调用递归函数并行
- 如何使用非默认构造函数实例化模板化类
- 如何使用OpenMP并行化此矩阵时间矢量运算
- 字符串化递归的"std::vector<std::vector<...>>"而不使用部分模板函数专用化
- 有没有一种代码密度较低的方法来使用非默认构造函数初始化数组?
- 如何在 C++ 中使用它的构造函数初始化 unique_ptrs 的 2D 向量?
- 如何使用 MPI 的远程内存访问 (RMA) 功能并行化数据聚合?
- 在C++中使用并行化的预期速度是多少(不是 OpenMp,而是 <thread>)
- 我们是否需要为 C++ 中的多个函数初始化多个模板?
- 如何使用 OpenMP 并行化最近邻搜索
- Malloc 在使用线程并行化 SSH 调用时存在问题
- 在C++中使用默认构造函数初始化对象的不同方法
- HPX 是否提供具有粒度控制的基于任务的并行化迭代函数?
- OpenMP 不在 for 循环中的顺序函数的并行化
- 尝试使用 OpenMP 并行化递归函数的冗余计算
- C++ OpenMP 中线性代数函数的高效并行化
- 在C++中使用OpenMP实现递归函数的并行化
- 如何用mpic++并行化函数
- 我可以使用OpenACC来并行化调用某些函数的大代码吗
- OpenMP从并行for循环调用并行化函数