Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
18BCE2182 ASSESS_1 Q2-1
#include <stdio.h> #include <stdlib.h> #include <omp.h> #define M 5 #define N 5 int main(int argc, char *argv) { int i,j; double t; double start, end, start_p, end_p; double **A; A= malloc(M*sizeof(double *)); for(i=0; i<M; i++) { A[i]= malloc(N*sizeof(double)); } for(i=0; i<M; i++) { for(j=0; j<N; j++) { A[i][j]=j*1; } } printf("MATRIX A:\n"); for(i=0; i<M; i++) { for(j=0; j<N; j++) { printf("%f ",A[i][j]); } printf("\n"); } printf("\n"); start= omp_get_wtime(); for(i=0; i<M; i++) { for(j=0; j<N; j++) { t=A[i][j]; A[i][j]=A[j][i]; A[j][i]=t; } } end= omp_get_wtime(); printf("Serial Execution Time: %f\n\n",(end-start)); ////////////////////////////////// start_p= omp_get_wtime(); #pragma omp parallel for for(i=0; i<M; i++) { for(j=0; j<N; j++) { t=A[i][j]; A[i][j]=A[j][i]; A[j][i]=t; } } end_p= omp_get_wtime(); printf("Parallel Execution Time: %f\n\n",(end_p-start_p)); printf("MATRIX TRANSPOSE, MATRIX A:\n"); for(i=0; i<M; i++) { for(j=0; j<N; j++) { printf("%f ",A[i][j]); } printf("\n"); } return 0; }
run
|
edit
|
history
|
help
0
StructSurvey
Coba
Assignment 3
Project 5 v.06
Project 3 Part 1 v1.7
BSEARCH() COMPLETE
PREGUNTA 3 - MODULO 4 TERMINADA
sum of arrays
150116_PrimoFactorial
Max successs