The difference between iostream and stdio in MPI
来源:互联网 发布:淘宝如何分类宝贝 编辑:程序博客网 时间:2024/05/29 14:34
在获取机器信息的时候,发现了iostream和stdio在MPI中的输出不一样。
下面分别使用这两种IO对机器名称、当前进程号和总进程数,运行环境是具有三核的PC,使用两个核来运行MPI程序。按照预想的结果,应该是随机输出每一个进程的机器名称与当前进程号和总进程数的输出信息,每一个进程的输出信息应该是完整的顺序输出机器名称、当前进程号和总进程数。
1 首先是使用iostream获取机器信息的函数代码
输出结果如下:
Machine Name: Justin
Machine Name: Justin
Current Process ID: 0
Total Number of Processes: 2
Current Process ID: 1
Total Number of Processes: 2
有时候输出结果是:
Machine Name: Justin
Machine Name: Justin
Current Process ID: 1
Current Process ID: 0
Total Number of Processes: 2
Total Number of Processes: 2
可以看出,使用iostream的代码输出的结果与我们的预想不同,两个进程的stream似乎相互纠缠在一起,有较大的随机性。
2 接下来,测试一下使用iostream获取机器信息的函数代码
输出结果如下:
Machine Name: Justin
Current Process ID: 0
Total Number of Processes: 2
Machine Name: Justin
Current Process ID: 1
Total Number of Processes: 2
再测试一下多次运行的结果,都比较稳定,只是当前进程号出现的顺序不一样。
可以看出stdio输出结果相对稳定。
出现此想象的原因,还期待MPI高手来解惑。
注:
GetMachineName(),GetTotalProcessCount(),GetCurrentProcessId()是对MPI相应函数的简单包装,具体实现请参见http://blog.csdn.net/Rabbit_2001/archive/2009/07/24/4376075.aspx
- The difference between iostream and stdio in MPI
- Multi-thread: What is the difference between OpenMP and MPI
- The difference between (()) and ().
- Understand the difference between IN and EXISTS in subqueries
- The difference between BEB in MACA and in MACAW
- The difference between && and ; in the Linux command line
- What's the difference between LastWriteTime and ChangeTime in FILE_BASIC_INFO?
- the difference between require() and include() in php
- The difference between EXISTS and IN upon Oracle
- the difference between final and static in java
- What is the difference between BIT and TINYINT in MySQL
- What's the difference between Template and Table in Smartforms
- What's the difference between “local” and “my” in Perl
- The difference between null and isEmpty in Groovy
- difference between count(*) and count(col) in the query
- What is the difference between fprintf and vfprintf in C++?
- what is the difference between definition and declaration in c
- what is the difference between _source and _all in Elasticsearch
- IE下div的高度问题
- 无语!!
- iPhone-3G工程师走俏,人才供不应求
- 使用多线程提高GUI响应,以及结束任务的方法
- this的用法
- The difference between iostream and stdio in MPI
- 为混血儿Iceweasel安装Google Toolbar
- FOJ--1629--Above Average--解题报告
- CClientDC、CPaintDC、CWindowDC类、WM_PAINT消息
- 产品经理的能力模型
- 异常处理与MiniDump详解(3) SEH(Structured Exception Handling)
- 根据XML Schema生成java类
- 我们网友的偏激——群体是偏激的,但不等于不可以更深入的客观
- 深圳电视台饭没了秀节目浪费警力资源