bench_helper.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include "bench_helper.h"
  17. int comp_double(const void*_a, const void*_b)
  18. {
  19. const double* a = _a;
  20. const double* b = _b;
  21. if(*a < *b)
  22. return -1;
  23. else if(*a > *b)
  24. return 1;
  25. else
  26. return 0;
  27. }
  28. uint64_t bench_next_size(uint64_t len)
  29. {
  30. uint64_t next = len * MULT_DEFAULT;
  31. if(next <= len)
  32. next++;
  33. return next;
  34. }
  35. uint64_t bench_nb_iterations(int iterations, uint64_t len)
  36. {
  37. const uint64_t max_data = NX_MAX;
  38. if(len <= 0)
  39. len = 1;
  40. uint64_t data_size = ((uint64_t)iterations * (uint64_t)len);
  41. if(data_size > max_data)
  42. {
  43. iterations = (max_data / (uint64_t)len);
  44. if(iterations < 2)
  45. iterations = 2;
  46. }
  47. return iterations;
  48. }