diff --git a/src/change.c b/src/change.c deleted file mode 100644 index d77c2d9283c56dc119f69151069ebd4b04f0fe93..0000000000000000000000000000000000000000 --- a/src/change.c +++ /dev/null @@ -1,9 +0,0 @@ -#include <stdio.h> -int main() { - const int x = 10; //define constant int - int *ptr; - printf("x = %d\n", x); - ptr = &x; //ptr points the variable x - *ptr = 15; //Updating through pointer - printf("x = %d\n", x); -} \ No newline at end of file diff --git a/src/par b/src/par index ffe23201b382ad85b854f2b410f170a9d593b6e4..8bf4ea24047dd88c1e67dfcc6830ff4f8b2f82c4 100644 Binary files a/src/par and b/src/par differ diff --git a/src/parallel.c b/src/parallel.c index 4ae1b646b441709643aa91fd5eb71a7eed9de6d2..ebf45623419aa2dcef6a04ae234c9d45ce7ac9fb 100644 --- a/src/parallel.c +++ b/src/parallel.c @@ -292,6 +292,7 @@ int main() { // reads kernel's row and column and initalize kernel matrix from input scanf("%d %d", &kernel_row, &kernel_col); + // Matrix* kernel = (Matrix*)malloc(num_targets * sizeof(Matrix)); Matrix kernel = input_matrix(kernel_row, kernel_col); // reads number of target matrices and their dimensions. @@ -357,38 +358,9 @@ int main() { */ - - - int root = 0; - if (world_rank == root) { - // If we are the root process, send our data to every process - int i; - for (i = 0; i < world_size; i++) { - if (i != world_rank) { - MPI_Send(&arr_mat[counter_distribute], 1, mat_MPI, i, 0, MPI_COMM_WORLD); - counter_distribute++; - } - } - print_matrix(&kernel); - printf("PRocess 0 distribute\n "); - - } else { - printf("PRocess selain 0 distribute %d \n", world_rank); - // If we are a receiver process, receive the data from the root - Matrix recv_data; - MPI_Recv(&recv_data, 1, mat_MPI, root, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - print_matrix(&recv_data); - - printf("HASILLL\n"); - arr_mat2[counter_receiver] = convolution(&m, &recv_data); - - print_matrix(&arr_mat2[counter_receiver]); - arr_range[counter_receiver] = get_matrix_datarange(&arr_mat2[counter_receiver]); - counter_receiver++; - } while (counter_distribute < PING_PONG_LIMIT){ // distribute(arr_mat[counter_distribute],1,mat_MPI,0, MPI_COMM_WORLD) @@ -398,31 +370,23 @@ int main() { int i; for (i = 0; i < world_size; i++) { if (i != world_rank) { - MPI_Send(&arr_mat[counter_distribute], 1, mat_MPI, i, 0, MPI_COMM_WORLD); + MPI_Send(&arr_mat[counter_distribute], 1, mat_MPI, i, 1, MPI_COMM_WORLD); + MPI_Send(&kernel, 1, mat_MPI, i, 0, MPI_COMM_WORLD); counter_distribute++; } } - print_matrix(&kernel); - printf("PRocess 0 distribute\n "); } else { - printf("PRocess selain 0 distribute %d \n", world_rank); // If we are a receiver process, receive the data from the root Matrix recv_data; - MPI_Recv(&recv_data, 1, mat_MPI, root, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Recv(&recv_data, 1, mat_MPI, root, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + Matrix kernel_recv; + MPI_Recv(&kernel_recv, 1, mat_MPI, root, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); print_matrix(&recv_data); - Matrix m; - m.row_eff = 2; - m.col_eff = 2; - - m.mat[0][0] = 1; - m.mat[0][1] = 0; - m.mat[1][0] = 0; - m.mat[1][1] = -1; - print_matrix(&m); + print_matrix(&kernel_recv); printf("HASILLL\n"); - arr_mat2[counter_receiver] = convolution(&m, &recv_data); + arr_mat2[counter_receiver] = convolution(&kernel_recv, &recv_data); print_matrix(&arr_mat2[counter_receiver]); arr_range[counter_receiver] = get_matrix_datarange(&arr_mat2[counter_receiver]);