add SCR Part
This commit is contained in:
16
SCR/SCR3.1/TP01/Exercise3/answer.txt
Normal file
16
SCR/SCR3.1/TP01/Exercise3/answer.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
- Version 1 -
|
||||
time = 0.149877
|
||||
[baudrier@salle224-14 Exercise3]$ size a.out
|
||||
text data bss dec hex filename
|
||||
1136 512 40032 41680 a2d0 a.out
|
||||
|
||||
- Version 2 -
|
||||
time = 1.313450
|
||||
[baudrier@salle224-14 Exercise3]$ size a.out
|
||||
text data bss dec hex filename
|
||||
1136 40528 8 41672 a2c8 a.out
|
||||
|
||||
-> La version 2 est donc plus longue car dans la deuxième version on doit charger à chaque fois une nouvelle colonne du tableau à chaque itération.
|
||||
-> Alors que dans la version 1, on parcours chaque colonne et chaque éléments de la colonne ensuite.
|
||||
-> Donc dans cette première version le tableau t est dans le segment bss (car il n'est pas initialisé).
|
||||
-> Et dans la deuxième version il est dans le segment data car il est initialisé.
|
26
SCR/SCR3.1/TP01/Exercise3/prog.c
Normal file
26
SCR/SCR3.1/TP01/Exercise3/prog.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* accès mémoire */
|
||||
#include<stdio.h>
|
||||
#include<time.h>
|
||||
#include <stdlib.h>
|
||||
#define N 8192
|
||||
|
||||
int t[N][N];
|
||||
|
||||
static inline double tstamp(void)
|
||||
{
|
||||
struct timespec tv;
|
||||
clock_gettime(CLOCK_REALTIME, &tv);
|
||||
return tv.tv_sec + tv.tv_nsec * 1.0e-9;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int i,j;
|
||||
double t1,t2;
|
||||
t1=tstamp();
|
||||
/* version 1 */ for(i=0;i<N;i++) for(j=0;j<N;j++) t[i][j] = 1;
|
||||
/* version 2 */ // for(i=0;i<N;i++) for(j=0;j<N;j++) t[j][i] = 1;
|
||||
t2=tstamp();
|
||||
printf("time = %lf\n",t2-t1);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user