Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
18BCE2182 LAB FAT-2-A-i
//gcc 7.4.0 #include <stdio.h> #include <stdlib.h> #include <omp.h> #include <time.h> #define M 5 #define N 5 int main(int argc, char* argv[]) { int i, j; double t, start, end; double **A, **B, **C; A = malloc(M*sizeof(double *)); B = malloc(M*sizeof(double *)); C = malloc(M*sizeof(double *)); for(i = 0; i < M; i++) { A[i]=malloc(N*sizeof(double *)); B[i]=malloc(N*sizeof(double *)); C[i]=malloc(N*sizeof(double *)); } for(i = 0; i < M; i++) { for(j = 0; j < N; j++) { A[i][j]=rand(); B[i][j]=rand(); } } //ADDITION IN STATIC SCHEDULING start = omp_get_wtime(); #pragma omp parallel for schedule(static,16) for(i=0;i<M;i++) { for(j=0;j<N;j++) { C[i][j] = A[i][j]+B[i][j]; } } end = omp_get_wtime(); printf("\n\nExecution Time in Static is: %f\n\n",(end-start)); //ADDITION IN DYNAMIC SCHEDULING start = omp_get_wtime(); #pragma omp parallel for schedule(dynamic,16) for(i=0; i<M; i++) { for(j=0; j<N; j++) { C[i][j]=A[i][j]+B[i][j]; } } end = omp_get_wtime(); printf("\n\nExecution Time in Dynamic is: %f\n\n",(end-start)); //ADDITION IN GUIDED SCHEDULING start = omp_get_wtime(); #pragma omp parallel for schedule(guided,16) for(i=0; i<M; i++) { for(j=0; j<N; j++) { C[i][j]=A[i][j]+B[i][j]; } } end = omp_get_wtime(); printf("\n\nExecution Time in Guided is: %f\n\n",(end-start)); return 0; }
run
|
edit
|
history
|
help
0
Stack frame enum test
Eee
implicit parameter type
domain.com
2-D array
selection sort
ytre
A_141201_MatrizTodosDistintos
Lp
switch_nota