lazy_unregister.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2011, 2012 Centre National de la Recherche Scientifique
  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 <config.h>
  17. #include <starpu.h>
  18. #include "../helper.h"
  19. static void dummy_func(void ** buffers, void * args) {
  20. }
  21. static struct starpu_codelet dummy_cl =
  22. {
  23. .modes = { STARPU_RW },
  24. .cpu_funcs = {fummy_func, NULL},
  25. .nbuffers = 1
  26. };
  27. int main(int argc, char **argv)
  28. {
  29. int i;
  30. int ret;
  31. int buffer[1024];
  32. starpu_data_handle_t handle;
  33. struct starpu_task *t1, *t2;
  34. ret = starpu_init(NULL);
  35. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  36. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  37. starpu_variable_data_register(&handle, 0, (uintptr_t)buffer, 1024*sizeof(int));
  38. t1 = starpu_task_create();
  39. t2 = starpu_task_create();
  40. t1->cl = &dummy_cl;
  41. t2->cl = &dummy_cl;
  42. t1->handles[0] = handle;
  43. t2->handles[0] = handle;
  44. starpu_task_declare_deps_array(t2, 1, &t1);
  45. starpu_task_submit(t2);
  46. starpu_data_unregister_lazy(handle);
  47. if (starpu_data_lookup(buffer) == NULL)
  48. return EXIT_FAILURE;
  49. starpu_task_submit(t1);
  50. starpu_task_wait(t2);
  51. if (starpu_data_lookup(buffer) != NULL)
  52. return EXIT_FAILURE;
  53. starpu_shutdown();
  54. return EXIT_SUCCESS;
  55. }