- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想要一个示例来展示如何使用 MPI_Type_create_subarray
为大型矩阵构建二维循环分布。
我知道 MPI_Type_create_darray
会给我二维循环分布,但它与 SCALAPACK
进程网格不兼容。
我会使用 MPI_Type_create_subarray
进行二维 block 循环分布,并将矩阵传递给 SCALAPACK
例程。
我可以举个例子吗?
最佳答案
您的问题至少有两个部分。以下部分将介绍这两个组成部分,但将两者的集成留给您。下面两个部分中包含的示例代码以及下面 ScaLapack 链接中提供的解释应该提供一些指导......
来自 DeinoMPI :
The following sample code illustrates MPI_Type_create_subarray.
#include "mpi.h"
#include <stdio.h>
int main(int argc, char *argv[])
{
int myrank;
MPI_Status status;
MPI_Datatype subarray;
int array[9] = { -1, 1, 2, 3, -2, -3, -4, -5, -6 };
int array_size[] = {9};
int array_subsize[] = {3};
int array_start[] = {1};
int i;
MPI_Init(&argc, &argv);
/* Create a subarray datatype */
MPI_Type_create_subarray(1, array_size, array_subsize, array_start, MPI_ORDER_C, MPI_INT, &subarray);
MPI_Type_commit(&subarray);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank == 0)
{
MPI_Send(array, 1, subarray, 1, 123, MPI_COMM_WORLD);
}
else if (myrank == 1)
{
for (i=0; i<9; i++)
array[i] = 0;
MPI_Recv(array, 1, subarray, 0, 123, MPI_COMM_WORLD, &status);
for (i=0; i<9; i++)
printf("array[%d] = %d\n", i, array[i]);
fflush(stdout);
}
MPI_Finalize();
return 0;
}
来自 ScaLapack in C essentials :
Unfortunately, there is no C interface for ScaLAPACK or PBLAS.All parametersshould be passed into routines and functionsby reference, you can also define constants (i_one for 1, i_negone for -1, d_two for 2.0E+0 etc.) to pass into routines.Matrices should bestoredas 1d array(A[ i + lda*j ], not A[i][j])
To invoke ScaLAPACK routines in your program, you should first initialize grid via BLACS routines (BLACS is enough). Second, you should distribute your matrix over process grid (block cyclic 2d distribution). You can do this by means of pdgeadd_ PBLAS routine. This routine cumputes sum of two matrices A, B: B:=alphaA+betaB). Matrices can have different distribution,in particularmatrixA can be owned by only one process, thus, setting alpha=1, beta=0 you cansimply copy your non-distributed matrix A into distributed matrix B.
Third, call pdgeqrf_ for matrix B. In the end of ScaLAPACK part of code, you can collect results on one process (just copy distributed matrix into local one via pdgeadd_). Finally, close grid via blacs_gridexit_ and blacs_exit_.
After all, ScaLAPACK-using program should contain following:
void main(){
// Useful constants
const int i_one = 1, i_negone = -1, i_zero = 0;
const double zero=0.0E+0, one=1.0E+0;
... (See the rest of code in linked location above...)
关于c - 使用 MPI_Type_create_subarray 做二维循环分布的例子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56789716/
谁能给我一个关于如何使用函数 crypt_r() 的例子吗? 在手册页中,不清楚返回的 char * 字符串是指向函数本身内部(在堆中)分配的内存块,还是仍然指向静态内存,如 crypt()? 最佳答
在 Spectre 中paper ,有一个利用越界数组访问的示例(第 1.2 节)。代码是 if (x < array1_size) y = array2[ array1[x] * 256 ];
这是 Grammar: difference between a top down and bottom up? 的后续问题 我从这个问题中了解到: 语法本身不是自上而下或自下而上的,而是解析器 有些
在java的构造函数中声明变量合法吗?示例。 Time(){ long timeMill = System.currentTimeMillis(); int secon
我一直在仔细研究 slick grid 的示例,并且想要 ping SO 社区并查询 Excel 电子表格编辑演示的示例?就存储而言,网格仅存储整数数据,并且网格将托管在 mvc3 razor 页面内
我很难将愚蠢的菜单置于我网站页面的中心。我知道我可以将外部 div 的宽度设置为 px 值,但我怎样才能让它以响应式网站为中心?这是页面: http://103.4.17.225/~america/i
我正在寻找可在 wordpress 上使用的主题。有时,页面会在调整大小的网络浏览器上正确加载,但在移动设备上却不能,即使尺寸相同,它也会加载某种错误(通常是错位)。例如,在此页面中 ( http:/
union { unsigned char raw[8]; struct { uint8_t gz_method; uint8_t flag;
我想使用 matchShapes() 函数在查询图像中查找对象。 假设我有一本书的模型图像,我想提取它的形状,然后尝试在另一幅图像中找到这本书(它的形状)。 我在谷歌上搜索了很多,但找不到任何关于如何
我正在寻找一个使用 inotify 的简单、简洁的示例gem 来检测目录的更改。 它缺少示例。 最佳答案 examples/watcher.rb 中有一个示例.该链接指向 aredridel 的 re
我一直在努力学习编程中的递归是什么,我需要有人来确认我是否已经完全理解它是什么。 我尝试考虑的方式是通过对象之间的碰撞检测。 假设我们有一个函数。当确定发生碰撞时调用该函数,并使用对象列表调用它以确定
我正在尝试学习如何在我正在处理的项目中使用 jBullet,我已经查看了源提供的演示,但我只是无法弄清楚这些演示如何显示对象。谁有好的资源可以指点我或提供一个在屏幕上显示一个或两个对象的基本示例? 在
我想在一个简单的 x,y 图表上绘制线条,以使用 JGraphT 在 JApplet 中显示。我找到的例子不是很有帮助。有人可以给我指出一些简单的 JGraphT 示例吗? 最佳答案 这里有一个例子,
在解决几何问题时,我遇到了一种称为滑动窗口算法的方法。 真的找不到任何关于它的学习 Material /细节。 算法是关于什么的? 最佳答案 我认为它更像是一种技术而不是一种算法。这是一种可用于各种算
我正在学习同步方法,以防止 Java 中的竞争条件和不良行为。我看到了以下示例,并被告知竞争条件非常微妙: public class Messages { private String messa
我有 100 万个 pdf,如何使用 hadoop 转换为文本并将其用于分析。目标是利用 hadoop 的强大功能将 pdf 数据提取为文本。 最佳答案 我已经在 Hadoop 上处理了一个 pdf
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我读到过,由于堆栈展开,从析构函数中抛出不是一个好主意。我不确定我是否完全理解。所以我尝试了下面的例子 struct foo { ~foo() { throw 1;
任何人都可以告诉我一个简单的(代码)示例来展示 response.encodeURL() 的用法吗?我所有的搜索(包括 google 和 stackoverflow)只提供了 encodeURL()
我受困于 haskell 类型。 {-# LANGUAGE OverloadedStrings #-} module Main ( main ) where import qualified
我是一名优秀的程序员,十分优秀!