master
Nihonium 9 months ago
parent 5a0a8acb38
commit 1415032a88

@ -0,0 +1,47 @@
#include <stdio.h>
#include <mpi.h>
#include <stdlib.h>
#include <unistd.h>
// 3 КБайта
#define MESSAGE_SIZE (3*1024)
#define IDX0 0
#define IDX1 1
int main(int argc, char *argv[]) {
double start_time, end_time;
double start_send, end_send;
int my_rank, commsize;
char *data;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &commsize);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
if ((my_rank == 0) || (my_rank ==1)) {
data = (char *)malloc(sizeof(char) * MESSAGE_SIZE);
start_time = MPI_Wtime();
if (my_rank == 0) {
start_send = MPI_Wtime();
MPI_Bsend(data, MESSAGE_SIZE, MPI_CHAR, IDX1, 0, MPI_COMM_WORLD);
end_send = MPI_Wtime();
sleep(2);
MPI_Recv(data, MESSAGE_SIZE, MPI_CHAR, IDX1, 0, MPI_COMM_WORLD, NULL);
}
else {
MPI_Recv(data, MESSAGE_SIZE, MPI_CHAR, IDX0, 0, MPI_COMM_WORLD, NULL);
start_send = MPI_Wtime();
MPI_Bsend(data, MESSAGE_SIZE, MPI_CHAR, IDX0, 0, MPI_COMM_WORLD);
end_send = MPI_Wtime();
}
end_time = MPI_Wtime();
printf("[%d]Execution time (MPI_Bsend): %f; Send time: %f\n", my_rank, end_time - start_time, end_send - start_send);
free(data);
}
MPI_Finalize();
}

@ -0,0 +1,47 @@
#include <stdio.h>
#include <mpi.h>
#include <stdlib.h>
#include <unistd.h>
// 16 КБайт
#define MESSAGE_SIZE (16*1024)
#define IDX0 0
#define IDX1 1
int main(int argc, char *argv[]) {
double start_time, end_time;
double start_send, end_send;
int my_rank, commsize;
char *data;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &commsize);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
if ((my_rank == 0) || (my_rank ==1)) {
data = (char *)malloc(sizeof(char) * MESSAGE_SIZE);
start_time = MPI_Wtime();
if (my_rank == 0) {
start_send = MPI_Wtime();
MPI_Rsend(data, MESSAGE_SIZE, MPI_CHAR, IDX1, 0, MPI_COMM_WORLD);
end_send = MPI_Wtime();
sleep(2);
MPI_Recv(data, MESSAGE_SIZE, MPI_CHAR, IDX1, 0, MPI_COMM_WORLD, NULL);
}
else {
MPI_Recv(data, MESSAGE_SIZE, MPI_CHAR, IDX0, 0, MPI_COMM_WORLD, NULL);
start_send = MPI_Wtime();
MPI_Rsend(data, MESSAGE_SIZE, MPI_CHAR, IDX0, 0, MPI_COMM_WORLD);
end_send = MPI_Wtime();
}
end_time = MPI_Wtime();
printf("[%d]Execution time (MPI_Rsend): %f; Send time: %f\n", my_rank, end_time - start_time, end_send - start_send);
free(data);
}
MPI_Finalize();
}

@ -0,0 +1,47 @@
#include <stdio.h>
#include <mpi.h>
#include <stdlib.h>
#include <unistd.h>
// 16 КБайт
#define MESSAGE_SIZE (16*1024)
#define IDX0 0
#define IDX1 1
int main(int argc, char *argv[]) {
double start_time, end_time;
double start_send, end_send;
int my_rank, commsize;
char *data;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &commsize);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
if ((my_rank == 0) || (my_rank ==1)) {
data = (char *)malloc(sizeof(char) * MESSAGE_SIZE);
start_time = MPI_Wtime();
if (my_rank == 0) {
start_send = MPI_Wtime();
MPI_Send(data, MESSAGE_SIZE, MPI_CHAR, IDX1, 0, MPI_COMM_WORLD);
end_send = MPI_Wtime();
sleep(2);
MPI_Recv(data, MESSAGE_SIZE, MPI_CHAR, IDX1, 0, MPI_COMM_WORLD, NULL);
}
else {
MPI_Recv(data, MESSAGE_SIZE, MPI_CHAR, IDX0, 0, MPI_COMM_WORLD, NULL);
start_send = MPI_Wtime();
MPI_Send(data, MESSAGE_SIZE, MPI_CHAR, IDX0, 0, MPI_COMM_WORLD);
end_send = MPI_Wtime();
}
end_time = MPI_Wtime();
printf("[%d]Execution time (MPI_Send): %f; Send time: %f\n", my_rank, end_time - start_time, end_send - start_send);
free(data);
}
MPI_Finalize();
}

@ -0,0 +1,47 @@
#include <stdio.h>
#include <mpi.h>
#include <stdlib.h>
#include <unistd.h>
// 16 КБайт
#define MESSAGE_SIZE (16*1024)
#define IDX0 0
#define IDX1 1
int main(int argc, char *argv[]) {
double start_time, end_time;
double start_send, end_send;
int my_rank, commsize;
char *data;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &commsize);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
if ((my_rank == 0) || (my_rank ==1)) {
data = (char *)malloc(sizeof(char) * MESSAGE_SIZE);
start_time = MPI_Wtime();
if (my_rank == 0) {
start_send = MPI_Wtime();
MPI_Ssend(data, MESSAGE_SIZE, MPI_CHAR, IDX1, 0, MPI_COMM_WORLD);
end_send = MPI_Wtime();
sleep(2);
MPI_Recv(data, MESSAGE_SIZE, MPI_CHAR, IDX1, 0, MPI_COMM_WORLD, NULL);
}
else {
MPI_Recv(data, MESSAGE_SIZE, MPI_CHAR, IDX0, 0, MPI_COMM_WORLD, NULL);
start_send = MPI_Wtime();
MPI_Ssend(data, MESSAGE_SIZE, MPI_CHAR, IDX0, 0, MPI_COMM_WORLD);
end_send = MPI_Wtime();
}
end_time = MPI_Wtime();
printf("[%d]Execution time (MPI_Ssend): %f; Send time: %f\n", my_rank, end_time - start_time, end_send - start_send);
free(data);
}
MPI_Finalize();
}

@ -0,0 +1,11 @@
[0]Execution time (MPI_Send): 2.001213; Send time: 0.000341
[1]Execution time (MPI_Send): 2.001231; Send time: 2.000874
[0]Execution time (MPI_Ssend): 2.022626; Send time: 0.000384
[1]Execution time (MPI_Ssend): 2.022571; Send time: 2.022247
[0]Execution time (MPI_Rsend): 2.018200; Send time: 0.000382
[1]Execution time (MPI_Rsend): 2.018145; Send time: 2.017824
[0]Execution time (MPI_Bsend): 2.000843; Send time: 0.000123
[1]Execution time (MPI_Bsend): 0.000254; Send time: 0.000105
Loading…
Cancel
Save