lazy_unregister.c 1.8 KB

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