G. *_*ron 4 c++ boolean mpi
我知道 a 的存储std::vector<bool> 不一定是 bool 数组。
std::vector<bool>
如果我想发送接收存储在 a 中的 int 数据std::vector<int>,我会使用MPI_Send(vect.data(),num_of_ints,MPI_INT,dest_rk,tag,comm).
std::vector<int>
MPI_Send(vect.data(),num_of_ints,MPI_INT,dest_rk,tag,comm)
我应该如何使用MPI_Send发送std::vector<bool>?尤其 :
MPI_Send
vect.data()
MPI_CXX_BOOL
Evg*_*Evg 5
std::vector<bool> 专业化没有data()成员函数。标准未指定底层存储方案:
data()
不要求将数据存储为连续的bool值分配。建议使用空间优化的位表示方式。
bool
发送的唯一合理选择std::vector<bool>是将其复制到向量char(或类似类型,如std::int8_t)中,然后发送该向量。更好的选择可能是从一开始就避免std::vector<bool>在代码中出现。
char
std::int8_t
归档时间:
5 年,8 月 前
查看次数:
494 次
最近记录: