mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 17:36:11 +00:00
tests/gtt_speed: try to outwit gcc
It optimized away the read loops ;-) Also fix up the size to not be 1/4th of the one we want for tiled buffer tests. Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
78c38dcddb
commit
544e357851
@ -102,23 +102,29 @@ int main(int argc, char **argv)
|
||||
|
||||
/* prefault into gtt */
|
||||
{
|
||||
uint32_t *ptr = gem_mmap(fd, handle, size, PROT_READ);
|
||||
uint32_t *ptr = gem_mmap(fd, handle, size, PROT_READ | PROT_WRITE);
|
||||
int x = 0;
|
||||
|
||||
for (i = 0; i < size/sizeof(*ptr); i++)
|
||||
x += ptr[i];
|
||||
|
||||
/* force overtly clever gcc to actually compute x */
|
||||
ptr[0] = x;
|
||||
|
||||
munmap(ptr, size);
|
||||
}
|
||||
/* mmap read */
|
||||
gettimeofday(&start, NULL);
|
||||
for (loop = 0; loop < 1000; loop++) {
|
||||
uint32_t *ptr = gem_mmap(fd, handle, size, PROT_READ);
|
||||
uint32_t *ptr = gem_mmap(fd, handle, size, PROT_READ | PROT_WRITE);
|
||||
int x = 0;
|
||||
|
||||
for (i = 0; i < size/sizeof(*ptr); i++)
|
||||
x += ptr[i];
|
||||
|
||||
/* force overtly clever gcc to actually compute x */
|
||||
ptr[0] = x;
|
||||
|
||||
munmap(ptr, size);
|
||||
}
|
||||
gettimeofday(&end, NULL);
|
||||
@ -142,12 +148,15 @@ int main(int argc, char **argv)
|
||||
/* mmap read */
|
||||
gettimeofday(&start, NULL);
|
||||
for (loop = 0; loop < 1000; loop++) {
|
||||
uint32_t *ptr = gem_mmap(fd, handle, size, PROT_READ);
|
||||
uint32_t *ptr = gem_mmap(fd, handle, size, PROT_READ | PROT_WRITE);
|
||||
int x = 0;
|
||||
|
||||
for (i = 0; i < size/sizeof(*ptr); i++)
|
||||
x += ptr[i];
|
||||
|
||||
/* force overtly clever gcc to actually compute x */
|
||||
ptr[0] = x;
|
||||
|
||||
munmap(ptr, size);
|
||||
}
|
||||
gettimeofday(&end, NULL);
|
||||
@ -214,6 +223,8 @@ int main(int argc, char **argv)
|
||||
gettimeofday(&end, NULL);
|
||||
printf("Time to pread %dk through the GTT (clflush): %7.3fµs\n",
|
||||
size/1024, elapsed(&start, &end, loop));
|
||||
|
||||
size *= 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user