lazy_unregister.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. (void) buffers;
  22. (void) args;
  23. }
  24. static struct starpu_codelet dummy_cl =
  25. {
  26. .modes = { STARPU_RW },
  27. .cpu_funcs = { dummy_func, NULL },
  28. .nbuffers = 1
  29. };
  30. int main(void)
  31. {
  32. int ret;
  33. int buffer[1024];
  34. starpu_data_handle_t handle;
  35. struct starpu_task *t1, *t2;
  36. ret = starpu_init(NULL);
  37. if (ret == -ENODEV)
  38. return STARPU_TEST_SKIPPED;
  39. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  40. starpu_variable_data_register(&handle, 0, (uintptr_t)buffer, 1024*sizeof(int));
  41. t1 = starpu_task_create();
  42. t2 = starpu_task_create();
  43. t1->cl = &dummy_cl;
  44. t2->cl = &dummy_cl;
  45. t1->handles[0] = handle;
  46. t2->handles[0] = handle;
  47. starpu_task_declare_deps_array(t2, 1, &t1);
  48. ret = starpu_task_submit(t2);
  49. if (ret == -ENODEV)
  50. return STARPU_TEST_SKIPPED;
  51. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  52. starpu_data_unregister_lazy(handle);
  53. if (starpu_data_lookup(buffer) == NULL)
  54. return EXIT_FAILURE;
  55. ret = starpu_task_submit(t1);
  56. if (ret == -ENODEV)
  57. return STARPU_TEST_SKIPPED;
  58. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  59. while (starpu_data_lookup(buffer) != NULL)
  60. usleep(100000);
  61. if (starpu_data_lookup(buffer) != NULL)
  62. return EXIT_FAILURE;
  63. starpu_shutdown();
  64. return EXIT_SUCCESS;
  65. }