Skip to content
Snippets Groups Projects
Commit 1e2fa05c authored by Terence Chateigne's avatar Terence Chateigne
Browse files

cachetime

parent 49af9571
No related branches found
No related tags found
No related merge requests found
......@@ -17,23 +17,30 @@ int main(int argc, const char **argv)
array[i * 4096] = 1;
// Vider le tableau du cache
for (i = 0; i < 10; i++) {
for (i = 0; i < 10; i++)
{
// TODO Vidage d'une ligne de cache
_mm_clflush(&array[i * 4096]);
}
// TODO Accéder à quelques éléments de array
for (i = 5; i < 10; i++)
{
addr = &array[i * 4096];
junk = *addr;
}
// Mesurer les temps d'accès
for (i = 0; i < 10; i++)
{
addr = &array[i * 4096];
// TODO prendre le timestamp CPU avant lecture
// TODO prendre le timestamp CPU avant lecture
time1 = __rdtsc();
junk = *addr;
// TODO calculer le temps écoulé dans time2
time2 = __rdtsc() - time1;
printf("Temps d'accès à array[%d * 4096]: %ld cycles CPU.\n", i, time2);
}
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment