algorithm - 部分填充的 MPI 笛卡尔网格
问题描述
是否可以创建仅“部分”填充节点的 MPI 笛卡尔网格?下面的一段代码总结了这个问题。我正在创建一个 4x4 网格,并且仅使用 15 个处理器运行程序,这会引发“MPI_ERR_DIMS:无效拓扑维度”错误。
下面是重现错误的代码(当使用少于 4x4=16 的处理器运行时):
MPI_Comm
create_topology(int size)
{
MPI_Comm grid;
int dims[2] = {4,4};
int periods[2] = {0,0};
MPI_Dims_create(size, 2, dims);
printf("dims = {%d,%d}", dims[0], dims[1]);
MPI_Cart_create(MPI_COMM_WORLD, 2, dims,
periods, 0, &grid);
return grid;
}
int
main(int argc, char** argv)
{
MPI_Comm topo;
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* Initializing the grid */
topo = create_topology(size);
/* Printing coordinates */
int coords[2];
MPI_Cart_coords(topo, rank, 2, coords);
if(rank == 0) {
printf("Root: [%d] -> [%d,%d]\n",
rank, coords[0], coords[1]);
} else {
printf("Process: [%d] -> [%d,%d]\n",
rank, coords[0], coords[1]);
}
MPI_Finalize();
return 0;
}
我还尝试直接传递一个 dims[]{4,4} 数组,而不使用 MPI_Dims_create 函数,该函数从 MPI_Cart_create 引发了一个 MPI_ERR_ARG。
有没有办法做到这一点?
解决方案
推荐阅读
- arrays - Perl - 从存储在哈希引用中的数组中获取数组值的问题
- c++ - 获取两个不同模板的产品类型
- php - 如何在php中使用htaccess重定向到特定的文件夹/页面
- animation - Update normals of animated skinned mesh in three.js?
- python - TypeError:写入文件需要一个整数(获取类型 str)
- tensorflow - How to fix "Invalid argument: Key: feature. Can't parse serialized Example."
- r - 我从 Excel 导入数据。但我不知道如何使用感测器包使用数据
- c# - Xamarin Forms: Remote Images don't load on Android
- spring-boot - Monitoring spring boot cache metrics with Prometheus
- java - 根据列表内容调用 Java 类