c - MPI_Gather 动态 2D 分配数组 - MPI C
问题描述
在每个处理器上,我都动态分配了二维数组:
char** result = malloc(maxRows * sizeof(char*));
int i;
for(i = 0 ; i<maxRows; ++i) result[i] = malloc(maxCols * sizeof(char));
但是这些数组填充了存储在名为count
wherecount < maxRows
的变量中的不同大小。我想将这些数组收集到主机上的一个数组中。请问有什么想法吗?
数据示例:
Process 1 : count = 3 , result[0] = "hello" , result[1] = "MPI" , result[2] = "World".
Process 2 : count = 2 , result[0] = "hi" , result[1] = "stackoverflow".
我希望主进程返回:
Process 0 (master) : count = 5 , result[0] = "hello" , result[1] = "MPI" ,
result[2] = "World" , result[3] = "hi" , result[4] = "stackoverflow".
解决方案
推荐阅读
- c - 在 printf 中使用 &ersand 和方括号
- java - 使用 java.net.http.HttpClient 的 GOAWAY BItBucket API
- c# - Android webview 在继续运行后挂起/崩溃(2-3 天)
- docker - 在容器内更新 cgroup 的最低功能是什么?
- django - 如何在 IIS 服务器上运行多个 django 应用程序?
- vim - Vim 不尊重 vimrc 缩进设置
- php - 如何在codeigniter rest api中使用刷新令牌?
- amazon-web-services - Amazon AWS SES 错误 - 限制失败:超出最大 SigV2 SMTP 发送速率
- mongodb - 至少有一个文档满足每个条件的 MongoDB 查询
- c# - 在 Hyper-V VM Powershell C# 上调用命令