mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-07-26 11:17:05 +00:00
igt/gem_pread: Support to verify pread/pwrite for non-shmem backed obj
This patch adds support to verify pread/pwrite for non-shmem backed objects. It also shows the pread/pwrite speed. It also tests speeds for pread with and without user side page faults v2: Fixed Rebase conflicts (Ankit) v3: Precalculating values to avoid redundant function calls (Dave) Replaced igt_subtest by igt_subtest_f, added asserts for mmap, corrected indentation (Tvrtko) v4: Updated data types to avoid redundant type conversions (Tvrtko) Corrected pagefault-pread time calculation (Ankit) Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
This commit is contained in:
parent
70c3be83a0
commit
48c945322b
@ -40,6 +40,10 @@
|
|||||||
#include "drm.h"
|
#include "drm.h"
|
||||||
|
|
||||||
#define OBJECT_SIZE 16384
|
#define OBJECT_SIZE 16384
|
||||||
|
#define LARGE_OBJECT_SIZE 1024 * 1024
|
||||||
|
#define KGRN "\x1B[32m"
|
||||||
|
#define KRED "\x1B[31m"
|
||||||
|
#define KNRM "\x1B[0m"
|
||||||
|
|
||||||
static void do_gem_read(int fd, uint32_t handle, void *buf, int len, int loops)
|
static void do_gem_read(int fd, uint32_t handle, void *buf, int len, int loops)
|
||||||
{
|
{
|
||||||
@ -75,12 +79,16 @@ static const char *bytes_per_sec(char *buf, double v)
|
|||||||
|
|
||||||
|
|
||||||
uint32_t *src, dst;
|
uint32_t *src, dst;
|
||||||
|
uint32_t *dst_user, src_stolen, large_stolen;
|
||||||
|
uint32_t *stolen_pf_user, *stolen_nopf_user;
|
||||||
int fd, count;
|
int fd, count;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int object_size = 0;
|
int object_size = 0;
|
||||||
uint32_t buf[20];
|
double usecs;
|
||||||
|
char buf[100];
|
||||||
|
char* bps;
|
||||||
const struct {
|
const struct {
|
||||||
int level;
|
int level;
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -105,6 +113,8 @@ 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);
|
||||||
|
src_stolen = gem_create_stolen(fd, object_size);
|
||||||
|
dst_user = malloc(object_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
igt_subtest("basic") {
|
igt_subtest("basic") {
|
||||||
@ -114,10 +124,10 @@ int main(int argc, char **argv)
|
|||||||
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);
|
||||||
|
usecs = elapsed(&start, &end, count);
|
||||||
|
bps = bytes_per_sec(buf, object_size/usecs*1e6);
|
||||||
igt_info("Time to pread %d bytes x %6d: %7.3fµs, %s\n",
|
igt_info("Time to pread %d bytes x %6d: %7.3fµs, %s\n",
|
||||||
object_size, count,
|
object_size, count, usecs, bps);
|
||||||
elapsed(&start, &end, count),
|
|
||||||
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,18 +142,102 @@ int main(int argc, char **argv)
|
|||||||
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);
|
||||||
|
usecs = elapsed(&start, &end, count);
|
||||||
|
bps = bytes_per_sec(buf, object_size/usecs*1e6);
|
||||||
igt_info("Time to %s pread %d bytes x %6d: %7.3fµs, %s\n",
|
igt_info("Time to %s pread %d bytes x %6d: %7.3fµs, %s\n",
|
||||||
c->name, object_size, count,
|
c->name, object_size, count, usecs, bps);
|
||||||
elapsed(&start, &end, count),
|
|
||||||
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
igt_subtest("stolen-normal") {
|
||||||
|
for (count = 1; count <= 1<<17; count <<= 1) {
|
||||||
|
struct timeval start, end;
|
||||||
|
|
||||||
|
gettimeofday(&start, NULL);
|
||||||
|
do_gem_read(fd, src_stolen, dst_user, object_size, count);
|
||||||
|
gettimeofday(&end, NULL);
|
||||||
|
usecs = elapsed(&start, &end, count);
|
||||||
|
bps = bytes_per_sec(buf, object_size/usecs*1e6);
|
||||||
|
igt_info("Time to pread %d bytes x %6d: %7.3fµs, %s\n",
|
||||||
|
object_size, count, usecs, bps);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (c = cache; c->level != -1; c++) {
|
||||||
|
igt_subtest_f("stolen-%s", c->name) {
|
||||||
|
gem_set_caching(fd, src_stolen, c->level);
|
||||||
|
|
||||||
|
for (count = 1; count <= 1<<17; count <<= 1) {
|
||||||
|
struct timeval start, end;
|
||||||
|
|
||||||
|
gettimeofday(&start, NULL);
|
||||||
|
do_gem_read(fd, src_stolen, dst_user,
|
||||||
|
object_size, count);
|
||||||
|
gettimeofday(&end, NULL);
|
||||||
|
usecs = elapsed(&start, &end, count);
|
||||||
|
bps = bytes_per_sec(buf, object_size/usecs*1e6);
|
||||||
|
igt_info("Time to stolen-%s pread %d bytes x %6d: %7.3fµs, %s\n",
|
||||||
|
c->name, object_size, count, usecs, bps);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* List the time taken in pread operation for stolen objects, with
|
||||||
|
* and without the overhead of page fault handling on accessing the
|
||||||
|
* user space buffer
|
||||||
|
*/
|
||||||
|
igt_subtest("pagefault-pread") {
|
||||||
|
large_stolen = gem_create_stolen(fd, LARGE_OBJECT_SIZE);
|
||||||
|
stolen_nopf_user = (uint32_t *) mmap(NULL, LARGE_OBJECT_SIZE,
|
||||||
|
PROT_WRITE,
|
||||||
|
MAP_ANONYMOUS|MAP_PRIVATE,
|
||||||
|
-1, 0);
|
||||||
|
igt_assert(stolen_nopf_user);
|
||||||
|
|
||||||
|
for (count = 1; count <= 10; count ++) {
|
||||||
|
struct timeval start, end;
|
||||||
|
double t_elapsed = 0;
|
||||||
|
|
||||||
|
gettimeofday(&start, NULL);
|
||||||
|
do_gem_read(fd, large_stolen, stolen_nopf_user,
|
||||||
|
LARGE_OBJECT_SIZE, 1);
|
||||||
|
gettimeofday(&end, NULL);
|
||||||
|
t_elapsed = elapsed(&start, &end, count);
|
||||||
|
bps = bytes_per_sec(buf, object_size/t_elapsed*1e6);
|
||||||
|
igt_info("Pagefault-N - Time to pread %d bytes: %7.3fµs, %s\n",
|
||||||
|
LARGE_OBJECT_SIZE, t_elapsed, bps);
|
||||||
|
|
||||||
|
stolen_pf_user = (uint32_t *) mmap(NULL, LARGE_OBJECT_SIZE,
|
||||||
|
PROT_WRITE,
|
||||||
|
MAP_ANONYMOUS|MAP_PRIVATE,
|
||||||
|
-1, 0);
|
||||||
|
igt_assert(stolen_pf_user);
|
||||||
|
|
||||||
|
gettimeofday(&start, NULL);
|
||||||
|
do_gem_read(fd, large_stolen, stolen_pf_user,
|
||||||
|
LARGE_OBJECT_SIZE, 1);
|
||||||
|
gettimeofday(&end, NULL);
|
||||||
|
usecs = elapsed(&start, &end, count);
|
||||||
|
bps = bytes_per_sec(buf, object_size/usecs*1e6);
|
||||||
|
igt_info("Pagefault-Y - Time to pread %d bytes: %7.3fµs, %s%s%s\n",
|
||||||
|
LARGE_OBJECT_SIZE, usecs,
|
||||||
|
t_elapsed < usecs ? KGRN : KRED, bps, KNRM);
|
||||||
|
fflush(stdout);
|
||||||
|
munmap(stolen_pf_user, LARGE_OBJECT_SIZE);
|
||||||
|
}
|
||||||
|
munmap(stolen_nopf_user, LARGE_OBJECT_SIZE);
|
||||||
|
gem_close(fd, large_stolen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
igt_fixture {
|
igt_fixture {
|
||||||
free(src);
|
free(src);
|
||||||
gem_close(fd, dst);
|
gem_close(fd, dst);
|
||||||
|
free(dst_user);
|
||||||
|
gem_close(fd, src_stolen);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
@ -132,12 +132,15 @@ static void test_big_gtt(int fd, int scale)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t *src, dst;
|
uint32_t *src, dst;
|
||||||
|
uint32_t *src_user, dst_stolen;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int object_size = 0;
|
int object_size = 0;
|
||||||
uint32_t buf[20];
|
double usecs;
|
||||||
|
char* bps;
|
||||||
|
char buf[100];
|
||||||
int count;
|
int count;
|
||||||
const struct {
|
const struct {
|
||||||
int level;
|
int level;
|
||||||
@ -164,6 +167,8 @@ 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);
|
||||||
|
dst_stolen = gem_create_stolen(fd, object_size);
|
||||||
|
src_user = malloc(object_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
igt_subtest("basic") {
|
igt_subtest("basic") {
|
||||||
@ -173,10 +178,10 @@ int main(int argc, char **argv)
|
|||||||
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);
|
||||||
|
usecs = elapsed(&start, &end, count);
|
||||||
|
bps = bytes_per_sec(buf, object_size/usecs*1e6);
|
||||||
igt_info("Time to pwrite %d bytes x %6d: %7.3fµs, %s\n",
|
igt_info("Time to pwrite %d bytes x %6d: %7.3fµs, %s\n",
|
||||||
object_size, count,
|
object_size, count, usecs, bps);
|
||||||
elapsed(&start, &end, count),
|
|
||||||
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,10 +196,46 @@ int main(int argc, char **argv)
|
|||||||
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);
|
||||||
|
usecs = elapsed(&start, &end, count);
|
||||||
|
bps = bytes_per_sec(buf, object_size/usecs*1e6);
|
||||||
igt_info("Time to %s pwrite %d bytes x %6d: %7.3fµs, %s\n",
|
igt_info("Time to %s pwrite %d bytes x %6d: %7.3fµs, %s\n",
|
||||||
|
c->name, object_size, count, usecs, bps);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
igt_subtest("stolen-normal") {
|
||||||
|
for (count = 1; count <= 1<<17; count <<= 1) {
|
||||||
|
struct timeval start, end;
|
||||||
|
|
||||||
|
gettimeofday(&start, NULL);
|
||||||
|
do_gem_write(fd, dst_stolen, src_user,
|
||||||
|
object_size, count);
|
||||||
|
gettimeofday(&end, NULL);
|
||||||
|
usecs = elapsed(&start, &end, count);
|
||||||
|
bps = bytes_per_sec(buf, object_size/usecs*1e6);
|
||||||
|
igt_info("Time to pwrite %d bytes x %6d: %7.3fµs, %s\n",
|
||||||
|
object_size, count, usecs, bps);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c = cache; c->level != -1; c++) {
|
||||||
|
igt_subtest_f("stolen-%s", c->name) {
|
||||||
|
gem_set_caching(fd, dst, c->level);
|
||||||
|
for (count = 1; count <= 1<<17; count <<= 1) {
|
||||||
|
struct timeval start, end;
|
||||||
|
|
||||||
|
gettimeofday(&start, NULL);
|
||||||
|
do_gem_write(fd, dst_stolen, src_user,
|
||||||
|
object_size, count);
|
||||||
|
gettimeofday(&end, NULL);
|
||||||
|
bps = bytes_per_sec(buf,
|
||||||
|
object_size/usecs*1e6);
|
||||||
|
igt_info("Time to stolen-%s pwrite %d bytes x %6d: %7.3fµs, %s\n",
|
||||||
c->name, object_size, count,
|
c->name, object_size, count,
|
||||||
elapsed(&start, &end, count),
|
usecs, bps);
|
||||||
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,6 +244,8 @@ int main(int argc, char **argv)
|
|||||||
igt_fixture {
|
igt_fixture {
|
||||||
free(src);
|
free(src);
|
||||||
gem_close(fd, dst);
|
gem_close(fd, dst);
|
||||||
|
free(src_user);
|
||||||
|
gem_close(fd, dst_stolen);
|
||||||
}
|
}
|
||||||
|
|
||||||
igt_subtest("big-cpu")
|
igt_subtest("big-cpu")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user