starpu_mpi_cache_stats.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2014-2017 CNRS
  4. * Copyright (C) 2015 Université de Bordeaux
  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 <starpu_mpi_cache_stats.h>
  18. #include <common/config.h>
  19. #include <stdio.h>
  20. #include <starpu_mpi_private.h>
  21. static int stats_enabled=0;
  22. void _starpu_mpi_cache_stats_init()
  23. {
  24. stats_enabled = starpu_get_env_number("STARPU_MPI_CACHE_STATS");
  25. if (stats_enabled == -1)
  26. {
  27. stats_enabled = 0;
  28. }
  29. if (stats_enabled == 0)
  30. return;
  31. _STARPU_DISP("Warning: StarPU is executed with STARPU_MPI_CACHE_STATS=1, which slows down a bit\n");
  32. }
  33. void _starpu_mpi_cache_stats_shutdown()
  34. {
  35. if (stats_enabled == 0)
  36. return;
  37. }
  38. void _starpu_mpi_cache_stats_update(unsigned dst, starpu_data_handle_t data_handle, int count)
  39. {
  40. size_t size;
  41. if (stats_enabled == 0)
  42. return;
  43. size = starpu_data_get_size(data_handle);
  44. if (count == 1)
  45. {
  46. _STARPU_MPI_MSG("[communication cache] + %10ld to %d\n", (long)size, dst);
  47. }
  48. else // count == -1
  49. {
  50. _STARPU_MPI_MSG("[communication cache] - %10ld from %d\n", (long)size, dst);
  51. }
  52. }