starpu_mpi_cache_stats.c 1.5 KB

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