<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:Arial;
        color:navy;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
/* List Definitions */
@list l0
        {mso-list-id:1689672426;
        mso-list-type:hybrid;
        mso-list-template-ids:-202464672 -866891874 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Arial;
        mso-fareast-font-family:"Times New Roman";}
@list l0:level2
        {mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-tab-stop:1.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level4
        {mso-level-tab-stop:2.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-tab-stop:2.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-tab-stop:3.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level7
        {mso-level-tab-stop:3.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-tab-stop:4.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=blue>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi Erich,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Frankly the code leading up to that for
loop is a bit scary. I don’t really know anything about MPI I/O,
but I can get you a few tips on your C++:<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><span style='mso-list:Ignore'>-<font size=1 face="Times New Roman"><span
style='font:7.0pt "Times New Roman"'>
</span></font></span></span></font><![endif]><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>Unless
you’re using a horribly out of date compiler like MSVC 6, you should use
the standard header names <iostream>, <vector>, <ctime>, etc.<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><span style='mso-list:Ignore'>-<font size=1 face="Times New Roman"><span
style='font:7.0pt "Times New Roman"'>
</span></font></span></span></font><![endif]><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>If you
are using a horribly out of date compiler like MSVC 6, you should upgrade to
the free MSVC++ 2005 Express Edition.<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><span style='mso-list:Ignore'>-<font size=1 face="Times New Roman"><span
style='font:7.0pt "Times New Roman"'>
</span></font></span></span></font><![endif]><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>In this
case it’s a cosmetic fix, but you should probably pass the
vector<bool> parameter by reference instead of by value.<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><span style='mso-list:Ignore'>-<font size=1 face="Times New Roman"><span
style='font:7.0pt "Times New Roman"'>
</span></font></span></span></font><![endif]><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>You seem
to be doing some mind boggling casting in order to determine if
num_elements_per_rank is too big to fit in an int (but only on your last
process?). You might get rid of that voodoo by using size_t (usually at
least an unsigned 4 byte int) for your position indexes instead
(vector<T>::size() returns vector<T>::size_type which usually boils
down to size_t).<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Beyond that, I would need to see some
debug output from your for loop. For example, what indexes are actually
being passed to the I/O calls by each process? Does MPI::File::Read_at()
allocate memory for the “buf” variable you pass it? If not,
you haven’t allocated any memory for it and that would lead to a crash
before you could say “new char.”<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Good luck,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Matt Chambers<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> <st1:PersonName
w:st="on">owner-<st1:PersonName w:st="on">mpich-discuss@mcs.anl.gov</st1:PersonName></st1:PersonName>
[mailto:<st1:PersonName w:st="on">owner-<st1:PersonName w:st="on">mpich-discuss@mcs.anl.gov</st1:PersonName></st1:PersonName>]
<b><span style='font-weight:bold'>On Behalf Of </span></b>Erich Peterson<br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, April 18, 2007
3:02 AM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName w:st="on">mpich-discuss@mcs.anl.gov</st1:PersonName><br>
<b><span style='font-weight:bold'>Subject:</span></b> [MPICH] Help With I/O</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>Hi all, I'm trying to write this
little routine which is part of my graduate project. What I'm trying to do is
pass a vector of bools in to the QueryData method. In that method I split the
vector up into equal parts among the number of processes, have each process
open a datafile which as 20 byte records (no new lines), read that record from
the file if the vector they are checking has "true" (basically
if vector[0] = true, it means grab the first record of the file), and lastly,
it should output that record into a new file.<br>
<br>
I have been able to determine it is messing up on the for-loop. The error is:<br>
<br>
[Student@cluster1 erich_test_area]$ mpiexec -n 3
/mnt/pvfs2/acxiom/erich_test_area/RecordRetrieval<br>
terminate called after throwing an instance of 'MPI::Exception'<br>
terminate called after throwing an instance of 'MPI::Exception'<br>
terminate called after throwing an instance of 'MPI::Exception'<br>
rank 0 in job 1 cluster1_33602 caused collective abort of all
ranks<br>
exit status of rank 0: killed by signal 6 <br>
<br>
If someone could please tell me or edit the code if they see what is wrong.
Thanks!<br>
<br>
Main.cpp:<br>
<br>
#include "RecordRetrieval.h"<br>
#include <vector.h><br>
int main()<br>
{<br>
vector<bool> vec;<br>
vec.push_back(true);<br>
vec.push_back(false);<br>
vec.push_back(true);<br>
vec.push_back(false);<br>
vec.push_back(true);<br>
vec.push_back(false);<br>
RecordRetrieval rec;<br>
rec.QueryData(vec, "test.dat");<br>
return 0;<br>
}<br>
<br>
RecordRetrieval.cpp:<br>
<br>
#include "RecordRetrieval.h"<br>
#include "mpi.h"<br>
#include "time.h"<br>
#include "iostream.h"<br>
void RecordRetrieval::QueryData(vector<bool> unencoded_vector, char *
filename)<br>
{<br>
int num_processes;<br>
int num_vector_elements;<br>
float num_elements_per_rank;<br>
int local_start_position;<br>
int local_end_position;<br>
char * buf;<br>
int my_rank;<br>
MPI::File input_file;<br>
MPI::Status input_file_status;<br>
MPI::File output_file;<br>
MPI::Status output_file_status;<br>
//MPI::Offset filesize;<br>
char output_filename[30];<br>
size_t i;<br>
struct tm tim;<br>
time_t now;<br>
now = time(NULL);<br>
tim = *(localtime(&now));<br>
i = strftime(output_filename, 30,
"%m_%d_%Y_%H_%M_%S", &tim);<br>
<br>
/* Let the system do what it needs to start up MPI */<br>
MPI::Init();<br>
/* Get my process rank */<br>
my_rank = MPI::COMM_WORLD.Get_rank();<br>
/* Find out how many processes are being used */<br>
num_processes = MPI::COMM_WORLD.Get_size();<br>
num_vector_elements = unencoded_vector.size();<br>
<br>
num_elements_per_rank = num_vector_elements /
num_processes;<br>
local_start_position = my_rank * (int)num_elements_per_rank;<br>
if(my_rank == num_processes - 1)<br>
{<br>
if(num_elements_per_rank *
num_processes == (int)num_elements_per_rank * num_processes)<br>
{<br>
local_end_position = local_start_position + ((int)num_elements_per_rank - 1);<br>
}<br>
else<br>
{<br>
local_end_position = (local_start_position + (int)num_elements_per_rank - 1) +<br>
(((int)num_elements_per_rank * num_processes) - ((int)num_elements_per_rank *
num_processes));<br>
}<br>
}<br>
else<br>
{<br>
local_end_position =
local_start_position + ((int)num_elements_per_rank - 1);<br>
}<br>
input_file = MPI::File::Open(MPI::COMM_WORLD, filename,
MPI::MODE_RDONLY,<br>
MPI::INFO_NULL);<br>
output_file = MPI::File::Open(MPI::COMM_WORLD,
output_filename, MPI::MODE_CREATE | MPI::MODE_WRONLY, MPI::INFO_NULL);<br>
// filesize = input_file.Get_size();<br>
for(int i = local_start_position; i < local_end_position
+ 1; i++)<br>
{<br>
if(unencoded_vector[i])<br>
{<br>
input_file.Read_at(i * 20, buf, 20, MPI_CHAR, input_file_status);<br>
output_file.Write_shared(buf, 20, MPI_CHAR, output_file_status);<br>
}<br>
}<br>
cout << "Error";<br>
input_file.Close();<br>
output_file.Close();<br>
<br>
MPI::Finalize();<br>
}<o:p></o:p></span></font></p>
<div class=MsoNormal align=center style='text-align:center'><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
<hr size=2 width="100%" align=center>
</span></font></div>
<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>Discover the new Windows Vista <a
href="http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE"
target="_new">Learn more!</a><o:p></o:p></span></font></p>
</div>
</div>
</body>
</html>