latency.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-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 <starpu.h>
  17. #include <debug/starpu_debug_helpers.h>
  18. #include <common/config.h>
  19. #include <datawizard/coherency.h>
  20. void _starpu_benchmark_ping_pong(starpu_data_handle_t handle,
  21. unsigned node0, unsigned node1, unsigned niter)
  22. {
  23. /* We assume that no one is using that handle !! */
  24. unsigned iter;
  25. for (iter = 0; iter < niter; iter++)
  26. {
  27. int ret;
  28. _starpu_spin_lock(&handle->header_lock);
  29. handle->refcnt++;
  30. handle->busy_count++;
  31. _starpu_spin_unlock(&handle->header_lock);
  32. struct _starpu_data_replicate *replicate_0 = &handle->per_node[node0];
  33. ret = _starpu_fetch_data_on_node(handle, node0, replicate_0, STARPU_RW, 0, STARPU_FETCH, 0, NULL, NULL, 0, "_starpu_benchmark_ping_pong");
  34. STARPU_ASSERT(!ret);
  35. _starpu_release_data_on_node(handle, 0, STARPU_NONE, replicate_0);
  36. _starpu_spin_lock(&handle->header_lock);
  37. handle->refcnt++;
  38. handle->busy_count++;
  39. _starpu_spin_unlock(&handle->header_lock);
  40. struct _starpu_data_replicate *replicate_1 = &handle->per_node[node1];
  41. ret = _starpu_fetch_data_on_node(handle, node1, replicate_1, STARPU_RW, 0, STARPU_FETCH, 0, NULL, NULL, 0, "_starpu_benchmark_ping_pong");
  42. STARPU_ASSERT(!ret);
  43. _starpu_release_data_on_node(handle, 0, STARPU_NONE, replicate_1);
  44. }
  45. }