- Oct 9, 2001
- 209
- 0
- 0
I am trying to send the following structure using MPI_Type_struct:
struct individual
{
unsigned *chrom;
double fitness;
int xsite;
int parent[2];
int *utility;
};
My program crashes durring send, what happens is chrom transmits successfully, but everything else seems to be messed up. I did deep copies of everything too make sure that my unsigned * and int * are equivilant to unsigned[] and int[]. I know that the offset is supposed to be of type MPI_AINT, but I havn't seen any good description of how to use something of this type. If anyone in the forum is experianced with MPI and can help that would be great. I have my program working where I send each member of each individual I am transmitting individaully, but as you can imagin this is quite inefficiant.
derive my MPI type is cut and pasted below:
floatsize = sizeof(float);
intsize = sizeof(int);
blen[0] = chromsize; byteOffSet[0] = 0; oldtypes[0] = MPI_UNSIGNED;
blen[1] = 1; byteOffSet[1] = nbytes; oldtypes[1] = MPI_DOUBLE;
blen[2] = 1; byteOffSet[2] = (nbytes + floatsize); oldtypes[2] = MPI_INT;
blen[3] = 2; byteOffSet[3] = (nbytes + floatsize + intsize); oldtypes[3] = MPI_INT;
blen[4] = ulen; byteOffSet[4] = (nbytes + floatsize + (intsize * 3)); oldtypes[4] = MPI_INT;
blen[5] = 1; byteOffSet[5] = sizeof(struct individual); oldtypes[5] = MPI_UB;
MPI_Type_struct(6, blen, byteOffSet, oldtypes, &MPI_INDI);
Here is where I'm doing my sending and reciving:
if (workstation_id < other)
{
MPI_Send(my_transmition, num_transmit, MPI_INDI, other,
num_transmit, MPI_COMM_WORLD);
MPI_Recv(temp, num_transmit, MPI_INDI, other, num_transmit,
MPI_COMM_WORLD, &status);
_heapchk();
}
else
{
MPI_Recv(temp, num_transmit, MPI_INDI, other, num_transmit,
MPI_COMM_WORLD, &status);
MPI_Send(my_transmition, num_transmit, MPI_INDI, other,
num_transmit, MPI_COMM_WORLD);
_heapchk();
}
_heapchk() is a microsoft function which verifies that the heap is in
good condition. Thank a lot.
Carlo Razzeto
struct individual
{
unsigned *chrom;
double fitness;
int xsite;
int parent[2];
int *utility;
};
My program crashes durring send, what happens is chrom transmits successfully, but everything else seems to be messed up. I did deep copies of everything too make sure that my unsigned * and int * are equivilant to unsigned[] and int[]. I know that the offset is supposed to be of type MPI_AINT, but I havn't seen any good description of how to use something of this type. If anyone in the forum is experianced with MPI and can help that would be great. I have my program working where I send each member of each individual I am transmitting individaully, but as you can imagin this is quite inefficiant.
derive my MPI type is cut and pasted below:
floatsize = sizeof(float);
intsize = sizeof(int);
blen[0] = chromsize; byteOffSet[0] = 0; oldtypes[0] = MPI_UNSIGNED;
blen[1] = 1; byteOffSet[1] = nbytes; oldtypes[1] = MPI_DOUBLE;
blen[2] = 1; byteOffSet[2] = (nbytes + floatsize); oldtypes[2] = MPI_INT;
blen[3] = 2; byteOffSet[3] = (nbytes + floatsize + intsize); oldtypes[3] = MPI_INT;
blen[4] = ulen; byteOffSet[4] = (nbytes + floatsize + (intsize * 3)); oldtypes[4] = MPI_INT;
blen[5] = 1; byteOffSet[5] = sizeof(struct individual); oldtypes[5] = MPI_UB;
MPI_Type_struct(6, blen, byteOffSet, oldtypes, &MPI_INDI);
Here is where I'm doing my sending and reciving:
if (workstation_id < other)
{
MPI_Send(my_transmition, num_transmit, MPI_INDI, other,
num_transmit, MPI_COMM_WORLD);
MPI_Recv(temp, num_transmit, MPI_INDI, other, num_transmit,
MPI_COMM_WORLD, &status);
_heapchk();
}
else
{
MPI_Recv(temp, num_transmit, MPI_INDI, other, num_transmit,
MPI_COMM_WORLD, &status);
MPI_Send(my_transmition, num_transmit, MPI_INDI, other,
num_transmit, MPI_COMM_WORLD);
_heapchk();
}
_heapchk() is a microsoft function which verifies that the heap is in
good condition. Thank a lot.
Carlo Razzeto
