summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-05-25 14:40:38 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-07-08 14:03:28 +0100
commitf40d54e132f84efa28b29723f90537e4731c6c92 (patch)
tree260c40a16910f9743ef2d57d512fa4df885ff565
parent4227da8c3cc6417c9d9600bddac938759f01ae03 (diff)
gem_gtt_speed: Add option for variable buffer size
-rw-r--r--tests/gem_gtt_speed.c67
1 files changed, 38 insertions, 29 deletions
diff --git a/tests/gem_gtt_speed.c b/tests/gem_gtt_speed.c
index af9f9478..1e63b781 100644
--- a/tests/gem_gtt_speed.c
+++ b/tests/gem_gtt_speed.c
@@ -130,14 +130,23 @@ static double elapsed(const struct timeval *start,
int main(int argc, char **argv)
{
struct timeval start, end;
- uint8_t buf[OBJECT_SIZE];
+ uint8_t *buf;
uint32_t handle;
+ int size = OBJECT_SIZE;
int loop, i, tiling;
int fd;
+ if (argc > 1)
+ size = atoi(argv[1]);
+ if (size == 0) {
+ fprintf(stderr, "Invalid object size specified\n");
+ return 1;
+ }
+
+ buf = malloc(size);
fd = drm_open_any();
- handle = gem_create(fd, OBJECT_SIZE);
+ handle = gem_create(fd, size);
assert(handle);
for (tiling = I915_TILING_NONE; tiling <= I915_TILING_Y; tiling++) {
@@ -151,80 +160,80 @@ int main(int argc, char **argv)
/* CPU pwrite */
gettimeofday(&start, NULL);
for (loop = 0; loop < 1000; loop++)
- gem_write(fd, handle, 0, buf, sizeof(buf));
+ gem_write(fd, handle, 0, buf, size);
gettimeofday(&end, NULL);
- printf("Time to pwrite 16k through the CPU: %7.3fµs\n",
- elapsed(&start, &end, loop));
+ printf("Time to pwrite %dk through the CPU: %7.3fµs\n",
+ size/1024, elapsed(&start, &end, loop));
/* CPU pread */
gettimeofday(&start, NULL);
for (loop = 0; loop < 1000; loop++)
- gem_read(fd, handle, 0, buf, sizeof(buf));
+ gem_read(fd, handle, 0, buf, size);
gettimeofday(&end, NULL);
- printf("Time to pread 16k through the CPU: %7.3fµs\n",
- elapsed(&start, &end, loop));
+ printf("Time to pread %dk through the CPU: %7.3fµs\n",
+ size/1024, elapsed(&start, &end, loop));
}
/* mmap read */
gettimeofday(&start, NULL);
for (loop = 0; loop < 1000; loop++) {
- volatile uint32_t *ptr = gem_mmap(fd, handle, OBJECT_SIZE, PROT_READ);
+ volatile uint32_t *ptr = gem_mmap(fd, handle, size, PROT_READ);
int x = 0;
- for (i = 0; i < OBJECT_SIZE/sizeof(*ptr); i++)
+ for (i = 0; i < size/sizeof(*ptr); i++)
x += ptr[i];
- munmap((void *)ptr, OBJECT_SIZE);
+ munmap((void *)ptr, size);
}
gettimeofday(&end, NULL);
- printf("Time to read 16k through a GTT map: %7.3fµs\n",
- elapsed(&start, &end, loop));
+ printf("Time to read %dk through a GTT map: %7.3fµs\n",
+ size/1024, elapsed(&start, &end, loop));
/* mmap write */
gettimeofday(&start, NULL);
for (loop = 0; loop < 1000; loop++) {
- volatile uint32_t *ptr = gem_mmap(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+ volatile uint32_t *ptr = gem_mmap(fd, handle, size, PROT_READ | PROT_WRITE);
- for (i = 0; i < OBJECT_SIZE/sizeof(*ptr); i++)
+ for (i = 0; i < size/sizeof(*ptr); i++)
ptr[i] = i;
- munmap((void *)ptr, OBJECT_SIZE);
+ munmap((void *)ptr, size);
}
gettimeofday(&end, NULL);
- printf("Time to write 16k through a GTT map: %7.3fµs\n",
- elapsed(&start, &end, loop));
+ printf("Time to write %dk through a GTT map: %7.3fµs\n",
+ size/1024, elapsed(&start, &end, loop));
/* mmap read */
gettimeofday(&start, NULL);
for (loop = 0; loop < 1000; loop++) {
- volatile uint32_t *ptr = gem_mmap(fd, handle, OBJECT_SIZE, PROT_READ);
+ volatile uint32_t *ptr = gem_mmap(fd, handle, size, PROT_READ);
int x = 0;
- for (i = 0; i < OBJECT_SIZE/sizeof(*ptr); i++)
+ for (i = 0; i < size/sizeof(*ptr); i++)
x += ptr[i];
- munmap((void *)ptr, OBJECT_SIZE);
+ munmap((void *)ptr, size);
}
gettimeofday(&end, NULL);
- printf("Time to read 16k (again) through a GTT map: %7.3fµs\n",
- elapsed(&start, &end, loop));
+ printf("Time to read %dk (again) through a GTT map: %7.3fµs\n",
+ size/1024, elapsed(&start, &end, loop));
if (tiling == I915_TILING_NONE) {
/* GTT pwrite */
gettimeofday(&start, NULL);
for (loop = 0; loop < 1000; loop++)
- gem_write(fd, handle, 0, buf, sizeof(buf));
+ gem_write(fd, handle, 0, buf, size);
gettimeofday(&end, NULL);
- printf("Time to pwrite 16k through the GTT: %7.3fµs\n",
- elapsed(&start, &end, loop));
+ printf("Time to pwrite %dk through the GTT: %7.3fµs\n",
+ size, elapsed(&start, &end, loop));
/* GTT pread */
gettimeofday(&start, NULL);
for (loop = 0; loop < 1000; loop++)
- gem_read(fd, handle, 0, buf, sizeof(buf));
+ gem_read(fd, handle, 0, buf, size);
gettimeofday(&end, NULL);
- printf("Time to pread 16k through the GTT: %7.3fµs\n",
- elapsed(&start, &end, loop));
+ printf("Time to pread %dk through the GTT: %7.3fµs\n",
+ size, elapsed(&start, &end, loop));
}
}