summaryrefslogtreecommitdiff
path: root/tests/gem_gtt_speed.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2011-11-30 12:36:29 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2011-12-01 21:42:23 +0100
commit2e88c4ce34c0403df2301863efae4bf0a8699acb (patch)
treeb0968e668f99b6a13f8091b49d53c66e6c5c157e /tests/gem_gtt_speed.c
parent4591d4ba7fe224289faa2b3b37052106d476a04f (diff)
tests/gem_gtt_speed: Add modes that force that to the gtt domain
No sane userspace doesn't upload data to the gpu without actually using it there ... Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/gem_gtt_speed.c')
-rw-r--r--tests/gem_gtt_speed.c70
1 files changed, 68 insertions, 2 deletions
diff --git a/tests/gem_gtt_speed.c b/tests/gem_gtt_speed.c
index 1e63b781..1a159a9a 100644
--- a/tests/gem_gtt_speed.c
+++ b/tests/gem_gtt_speed.c
@@ -127,6 +127,17 @@ static double elapsed(const struct timeval *start,
return (1e6*(end->tv_sec - start->tv_sec) + (end->tv_usec - start->tv_usec))/loop;
}
+static void gem_sync(int fd, uint32_t handle)
+{
+ struct drm_i915_gem_set_domain set_domain;
+
+ set_domain.handle = handle;
+ set_domain.read_domains = I915_GEM_DOMAIN_GTT;
+ set_domain.write_domain = I915_GEM_DOMAIN_GTT;
+
+ drmIoctl(fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain);
+}
+
int main(int argc, char **argv)
{
struct timeval start, end;
@@ -144,6 +155,7 @@ int main(int argc, char **argv)
}
buf = malloc(size);
+ memset(buf, 0, size);
fd = drm_open_any();
handle = gem_create(fd, size);
@@ -174,6 +186,16 @@ int main(int argc, char **argv)
size/1024, elapsed(&start, &end, loop));
}
+ /* prefault into gtt */
+ {
+ volatile uint32_t *ptr = gem_mmap(fd, handle, size, PROT_READ);
+ int x = 0;
+
+ for (i = 0; i < size/sizeof(*ptr); i++)
+ x += ptr[i];
+
+ munmap((void *)ptr, size);
+ }
/* mmap read */
gettimeofday(&start, NULL);
for (loop = 0; loop < 1000; loop++) {
@@ -225,7 +247,7 @@ int main(int argc, char **argv)
gem_write(fd, handle, 0, buf, size);
gettimeofday(&end, NULL);
printf("Time to pwrite %dk through the GTT: %7.3fµs\n",
- size, elapsed(&start, &end, loop));
+ size/1024, elapsed(&start, &end, loop));
/* GTT pread */
gettimeofday(&start, NULL);
@@ -233,7 +255,51 @@ int main(int argc, char **argv)
gem_read(fd, handle, 0, buf, size);
gettimeofday(&end, NULL);
printf("Time to pread %dk through the GTT: %7.3fµs\n",
- size, elapsed(&start, &end, loop));
+ size/1024, elapsed(&start, &end, loop));
+
+ /* GTT pwrite, including clflush */
+ gettimeofday(&start, NULL);
+ for (loop = 0; loop < 1000; loop++) {
+ gem_write(fd, handle, 0, buf, size);
+ gem_sync(fd, handle);
+ }
+ gettimeofday(&end, NULL);
+ printf("Time to pwrite %dk through the GTT (clflush): %7.3fµs\n",
+ size/1024, elapsed(&start, &end, loop));
+
+ /* GTT pread, including clflush */
+ gettimeofday(&start, NULL);
+ for (loop = 0; loop < 1000; loop++) {
+ gem_sync(fd, handle);
+ gem_read(fd, handle, 0, buf, size);
+ }
+ gettimeofday(&end, NULL);
+ printf("Time to pread %dk through the GTT (clflush): %7.3fµs\n",
+ size/1024, elapsed(&start, &end, loop));
+
+ /* partial writes */
+ printf("Now partial writes.\n");
+ size /= 4;
+
+ /* partial GTT pwrite, including clflush */
+ gettimeofday(&start, NULL);
+ for (loop = 0; loop < 1000; loop++) {
+ gem_write(fd, handle, 0, buf, size);
+ gem_sync(fd, handle);
+ }
+ gettimeofday(&end, NULL);
+ printf("Time to pwrite %dk through the GTT (clflush): %7.3fµs\n",
+ size/1024, elapsed(&start, &end, loop));
+
+ /* partial GTT pread, including clflush */
+ gettimeofday(&start, NULL);
+ for (loop = 0; loop < 1000; loop++) {
+ gem_sync(fd, handle);
+ gem_read(fd, handle, 0, buf, size);
+ }
+ gettimeofday(&end, NULL);
+ printf("Time to pread %dk through the GTT (clflush): %7.3fµs\n",
+ size/1024, elapsed(&start, &end, loop));
}
}