invalidate_pending_requests.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2016 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013 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 "../helper.h"
  19. /*
  20. * Try invalidating a variable which is pending a request
  21. */
  22. #define SIZE (100<<20)
  23. int main(int argc, char **argv)
  24. {
  25. int ret;
  26. char *var = malloc(SIZE);
  27. starpu_data_handle_t handle;
  28. ret = starpu_init(NULL);
  29. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  30. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  31. if (starpu_worker_get_count_by_type(STARPU_CUDA_WORKER) == 0 &&
  32. starpu_worker_get_count_by_type(STARPU_OPENCL_WORKER) == 0)
  33. goto enodev;
  34. starpu_variable_data_register(&handle, STARPU_MAIN_RAM, (uintptr_t)var, SIZE);
  35. /* Let a request fly */
  36. starpu_fxt_trace_user_event_string("requesting");
  37. starpu_data_fetch_on_node(handle, 1, 1);
  38. starpu_fxt_trace_user_event_string("requested");
  39. /* But suddenly invalidate the data while it's on the fly! */
  40. starpu_data_invalidate_submit(handle);
  41. starpu_fxt_trace_user_event_string("invalidated");
  42. starpu_data_unregister(handle);
  43. starpu_shutdown();
  44. return 0;
  45. enodev:
  46. starpu_shutdown();
  47. return STARPU_TEST_SKIPPED;
  48. }