invalidate_pending_requests.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2016 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013, 2016 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 = NULL;
  27. starpu_data_handle_t handle;
  28. ret = starpu_init(NULL);
  29. if (ret == -ENODEV) goto skip;
  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. var = malloc(SIZE);
  35. starpu_variable_data_register(&handle, STARPU_MAIN_RAM, (uintptr_t)var, SIZE);
  36. /* Let a request fly */
  37. starpu_fxt_trace_user_event_string("requesting");
  38. starpu_data_fetch_on_node(handle, 1, 1);
  39. starpu_fxt_trace_user_event_string("requested");
  40. /* But suddenly invalidate the data while it's on the fly! */
  41. starpu_data_invalidate_submit(handle);
  42. starpu_fxt_trace_user_event_string("invalidated");
  43. starpu_data_unregister(handle);
  44. free(var);
  45. starpu_shutdown();
  46. return 0;
  47. enodev:
  48. starpu_shutdown();
  49. skip:
  50. return STARPU_TEST_SKIPPED;
  51. }