Expand gem_set_cacheing testing to handle the proposed DISPLAY domain

This commit is contained in:
Chris Wilson 2013-08-10 15:49:33 +01:00
parent dbbf2e9b24
commit 467796acc8
7 changed files with 173 additions and 90 deletions

View File

@ -408,7 +408,7 @@ int gem_has_cacheing(int fd)
return ret == 0; return ret == 0;
} }
void gem_set_cacheing(int fd, uint32_t handle, int cacheing) int gem_set_cacheing(int fd, uint32_t handle, int cacheing)
{ {
struct local_drm_i915_gem_cacheing arg; struct local_drm_i915_gem_cacheing arg;
int ret; int ret;
@ -416,7 +416,7 @@ void gem_set_cacheing(int fd, uint32_t handle, int cacheing)
arg.handle = handle; arg.handle = handle;
arg.cacheing = cacheing; arg.cacheing = cacheing;
ret = ioctl(fd, LOCAL_DRM_IOCTL_I915_GEM_SET_CACHEING, &arg); ret = ioctl(fd, LOCAL_DRM_IOCTL_I915_GEM_SET_CACHEING, &arg);
assert(ret == 0); return ret == 0 ? 0 : -errno;
} }
int gem_get_cacheing(int fd, uint32_t handle) int gem_get_cacheing(int fd, uint32_t handle)

View File

@ -54,7 +54,7 @@ bool gem_has_blt(int fd);
bool gem_has_vebox(int fd); bool gem_has_vebox(int fd);
int gem_get_num_rings(int fd); int gem_get_num_rings(int fd);
int gem_has_cacheing(int fd); int gem_has_cacheing(int fd);
void gem_set_cacheing(int fd, uint32_t handle, int cacheing); int gem_set_cacheing(int fd, uint32_t handle, int cacheing);
int gem_get_cacheing(int fd, uint32_t handle); int gem_get_cacheing(int fd, uint32_t handle);
uint32_t gem_flink(int fd, uint32_t handle); uint32_t gem_flink(int fd, uint32_t handle);
uint32_t gem_open(int fd, uint32_t name); uint32_t gem_open(int fd, uint32_t name);

View File

@ -257,8 +257,17 @@ static void do_tests(int cache_level, const char *suffix)
{ {
char name[80]; char name[80];
if (cache_level != -1) if (cache_level != -1) {
gem_set_cacheing(fd, scratch_bo->handle, cache_level); switch (gem_set_cacheing(fd, scratch_bo->handle, cache_level)) {
case 0: break;
case -EINVAL:
case -ENOTTY:
return;
default:
assert(0);
return;
}
}
snprintf(name, sizeof(name), "reads%s", suffix); snprintf(name, sizeof(name), "reads%s", suffix);
if (drmtest_run_subtest(name)) if (drmtest_run_subtest(name))
@ -299,6 +308,7 @@ int main(int argc, char **argv)
/* Repeat the tests using different levels of snooping */ /* Repeat the tests using different levels of snooping */
do_tests(0, "-uncached"); do_tests(0, "-uncached");
do_tests(1, "-snoop"); do_tests(1, "-snoop");
do_tests(2, "-display");
drmtest_cleanup_aperture_trashers(); drmtest_cleanup_aperture_trashers();
drm_intel_bufmgr_destroy(bufmgr); drm_intel_bufmgr_destroy(bufmgr);

View File

@ -83,6 +83,15 @@ int main(int argc, char **argv)
uint32_t buf[20]; uint32_t buf[20];
uint32_t *src, dst; uint32_t *src, dst;
int fd, count; int fd, count;
const struct {
int level;
const char *name;
} cache[] = {
{ 0, "uncached" },
{ 1, "snoop" },
{ 2, "display" },
{ -1 },
}, *c;
drmtest_skip_on_simulation(); drmtest_skip_on_simulation();
@ -97,32 +106,35 @@ int main(int argc, char **argv)
dst = gem_create(fd, object_size); dst = gem_create(fd, object_size);
src = malloc(object_size); src = malloc(object_size);
gem_set_cacheing(fd, dst, 0);
for (count = 1; count <= 1<<17; count <<= 1) { for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end; struct timeval start, end;
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
do_gem_read(fd, dst, src, object_size, count); do_gem_read(fd, dst, src, object_size, count);
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
printf("Time to uncached pread %d bytes x %6d: %7.3fµs, %s\n", printf("Time to pread %d bytes x %6d: %7.3fµs, %s\n",
object_size, count, object_size, count,
elapsed(&start, &end, count), elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6)); bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout); fflush(stdout);
} }
gem_set_cacheing(fd, dst, 1); for (c = cache; c->level != -1; c++) {
for (count = 1; count <= 1<<17; count <<= 1) { if (gem_set_cacheing(fd, dst, c->level))
struct timeval start, end; continue;
gettimeofday(&start, NULL); for (count = 1; count <= 1<<17; count <<= 1) {
do_gem_read(fd, dst, src, object_size, count); struct timeval start, end;
gettimeofday(&end, NULL);
printf("Time to snooped pread %d bytes x %6d: %7.3fµs, %s\n", gettimeofday(&start, NULL);
object_size, count, do_gem_read(fd, dst, src, object_size, count);
elapsed(&start, &end, count), gettimeofday(&end, NULL);
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6)); printf("Time to %s pread %d bytes x %6d: %7.3fµs, %s\n",
fflush(stdout); c->name, object_size, count,
elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout);
}
} }
free(src); free(src);

View File

@ -131,8 +131,9 @@ static void do_test(int fd, int cache_level,
int loop) int loop)
{ {
if (cache_level != -1) { if (cache_level != -1) {
gem_set_cacheing(fd, tmp[0]->handle, cache_level); if (gem_set_cacheing(fd, tmp[0]->handle, cache_level) ||
gem_set_cacheing(fd, tmp[1]->handle, cache_level); gem_set_cacheing(fd, tmp[1]->handle, cache_level))
return;
} }
do { do {
@ -215,6 +216,15 @@ main(int argc, char **argv)
do_test(fd, 1, src, start, dst, 100); do_test(fd, 1, src, start, dst, 100);
drmtest_stop_signal_helper(); drmtest_stop_signal_helper();
} }
if (drmtest_run_subtest("normal-display"))
do_test(fd, 2, src, start, dst, 1);
if (drmtest_run_subtest("interruptible-display")) {
drmtest_fork_signal_helper();
do_test(fd, 2, src, start, dst, 100);
drmtest_stop_signal_helper();
}
drm_intel_bo_unreference(src[0]); drm_intel_bo_unreference(src[0]);
drm_intel_bo_unreference(src[1]); drm_intel_bo_unreference(src[1]);
drm_intel_bo_unreference(dst[0]); drm_intel_bo_unreference(dst[0]);

View File

@ -90,6 +90,15 @@ int main(int argc, char **argv)
uint32_t buf[20]; uint32_t buf[20];
uint32_t *src, dst; uint32_t *src, dst;
int fd, count; int fd, count;
const struct {
int level;
const char *name;
} cache[] = {
{ 0, "uncached" },
{ 1, "snoop" },
{ 2, "display" },
{ -1 },
}, *c;
drmtest_skip_on_simulation(); drmtest_skip_on_simulation();
@ -104,32 +113,35 @@ int main(int argc, char **argv)
dst = gem_create(fd, object_size); dst = gem_create(fd, object_size);
src = malloc(object_size); src = malloc(object_size);
gem_set_cacheing(fd, dst, 0);
for (count = 1; count <= 1<<17; count <<= 1) { for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end; struct timeval start, end;
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
do_gem_write(fd, dst, src, object_size, count); do_gem_write(fd, dst, src, object_size, count);
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
printf("Time to uncached pwrite %d bytes x %6d: %7.3fµs, %s\n", printf("Time to pwrite %d bytes x %6d: %7.3fµs, %s\n",
object_size, count, object_size, count,
elapsed(&start, &end, count), elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6)); bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout); fflush(stdout);
} }
gem_set_cacheing(fd, dst, 1); for (c = cache; c->level != -1; c++) {
for (count = 1; count <= 1<<17; count <<= 1) { if (gem_set_cacheing(fd, dst, c->level))
struct timeval start, end; continue;
gettimeofday(&start, NULL); for (count = 1; count <= 1<<17; count <<= 1) {
do_gem_write(fd, dst, src, object_size, count); struct timeval start, end;
gettimeofday(&end, NULL);
printf("Time to snooped pwrite %d bytes x %6d: %7.3fµs, %s\n", gettimeofday(&start, NULL);
object_size, count, do_gem_write(fd, dst, src, object_size, count);
elapsed(&start, &end, count), gettimeofday(&end, NULL);
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6)); printf("Time to %s pwrite %d bytes x %6d: %7.3fµs, %s\n",
fflush(stdout); c->level, object_size, count,
elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout);
}
} }
free(src); free(src);

View File

@ -398,75 +398,114 @@ int main(int argc, char **argv)
src = gem_create(fd, object_size); src = gem_create(fd, object_size);
tmp = malloc(object_size); tmp = malloc(object_size);
gem_set_cacheing(fd, src, 0); if (gem_set_cacheing(fd, src, 0) == 0 &&
gem_set_cacheing(fd, dst, 0); gem_set_cacheing(fd, dst, 0) == 0) {
if (drmtest_run_subtest("uncached-copy-correctness")) if (drmtest_run_subtest("uncached-copy-correctness"))
test_copy(fd, src, dst, tmp, object_size); test_copy(fd, src, dst, tmp, object_size);
if (drmtest_run_subtest("uncached-copy-performance")) { if (drmtest_run_subtest("uncached-copy-performance")) {
for (count = 1; count <= 1<<17; count <<= 1) { for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end; struct timeval start, end;
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
copy(fd, src, dst, tmp, object_size, count); copy(fd, src, dst, tmp, object_size, count);
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
printf("Time to uncached copy %d bytes x %6d: %7.3fµs, %s\n", printf("Time to uncached copy %d bytes x %6d: %7.3fµs, %s\n",
object_size, count, object_size, count,
elapsed(&start, &end, count), elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6)); bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout); fflush(stdout);
}
}
if (drmtest_run_subtest("uncached-pwrite-blt-gtt_mmap-correctness"))
test_as_gtt_mmap(fd, src, dst, object_size);
if (drmtest_run_subtest("uncached-pwrite-blt-gtt_mmap-performance")) {
for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end;
gettimeofday(&start, NULL);
as_gtt_mmap(fd, src, dst, tmp, object_size, count);
gettimeofday(&end, NULL);
printf("** mmap uncached copy %d bytes x %6d: %7.3fµs, %s\n",
object_size, count,
elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout);
}
} }
} }
if (drmtest_run_subtest("uncached-pwrite-blt-gtt_mmap-correctness")) if (gem_set_cacheing(fd, src, 1) == 0 &&
test_as_gtt_mmap(fd, src, dst, object_size); gem_set_cacheing(fd, dst, 1) == 0) {
if (drmtest_run_subtest("uncached-pwrite-blt-gtt_mmap-performance")) { if (drmtest_run_subtest("snooped-copy-correctness"))
for (count = 1; count <= 1<<17; count <<= 1) { test_copy(fd, src, dst, tmp, object_size);
struct timeval start, end; if (drmtest_run_subtest("snooped-copy-performance")) {
for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end;
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
as_gtt_mmap(fd, src, dst, tmp, object_size, count); copy(fd, src, dst, tmp, object_size, count);
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
printf("** mmap uncached copy %d bytes x %6d: %7.3fµs, %s\n", printf("Time to snooped copy %d bytes x %6d: %7.3fµs, %s\n",
object_size, count, object_size, count,
elapsed(&start, &end, count), elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6)); bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout); fflush(stdout);
}
}
if (drmtest_run_subtest("snooped-pwrite-blt-cpu_mmap-correctness"))
test_as_cpu_mmap(fd, src, dst, object_size);
if (drmtest_run_subtest("snooped-pwrite-blt-cpu_mmap-performance")) {
for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end;
gettimeofday(&start, NULL);
as_cpu_mmap(fd, src, dst, tmp, object_size, count);
gettimeofday(&end, NULL);
printf("** mmap snooped copy %d bytes x %6d: %7.3fµs, %s\n",
object_size, count,
elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout);
}
} }
} }
gem_set_cacheing(fd, src, 1); if (gem_set_cacheing(fd, src, 2) == 0 &&
gem_set_cacheing(fd, dst, 1); gem_set_cacheing(fd, dst, 2) == 0) {
if (drmtest_run_subtest("snooped-copy-correctness")) if (drmtest_run_subtest("display-copy-correctness"))
test_copy(fd, src, dst, tmp, object_size); test_copy(fd, src, dst, tmp, object_size);
if (drmtest_run_subtest("snooped-copy-performance")) { if (drmtest_run_subtest("display-copy-performance")) {
for (count = 1; count <= 1<<17; count <<= 1) { for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end; struct timeval start, end;
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
copy(fd, src, dst, tmp, object_size, count); copy(fd, src, dst, tmp, object_size, count);
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
printf("Time to snooped copy %d bytes x %6d: %7.3fµs, %s\n", printf("Time to display copy %d bytes x %6d: %7.3fµs, %s\n",
object_size, count, object_size, count,
elapsed(&start, &end, count), elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6)); bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout); fflush(stdout);
}
} }
}
if (drmtest_run_subtest("snooped-pwrite-blt-cpu_mmap-correctness")) if (drmtest_run_subtest("display-pwrite-blt-gtt_mmap-correctness"))
test_as_cpu_mmap(fd, src, dst, object_size); test_as_gtt_mmap(fd, src, dst, object_size);
if (drmtest_run_subtest("snooped-pwrite-blt-cpu_mmap-performance")) { if (drmtest_run_subtest("display-pwrite-blt-gtt_mmap-performance")) {
for (count = 1; count <= 1<<17; count <<= 1) { for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end; struct timeval start, end;
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
as_cpu_mmap(fd, src, dst, tmp, object_size, count); as_gtt_mmap(fd, src, dst, tmp, object_size, count);
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
printf("** mmap snooped copy %d bytes x %6d: %7.3fµs, %s\n", printf("** mmap display copy %d bytes x %6d: %7.3fµs, %s\n",
object_size, count, object_size, count,
elapsed(&start, &end, count), elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6)); bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout); fflush(stdout);
}
} }
} }