lazy_unregister.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2011, 2012, 2013 CNRS
  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 <unistd.h>
  20. #include "../helper.h"
  21. /*
  22. * Test that starpu_data_unregister_submit waits for both tasks to finish
  23. */
  24. void dummy_func(void ** buffers, void * args)
  25. {
  26. (void) buffers;
  27. (void) args;
  28. }
  29. static struct starpu_codelet dummy_cl =
  30. {
  31. .modes = { STARPU_RW },
  32. .cpu_funcs = { dummy_func },
  33. .cpu_funcs_name = { "dummy_func" },
  34. .nbuffers = 1
  35. };
  36. int main(void)
  37. {
  38. int ret;
  39. int buffer[1024];
  40. starpu_data_handle_t handle;
  41. struct starpu_task *t1,*t2;
  42. ret = starpu_init(NULL);
  43. if (ret == -ENODEV)
  44. return STARPU_TEST_SKIPPED;
  45. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  46. starpu_variable_data_register(&handle, STARPU_MAIN_RAM, (uintptr_t)buffer, 1024*sizeof(int));
  47. t1 = starpu_task_create();
  48. t2 = starpu_task_create();
  49. t2->cl = &dummy_cl;
  50. t2->detach = 0;
  51. t2->handles[0] = handle;
  52. starpu_task_declare_deps_array(t2, 1, &t1);
  53. ret = starpu_task_submit(t2);
  54. if (ret == -ENODEV)
  55. return STARPU_TEST_SKIPPED;
  56. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  57. starpu_data_unregister_submit(handle);
  58. ret = starpu_task_submit(t1);
  59. if (ret == -ENODEV)
  60. return STARPU_TEST_SKIPPED;
  61. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  62. ret = starpu_task_wait(t2);
  63. if (ret == -ENODEV)
  64. return STARPU_TEST_SKIPPED;
  65. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
  66. while (starpu_data_lookup(buffer) != NULL)
  67. usleep(100000);
  68. starpu_shutdown();
  69. return EXIT_SUCCESS;
  70. }