Skip to content
Snippets Groups Projects
Commit e66fe356 authored by mfikrin's avatar mfikrin
Browse files

fix : kernel matrix missing data

parent f24b3cff
Branches
No related merge requests found
#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
No preview for this file type
...@@ -292,6 +292,7 @@ int main() { ...@@ -292,6 +292,7 @@ int main() {
// reads kernel's row and column and initalize kernel matrix from input // reads kernel's row and column and initalize kernel matrix from input
scanf("%d %d", &kernel_row, &kernel_col); scanf("%d %d", &kernel_row, &kernel_col);
// Matrix* kernel = (Matrix*)malloc(num_targets * sizeof(Matrix));
Matrix kernel = input_matrix(kernel_row, kernel_col); Matrix kernel = input_matrix(kernel_row, kernel_col);
// reads number of target matrices and their dimensions. // reads number of target matrices and their dimensions.
...@@ -357,38 +358,9 @@ int main() { ...@@ -357,38 +358,9 @@ int main() {
*/ */
int root = 0; 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){ while (counter_distribute < PING_PONG_LIMIT){
// distribute(arr_mat[counter_distribute],1,mat_MPI,0, MPI_COMM_WORLD) // distribute(arr_mat[counter_distribute],1,mat_MPI,0, MPI_COMM_WORLD)
...@@ -398,31 +370,23 @@ int main() { ...@@ -398,31 +370,23 @@ int main() {
int i; int i;
for (i = 0; i < world_size; i++) { for (i = 0; i < world_size; i++) {
if (i != world_rank) { 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++; counter_distribute++;
} }
} }
print_matrix(&kernel);
printf("PRocess 0 distribute\n ");
} else { } else {
printf("PRocess selain 0 distribute %d \n", world_rank);
// If we are a receiver process, receive the data from the root // If we are a receiver process, receive the data from the root
Matrix recv_data; 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); print_matrix(&recv_data);
Matrix m; print_matrix(&kernel_recv);
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);
printf("HASILLL\n"); 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]); print_matrix(&arr_mat2[counter_receiver]);
arr_range[counter_receiver] = get_matrix_datarange(&arr_mat2[counter_receiver]); arr_range[counter_receiver] = get_matrix_datarange(&arr_mat2[counter_receiver]);
......
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