我想了解如何调用此函数与我的程序有关。我的程序正在读取一个文本文件并将每个单词放入一个数组中,如下所示:
// declared outside of main
const static int ARRAY_SIZE = 130000;
using Lines = char[ARRAY_SIZE][16];
// in main
Lines lines;
int i = 0;
if (processId == 0) {
std::ifstream file;
file.imbue(std::locale(std::locale(), new letter_only())); // letter_only is defined
file.open(argv[1]);
std::string workString;
while (file >> workString) {
memset(lines[i], '\0', 16);
memcpy(lines[i++], workString.c_str(), workString.length());
}
}
然后我希望将此数组分成块以传递给进程,然后将工作分散到这些进程。我这样做:
int chunk_size = i/num_processes; // num_processes has the number of processes
int sum = 0;
int my_count = 0;
std::vector<std::string> my_string_vector;
char my_lines[chunk_size][16];
MPI_Scatter(lines,chunk_size,MPI_CHAR,my_lines,chunk_size,MPI_CHAR,0,MPI_COMM_WORLD);
对MPI_Scatter的调用导致程序挂起,我不知道为什么。我将正确的值传递给MPI_Scatter吗?是否有MPI的数据类型字符串?
感谢任何帮助