Larger performance impact is expected with first draft of the kernel implementation for overlapping objects so this is just to confirm that. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> --- benchmarks/gem_userptr_benchmark.c | 97 ++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 25 deletions(-) diff --git a/benchmarks/gem_userptr_benchmark.c b/benchmarks/gem_userptr_benchmark.c index 4d7442b..04af219 100644 --- a/benchmarks/gem_userptr_benchmark.c +++ b/benchmarks/gem_userptr_benchmark.c @@ -213,7 +213,8 @@ static void exchange_ptr(void *array, unsigned i, unsigned j) static void test_malloc_free(int random) { unsigned long iter = 0; - unsigned int i, tot = 1000; + unsigned int i; + const unsigned int tot = 1000; void *ptr[tot]; start_test(test_duration_sec); @@ -230,13 +231,14 @@ static void test_malloc_free(int random) iter++; } - printf("%8lu iter/s\n", iter / test_duration_sec); + printf("%10lu op/s\n", 2 * tot * iter / test_duration_sec); } static void test_malloc_realloc_free(int random) { unsigned long iter = 0; - unsigned int i, tot = 1000; + unsigned int i; + const unsigned int tot = 1000; void *ptr[tot]; start_test(test_duration_sec); @@ -259,13 +261,14 @@ static void test_malloc_realloc_free(int random) iter++; } - printf("%8lu iter/s\n", iter / test_duration_sec); + printf("%10lu op/s\n", 3 * tot * iter / test_duration_sec); } static void test_mmap_unmap(int random) { unsigned long iter = 0; - unsigned int i, tot = 1000; + unsigned int i; + const unsigned int tot = 1000; void *ptr[tot]; start_test(test_duration_sec); @@ -283,7 +286,7 @@ static void test_mmap_unmap(int random) iter++; } - printf("%8lu iter/s\n", iter / test_duration_sec); + printf("%10lu op/s\n", 2 * tot * iter / test_duration_sec); } static void test_ptr_read(void *ptr) @@ -307,7 +310,7 @@ static void test_ptr_read(void *ptr) iter++; } - printf("%8lu MB/s\n", iter / test_duration_sec * BO_SIZE / 1000000); + printf("%10lu MB/s\n", iter / test_duration_sec * BO_SIZE / 1000000); } static void test_ptr_write(void *ptr) @@ -331,7 +334,31 @@ static void test_ptr_write(void *ptr) iter++; } - printf("%8lu MB/s\n", iter / test_duration_sec * BO_SIZE / 1000000); + printf("%10lu MB/s\n", iter / test_duration_sec * BO_SIZE / 1000000); +} + +static void test_impact_common(void *ptr, unsigned int nr) +{ + printf("ptr-read, %5u bos = ", nr); + test_ptr_read(ptr); + + printf("ptr-write, %5u bos = ", nr); + test_ptr_write(ptr); + + printf("malloc-free, %5u bos = ", nr); + test_malloc_free(0); + printf("malloc-free-random, %5u bos = ", nr); + test_malloc_free(1); + + printf("malloc-realloc-free, %5u bos = ", nr); + test_malloc_realloc_free(0); + printf("malloc-realloc-free-random, %5u bos = ", nr); + test_malloc_realloc_free(1); + + printf("mmap-unmap, %5u bos = ", nr); + test_mmap_unmap(0); + printf("mmap-unmap-random, %5u bos = ", nr); + test_mmap_unmap(1); } static void test_impact(int fd) @@ -351,29 +378,46 @@ static void test_impact(int fd) else ptr = buffer; - printf("ptr-read, %5u bos = ", nr_bos[subtest]); - test_ptr_read(ptr); + test_impact_common(ptr, nr_bos[subtest]); - printf("ptr-write %5u bos = ", nr_bos[subtest]); - test_ptr_write(ptr); + for (i = 0; i < nr_bos[subtest]; i++) + free_userptr_bo(fd, handles[i]); + } +} - printf("malloc-free, %5u bos = ", nr_bos[subtest]); - test_malloc_free(0); - printf("malloc-free-random %5u bos = ", nr_bos[subtest]); - test_malloc_free(1); +static void test_impact_overlap(int fd) +{ + unsigned int total = sizeof(nr_bos) / sizeof(nr_bos[0]); + unsigned int subtest, i; + uint32_t handles[nr_bos[total-1]]; + void *ptr; + char buffer[BO_SIZE]; + void *block; + uint32_t handle; + int ret; - printf("malloc-realloc-free, %5u bos = ", nr_bos[subtest]); - test_malloc_realloc_free(0); - printf("malloc-realloc-free-random, %5u bos = ", nr_bos[subtest]); - test_malloc_realloc_free(1); + for (subtest = 0; subtest < total; subtest++) { + if (nr_bos[subtest] > 0) { + ret = posix_memalign(&block, PAGE_SIZE, BO_SIZE * nr_bos[subtest]); + igt_assert(ret == 0); + for (ptr = block, i = 0; i < nr_bos[subtest]; i++) { + ret = gem_userptr(fd, ptr, BO_SIZE, 0, &handle); + igt_assert(ret == 0); + handles[i] = handle; + ptr = (char *)ptr + BO_SIZE / 2; + } + ptr = block; + } else { + ptr = buffer; + } - printf("mmap-unmap, %5u bos = ", nr_bos[subtest]); - test_mmap_unmap(0); - printf("mmap-unmap-random, %5u bos = ", nr_bos[subtest]); - test_mmap_unmap(1); + test_impact_common(ptr, nr_bos[subtest]); for (i = 0; i < nr_bos[subtest]; i++) - free_userptr_bo(fd, handles[i]); + gem_close(fd, handles[i]); + + if (nr_bos[subtest]) + free(block); } } @@ -494,6 +538,9 @@ int main(int argc, char **argv) igt_subtest("userptr-impact-sync") test_impact(fd); + igt_subtest("userptr-overlap-impact-sync") + test_impact_overlap(fd); + igt_exit(); return 0; -- 1.9.3 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx