footprint.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010-2011 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #include <datawizard/footprint.h>
  18. #include <starpu_hash.h>
  19. uint32_t _starpu_compute_buffers_footprint(struct starpu_perfmodel *model, enum starpu_perf_archtype arch, unsigned nimpl, struct _starpu_job *j)
  20. {
  21. if (j->footprint_is_computed)
  22. return j->footprint;
  23. uint32_t footprint = 0;
  24. unsigned buffer;
  25. struct starpu_task *task = j->task;
  26. if (model && model->per_arch[arch][nimpl].size_base)
  27. {
  28. size_t size = model->per_arch[arch][nimpl].size_base(task, arch, nimpl);
  29. footprint = starpu_crc32_be_n(&size, sizeof(size), footprint);
  30. }
  31. else if (model && model->size_base)
  32. {
  33. size_t size = model->size_base(task, nimpl);
  34. footprint = starpu_crc32_be_n(&size, sizeof(size), footprint);
  35. }
  36. else
  37. {
  38. for (buffer = 0; buffer < task->cl->nbuffers; buffer++)
  39. {
  40. starpu_data_handle_t handle = task->handles[buffer];
  41. uint32_t handle_footprint = _starpu_data_get_footprint(handle);
  42. footprint = starpu_crc32_be(handle_footprint, footprint);
  43. }
  44. }
  45. j->footprint = footprint;
  46. j->footprint_is_computed = 1;
  47. return footprint;
  48. }
  49. uint32_t _starpu_compute_data_footprint(starpu_data_handle_t handle)
  50. {
  51. uint32_t interfaceid = (uint32_t)starpu_handle_get_interface_id(handle);
  52. STARPU_ASSERT(handle->ops->footprint);
  53. uint32_t handle_footprint = handle->ops->footprint(handle);
  54. return starpu_crc32_be(handle_footprint, interfaceid);
  55. }