John Smith
2009-05-04 13:42:46 UTC
Hello.
I'm new in MPI and I'm trying to build an MPI application.
I have a problem with the following snippet. I work on a Shared
Memory machine.
Basically I want to allocate some pointers to an abstract class and
then send
the pointers to the processes. In the snippet I have a problem with
the allocation.
It crashes on the line "here b". For some reason the processes cannot
dereference the
pointer
Thanks a lot for any help.
I use the commands :
mpicxx crash.cpp -o crash.exe
mpirun -n 4 ./crash.exe
the file crash.cpp is the following:
#include <mpi.h>
int main( int argc, char *argv[] ) {
const size_t ROOT = 0;
int size, rank;
double *data = 0;
//
MPI_Init( &argc, &argv );
//
MPI_Comm_size( MPI_COMM_WORLD, &size );
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
//
data = new double;
*data = 1.1;
//
MPI_Bcast( &data, 1, MPI_LONG, ROOT, MPI_COMM_WORLD );
//
MPI_Barrier( MPI_COMM_WORLD );
//
printf(" --->>>> here a rank %d, data %p\n", rank, data);
printf(" --->>>> here b rank %d, data %p, value %f\n", rank, data,
*data);
//
MPI_Finalize();
//
return 0;
}
I'm new in MPI and I'm trying to build an MPI application.
I have a problem with the following snippet. I work on a Shared
Memory machine.
Basically I want to allocate some pointers to an abstract class and
then send
the pointers to the processes. In the snippet I have a problem with
the allocation.
It crashes on the line "here b". For some reason the processes cannot
dereference the
pointer
Thanks a lot for any help.
I use the commands :
mpicxx crash.cpp -o crash.exe
mpirun -n 4 ./crash.exe
the file crash.cpp is the following:
#include <mpi.h>
int main( int argc, char *argv[] ) {
const size_t ROOT = 0;
int size, rank;
double *data = 0;
//
MPI_Init( &argc, &argv );
//
MPI_Comm_size( MPI_COMM_WORLD, &size );
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
//
data = new double;
*data = 1.1;
//
MPI_Bcast( &data, 1, MPI_LONG, ROOT, MPI_COMM_WORLD );
//
MPI_Barrier( MPI_COMM_WORLD );
//
printf(" --->>>> here a rank %d, data %p\n", rank, data);
printf(" --->>>> here b rank %d, data %p, value %f\n", rank, data,
*data);
//
MPI_Finalize();
//
return 0;
}