latency.c 1.9 KB

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