invalidate_pending_requests.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2013,2015-2017 CNRS
  4. * Copyright (C) 2010,2013,2014,2016 Université de Bordeaux
  5. * Copyright (C) 2012,2013 Inria
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #include <starpu.h>
  19. #include "../helper.h"
  20. /*
  21. * Try invalidating a variable which is pending a request
  22. */
  23. #define SIZE (100<<20)
  24. int main(void)
  25. {
  26. int ret;
  27. char *var = NULL;
  28. starpu_data_handle_t handle;
  29. ret = starpu_init(NULL);
  30. if (ret == -ENODEV) goto skip;
  31. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  32. if (starpu_worker_get_count_by_type(STARPU_CUDA_WORKER) == 0 &&
  33. starpu_worker_get_count_by_type(STARPU_OPENCL_WORKER) == 0)
  34. goto enodev;
  35. var = malloc(SIZE);
  36. starpu_variable_data_register(&handle, STARPU_MAIN_RAM, (uintptr_t)var, SIZE);
  37. /* Let a request fly */
  38. starpu_fxt_trace_user_event_string("requesting");
  39. starpu_data_fetch_on_node(handle, 1, 1);
  40. starpu_fxt_trace_user_event_string("requested");
  41. /* But suddenly invalidate the data while it's on the fly! */
  42. starpu_data_invalidate_submit(handle);
  43. starpu_fxt_trace_user_event_string("invalidated");
  44. starpu_data_unregister(handle);
  45. free(var);
  46. starpu_shutdown();
  47. return 0;
  48. enodev:
  49. starpu_shutdown();
  50. skip:
  51. return STARPU_TEST_SKIPPED;
  52. }