mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-12 02:16:17 +00:00
tests/gem_*_blits: reduce buffer count to not trash swap
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
62c542fd4e
commit
b75451838a
@ -36,6 +36,7 @@
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
#include "intel_gpu_tools.h"
|
||||
#include "i915_drm.h"
|
||||
@ -73,3 +74,19 @@ int intel_gen(uint32_t devid)
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
intel_get_total_ram_mb(void)
|
||||
{
|
||||
struct sysinfo sysinf;
|
||||
uint64_t retval;
|
||||
int ret;
|
||||
|
||||
ret = sysinfo(&sysinf);
|
||||
assert(ret == 0);
|
||||
|
||||
retval = sysinf.totalram;
|
||||
retval *= sysinf.mem_unit;
|
||||
|
||||
return retval / (1024*1024);
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ struct pci_device *intel_get_pci_device(void);
|
||||
|
||||
uint32_t intel_get_drm_devid(int fd);
|
||||
int intel_gen(uint32_t devid);
|
||||
uint64_t intel_get_total_ram_mb(void);
|
||||
|
||||
void intel_map_file(char *);
|
||||
|
||||
|
@ -248,6 +248,13 @@ int main(int argc, char **argv)
|
||||
count = atoi(argv[1]);
|
||||
if (count == 0)
|
||||
count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
|
||||
|
||||
if (count > intel_get_total_ram_mb() * 9 / 10) {
|
||||
count = intel_get_total_ram_mb() * 9 / 10;
|
||||
fprintf(stderr, "not enough RAM to run test, reducing buffer count\n");
|
||||
return 77;
|
||||
}
|
||||
|
||||
printf("Using %d 1MiB buffers\n", count);
|
||||
|
||||
handle = malloc(sizeof(uint32_t)*count*2);
|
||||
|
@ -144,6 +144,13 @@ int main(int argc, char **argv)
|
||||
count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
|
||||
count += (count & 1) == 0;
|
||||
}
|
||||
|
||||
if (count > intel_get_total_ram_mb() * 9 / 10) {
|
||||
count = intel_get_total_ram_mb() * 9 / 10;
|
||||
fprintf(stderr, "not enough RAM to run test, reducing buffer count\n");
|
||||
return 77;
|
||||
}
|
||||
|
||||
printf("Using %d 1MiB buffers\n", count);
|
||||
|
||||
bo = malloc(sizeof(drm_intel_bo *)*count);
|
||||
|
@ -148,6 +148,11 @@ int main(int argc, char **argv)
|
||||
|
||||
fd = drm_open_any();
|
||||
count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
|
||||
if (count > intel_get_total_ram_mb() * 9 / 10) {
|
||||
count = intel_get_total_ram_mb() * 9 / 10;
|
||||
fprintf(stderr, "not enough RAM to run test, reducing buffer count\n");
|
||||
return 77;
|
||||
}
|
||||
count |= 1;
|
||||
printf("Using %d 1MiB buffers\n", count);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user