Skip to content
Snippets Groups Projects
Commit 17ba2c02 authored by Chinthak Murali's avatar Chinthak Murali
Browse files

Update MPI Programming and Benchmarking

parent ccb1f945
No related merge requests found
......@@ -327,10 +327,16 @@ int main(int argc, char** argv) {
// Gather encrypted data from all processes
MPI_Gather(local_encrypted, chunk_size, MPI_BYTE, encrypted, chunk_size, MPI_BYTE, 0, MPI_COMM_WORLD);
// Scatter encrypted data to all processes for decryption
MPI_Scatter(encrypted, chunk_size, MPI_BYTE, local_encrypted, chunk_size, MPI_BYTE, 0, MPI_COMM_WORLD);
start = MPI_Wtime();
blowfish_decrypt(&key, encrypted, DATA_SIZE, decrypted);
blowfish_decrypt(&key, local_encrypted, chunk_size, local_decrypted);
end = MPI_Wtime();
printf("Decryption time (parallel): %f seconds\n", end - start);
printf("Process %d decryption time: %f seconds\n", rank, end - start);
// Gather decrypted data from all processes
MPI_Gather(local_decrypted, chunk_size, MPI_BYTE, decrypted, chunk_size, MPI_BYTE, 0, MPI_COMM_WORLD);
// Validate the decrypted data
if (memcmp(data, decrypted, DATA_SIZE) != 0) {
......@@ -353,8 +359,19 @@ int main(int argc, char** argv) {
end = MPI_Wtime();
printf("Process %d encryption time: %f seconds\n", rank, end - start);
// Send encrypted data chunk to root process
// Gather encrypted data chunk to root process
MPI_Gather(local_encrypted, chunk_size, MPI_BYTE, NULL, chunk_size, MPI_BYTE, 0, MPI_COMM_WORLD);
// Scatter encrypted data to all processes for decryption
MPI_Scatter(NULL, chunk_size, MPI_BYTE, local_encrypted, chunk_size, MPI_BYTE, 0, MPI_COMM_WORLD);
start = MPI_Wtime();
blowfish_decrypt(&key, local_encrypted, chunk_size, local_decrypted);
end = MPI_Wtime();
printf("Process %d decryption time: %f seconds\n", rank, end - start);
// Gather decrypted data chunk to root process
MPI_Gather(local_decrypted, chunk_size, MPI_BYTE, NULL, chunk_size, MPI_BYTE, 0, MPI_COMM_WORLD);
}
free(local_data);
......@@ -369,6 +386,7 @@ int main(int argc, char** argv) {
mpicc blowfish_mpi.c -o blowfish_mpi -lcrypto
mpirun -np 4 ./blowfish_mpi
......@@ -403,55 +421,73 @@ Decrypted data matches original data!
-N 2
-p 128GB
Process 1 encryption time: 0.476727 seconds
Process 0 encryption time: 0.476585 seconds
Decryption time (parallel): 0.954134 seconds
Process 1 encryption time: 0.476605 seconds
Process 0 encryption time: 0.476566 seconds
Process 1 decryption time: 0.476421 seconds
Process 0 decryption time: 0.476719 seconds
Decrypted data matches original data!
-N 3
-p 128GB
Process 1 encryption time: 0.326551 seconds
Process 2 encryption time: 0.323678 seconds
Process 0 encryption time: 0.323797 seconds
Decryption time (parallel): 0.970143 seconds
Process 1 encryption time: 0.321120 seconds
Process 2 encryption time: 0.322333 seconds
Process 0 encryption time: 0.318449 seconds
Process 2 decryption time: 0.317735 seconds
Process 1 decryption time: 0.321197 seconds
Process 0 decryption time: 0.318884 seconds
-N 4
-p 128GB
Process 1 encryption time: 0.243206 seconds
Process 3 encryption time: 0.243105 seconds
Process 0 encryption time: 0.240108 seconds
Process 2 encryption time: 0.240205 seconds
Decryption time (parallel): 0.961980 seconds
Decrypted data matches original data!
Process 3 encryption time: 0.238996 seconds
Process 1 encryption time: 0.241968 seconds
Process 0 encryption time: 0.242709 seconds
Process 2 encryption time: 0.242700 seconds
Process 3 decryption time: 0.240068 seconds
Process 1 decryption time: 0.240390 seconds
Process 0 decryption time: 0.241649 seconds
Process 2 decryption time: 0.241826 seconds
-N 5
-p 128GB
Process 3 encryption time: 0.193014 seconds
Process 4 encryption time: 0.207064 seconds
Process 0 encryption time: 0.196599 seconds
Process 2 encryption time: 0.196809 seconds
Process 1 encryption time: 0.205737 seconds
Decryption time (parallel): 0.983177 seconds
Process 0 encryption time: 0.192699 seconds
Process 1 encryption time: 0.195781 seconds
Process 2 encryption time: 0.196270 seconds
Process 3 encryption time: 0.195687 seconds
Process 4 encryption time: 0.192910 seconds
Process 4 decryption time: 0.195979 seconds
Process 1 decryption time: 0.196943 seconds
Process 3 decryption time: 0.196658 seconds
Process 0 decryption time: 0.196703 seconds
Process 2 decryption time: 0.196011 seconds
Decrypted data matches original data!
-N 6
-p 128GB
Process 5 encryption time: 0.164433 seconds
Process 4 encryption time: 0.163639 seconds
Process 1 encryption time: 0.161994 seconds
Process 3 encryption time: 0.163783 seconds
Process 2 encryption time: 0.162038 seconds
Process 0 encryption time: 0.163603 seconds
Decryption time (parallel): 1.002695 seconds
Process 5 encryption time: 0.162260 seconds
Process 4 encryption time: 0.165288 seconds
Process 1 encryption time: 0.164572 seconds
Process 3 encryption time: 0.164788 seconds
Process 2 encryption time: 0.162729 seconds
Process 0 encryption time: 0.164458 seconds
Process 5 decryption time: 0.164114 seconds
Process 4 decryption time: 0.163690 seconds
Process 1 decryption time: 0.163860 seconds
Process 3 decryption time: 0.164126 seconds
Process 0 decryption time: 0.163264 seconds
Process 2 decryption time: 0.163493 seconds
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment