Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
2.1 Comparision of Matrix Transpose Execution Time
//gcc 7.4.0 #include <stdio.h> #include <omp.h> #include <stdlib.h> #include <time.h> #include <math.h> int main(void) { int r=9000; int c=9000; int *arr[r]; for(int i=0;i<r;i++){ arr[i]=(int *)malloc(c*sizeof(int)); } for(int i=0;i<r;i++){ for(int j=0;j<c;j++){ arr[i][j]=rand(); } } printf("\nSequential Time: \n"); int *arr1[r]; for(int i=0;i<r;i++){ arr1[i]=(int *)malloc(c*sizeof(int)); } double start=omp_get_wtime(); for(int i=0;i<r;i++){ for(int j=0;j<c;j++){ arr1[i][j]=arr[j][i]; } } double end=omp_get_wtime(); printf("Execution Time : %f\n",end-start); printf("\nParallel Time: \n"); int *arr2[r]; for(int i=0;i<r;i++){ arr2[i]=(int *)malloc(c*sizeof(int)); } double start1=omp_get_wtime(); int i=0; int j=0; #pragma omp parallel for private(j) for(i=0;i<r;i++){ for(j=0;j<c;j++){ arr2[i][j]=arr[j][i]; } } double end1=omp_get_wtime(); printf("Execution Time : %f\n",end1-start1); for(int i=0;i<r;i++){ free(arr[i]); } return 0; }
run
|
edit
|
history
|
help
0
150109_RecursividadParImpar
mypro
Ppp
finding 3 ones in a row
PJE
MATRIZ DE CADENAS
The endless numbers.
tarea1
pointer**
Spring 2017 Project 2 v.02