<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>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, <FONT face="">MPI_CHAR</FONT>, input_file_status);<BR> output_file.Write_shared(buf, 20, <FONT face="">MPI_CHAR</FONT>, output_file_status);<BR> }<BR> }<BR> cout << "Error";<BR> input_file.Close();<BR> output_file.Close();<BR> <BR> MPI::Finalize();<BR>}<BR><BR><br /><hr />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></body>
</html>