Hi,

Since you are using std::string in your structure you should allocate the memory with "new" instead of "malloc". Otherwise the constructor of std::string is not called and things like the length() of a string might not give the desired result leading boost to iterate over too many chars.

I don't know if this is the particular problem here but it might be ...


On Mar 17, 2010, at 6:11 AM, alev mutlu wrote:

Hi the following codes compiles fine but gives some run time errors.
Ant suggestions to fix the problem.

cheers


Code

#include<boost/mpi/environment.hpp>
#include<boost/mpi/communicator.hpp>
#include<boost/mpi/collectives.hpp>
#include<boost/thread/barrier.hpp>
#include<boost/thread/mutex.hpp>
#include<boost/config.hpp>
#include<boost/archive/text_oarchive.hpp>
#include<boost/archive/text_iarchive.hpp>
#include<boost/serialization/access.hpp>
#include<boost/serialization/string.hpp>
#include<boost/mpi/skeleton_and_content.hpp>
#include<boost/mpi/datatype.hpp>
#include<boost/mpi/allocator.hpp>
#include<boost/archive/tmpdir.hpp>
#include<boost/serialization/utility.hpp>
#include<boost/serialization/base_object.hpp>
#include<boost/mpi.hpp>
#include<boost/tokenizer.hpp>
#include<boost/archive/tmpdir.hpp>
#include<boost/archive/binary_oarchive.hpp>
#include<boost/serialization/export.hpp>
#include<boost/serialization/base_object.hpp>
#include<boost/serialization/utility.hpp>
#include<boost/serialization/hash_map.hpp>
#include<boost/serialization/map.hpp>



#include<string>
#include<iostream>
#include<vector>
#include<fstream>

#define MASTER 0

int arraySize = 7;

using namespace std;
namespace mpi = boost::mpi;

struct field {
     string field_name;
     string field_type;
     string field_ref;
     string field_colType;

};

namespace boost {
     namespace serialization{
         template<class Archive>
         void serialize(Archive&  ar, struct field&  f,  unsigned int version){
             ar&  f.field_name;
             ar&  f.field_type;
             ar&  f.field_ref;
             ar&  f.field_colType;
         }
     }
}

int main(int argc, char* argv[])
{
     mpi::environment env(argc, argv);
     mpi::communicator world;
     int m_mySize, w_mySize, kk,i;
     struct field *relAllValues;
     struct field *relMyValues;
     vector<struct field>  C;
     struct field c;

     w_mySize = arraySize / world.size();
     cout<<  "w_mySize = "<<  w_mySize<<  endl;
     if (world.rank() == MASTER){
         for(int i = 0; i<  arraySize; i++){
             c.field_name = "field_name=" ;
             c.field_type = "field_type=";
             c.field_ref = "field_ref=";
             c.field_colType = "field_colType=";
             C.push_back(c);
         }
           m_mySize = arraySize / world.size() + arraySize % world.size();
         relMyValues = (struct field *) malloc(sizeof(struct field) * w_mySize);
         relAllValues = (struct field *) malloc(sizeof(struct field) * 
arraySize);

     }
       else{
          relMyValues = (struct field *) malloc(sizeof(struct field) * 
w_mySize);
       }

       if (world.rank() == MASTER){
           scatter(world, C, relMyValues, w_mySize, 0);
       }
       else{
           scatter(world, C, relMyValues, w_mySize, 0);
       }
}

and the run time errors

[ceng34:00724] *** Process received signal ***
[ceng34:00724] Signal: Segmentation fault (11)
[ceng34:00724] Signal code: Address not mapped (1)
[ceng34:00724] Failing at address: 0xfffffffffffffff8
[ceng34:00724] [ 0] /lib64/libpthread.so.0 [0x315880de80]
[ceng34:00724] [ 1] 
/usr/lib64/libstdc++.so.6(_ZN9__gnu_cxx18__exchange_and_addEPVii+0x2) 
[0x385dab7672]
[ceng34:00724] [ 2] /usr/lib64/libstdc++.so.6(_ZNSs6assignERKSs+0x9b) 
[0x385da9ca4b]
[ceng34:00724] [ 3] test-boost(_ZN5fieldaSERKS_+0x47) [0x42197f]
[ceng34:00724] [ 4] 
test-boost(_ZNSt6__copyILb0ESt26random_access_iterator_tagE4copyIPK5fieldPS3_EET0_T_S8_S7_+0x3c)
 [0x4221be]
[ceng34:00724] [ 5] test-boost(_ZSt10__copy_auxIPK5fieldPS0_ET0_T_S5_S4_+0x29) 
[0x422203]
[ceng34:00724] [ 6] 
test-boost(_ZNSt13__copy_normalILb0ELb0EE6copy_nIPK5fieldPS2_EET0_T_S7_S6_+0x25)
 [0x42222b]
[ceng34:00724] [ 7] test-boost(_ZSt4copyIPK5fieldPS0_ET0_T_S5_S4_+0x2d) 
[0x42225b]
[ceng34:00724] [ 8] 
test-boost(_ZN5boost3mpi6detail12scatter_implI5fieldEEvRKNS0_12communicatorEPKT_PS7_iiN4mpl_5bool_ILb0EEE+0x90)
 [0x42a630]
[ceng34:00724] [ 9] 
test-boost(_ZN5boost3mpi7scatterI5fieldEEvRKNS0_12communicatorEPKT_PS6_ii+0x50) 
[0x42b162]
[ceng34:00724] [10] 
test-boost(_ZN5boost3mpi7scatterI5fieldEEvRKNS0_12communicatorERKSt6vectorIT_SaIS7_EEPS7_ii+0x55)
 [0x42b1db]
[ceng34:00724] [11] test-boost(main+0x20e) [0x420880]
[ceng34:00724] [12] /lib64/libc.so.6(__libc_start_main+0xf4) [0x3157c1d8b4]
[ceng34:00724] [13] test-boost(__gxx_personality_v0+0x169) [0x420489]
[ceng34:00724] *** End of error message ***
mpirun noticed that job rank 0 with PID 724 on node ceng34-ib exited on signal 
11 (Segmentation fault).
_______________________________________________
users mailing list
us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/users


Reply via email to