Révision 76
| Pi/C/Hybrid/Pi_Hybrid.c (revision 76) | ||
|---|---|---|
| 94 | 94 |
#endif |
| 95 | 95 |
|
| 96 | 96 |
MPI_Status Stat; |
| 97 |
|
|
| 97 |
MPI_Request RequestSend,RequestRecv,RequestSend2,RequestRecv2; |
|
| 98 |
|
|
| 98 | 99 |
rc = MPI_Init(&argc,&argv); |
| 99 | 100 |
if (rc != MPI_SUCCESS) {
|
| 100 | 101 |
printf ("Error starting MPI program. Terminating.\n");
|
| ... | ... | |
| 152 | 153 |
send.process=process; |
| 153 | 154 |
|
| 154 | 155 |
// Split part of code |
| 155 |
for (i=1;i<numtasks;i++) {
|
|
| 156 |
|
|
| 157 |
rc = MPI_Send(&send, 1, mpi_node_type, i, tag, MPI_COMM_WORLD); |
|
| 156 |
for (i=1;i<numtasks;i++) {
|
|
| 157 |
rc = MPI_Isend(&send, 1, mpi_node_type, i, tag, MPI_COMM_WORLD, &RequestSend); |
|
| 158 | 158 |
} |
| 159 |
MPI_Wait(&RequestSend,&Stat); |
|
| 159 | 160 |
|
| 160 | 161 |
#ifdef TIME |
| 161 | 162 |
gettimeofday(&start,(struct timezone *)0); |
| ... | ... | |
| 191 | 192 |
// Join part of code |
| 192 | 193 |
for (i=1;i<numtasks;i++) {
|
| 193 | 194 |
#ifdef LONG |
| 194 |
rc = MPI_Recv(&insideMPI[i], 1, MPI_LONG_LONG, i, tag,
|
|
| 195 |
MPI_COMM_WORLD, &Stat);
|
|
| 195 |
rc = MPI_Irecv(&insideMPI[i], 1, MPI_LONG_LONG, i, tag,
|
|
| 196 |
MPI_COMM_WORLD, &RequestRecv2);
|
|
| 196 | 197 |
#else |
| 197 |
rc = MPI_Recv(&insideMPI[i], 1, MPI_INT, i, tag,
|
|
| 198 |
MPI_COMM_WORLD, &Stat);
|
|
| 198 |
rc = MPI_Irecv(&insideMPI[i], 1, MPI_INT, i, tag,
|
|
| 199 |
MPI_COMM_WORLD, &RequestRecv2);
|
|
| 199 | 200 |
#endif |
| 201 |
MPI_Wait(&RequestRecv2,&Stat); |
|
| 200 | 202 |
printf("\tReceive %lu inside from rank %i\n",(unsigned long)insideMPI[i],i);
|
| 201 | 203 |
insides+=insideMPI[i]; |
| 202 | 204 |
} |
| ... | ... | |
| 213 | 215 |
|
| 214 | 216 |
node recv; |
| 215 | 217 |
|
| 216 |
rc = MPI_Recv(&recv, 1, mpi_node_type, 0, tag, MPI_COMM_WORLD, &Stat); |
|
| 218 |
rc = MPI_Irecv(&recv, 1, mpi_node_type, 0, tag, MPI_COMM_WORLD, &RequestRecv); |
|
| 219 |
MPI_Wait(&RequestRecv,&Stat); |
|
| 217 | 220 |
|
| 218 | 221 |
printf("\t(%s,%i) receive from master %lld with %i process\n",
|
| 219 | 222 |
hostname,rank,(long long)recv.iterations,recv.process); |
| ... | ... | |
| 246 | 249 |
(long long)part_inside); |
| 247 | 250 |
|
| 248 | 251 |
#endif |
| 249 |
|
|
| 252 |
|
|
| 250 | 253 |
#ifdef LONG |
| 251 |
rc = MPI_Send(&part_inside, 1, MPI_LONG_LONG, 0, tag, MPI_COMM_WORLD);
|
|
| 254 |
rc = MPI_Isend(&part_inside, 1, MPI_LONG_LONG, 0, tag, MPI_COMM_WORLD, &RequestSend2);
|
|
| 252 | 255 |
#else |
| 253 |
rc = MPI_Send(&part_inside, 1, MPI_INT, 0, tag, MPI_COMM_WORLD);
|
|
| 256 |
rc = MPI_Isend(&part_inside, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &RequestSend2);
|
|
| 254 | 257 |
#endif |
| 255 | 258 |
|
| 259 |
MPI_Wait(&RequestSend2, &Stat); |
|
| 256 | 260 |
} |
| 257 | 261 |
|
| 258 | 262 |
MPI_Type_free(&mpi_node_type); |
Formats disponibles : Unified diff