lazy_unregister.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012,2013 Inria
  4. * Copyright (C) 2010-2013,2015,2017 CNRS
  5. * Copyright (C) 2012,2014-2016 Université de Bordeaux
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #include <starpu.h>
  19. #include <stdlib.h>
  20. #include <unistd.h>
  21. #include "../helper.h"
  22. /*
  23. * Test that starpu_data_unregister_submit waits for both tasks to finish
  24. */
  25. void dummy_func(void ** buffers, void * args)
  26. {
  27. (void) buffers;
  28. (void) args;
  29. }
  30. static struct starpu_codelet dummy_cl =
  31. {
  32. .modes = { STARPU_RW },
  33. .cpu_funcs = { dummy_func },
  34. .cpu_funcs_name = { "dummy_func" },
  35. .nbuffers = 1
  36. };
  37. int main(void)
  38. {
  39. int ret;
  40. int buffer[1024];
  41. starpu_data_handle_t handle;
  42. struct starpu_task *t1,*t2;
  43. ret = starpu_init(NULL);
  44. if (ret == -ENODEV)
  45. return STARPU_TEST_SKIPPED;
  46. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  47. starpu_variable_data_register(&handle, STARPU_MAIN_RAM, (uintptr_t)buffer, 1024*sizeof(int));
  48. t1 = starpu_task_create();
  49. t2 = starpu_task_create();
  50. t2->cl = &dummy_cl;
  51. t2->detach = 0;
  52. t2->handles[0] = handle;
  53. starpu_task_declare_deps_array(t2, 1, &t1);
  54. ret = starpu_task_submit(t2);
  55. if (ret == -ENODEV)
  56. return STARPU_TEST_SKIPPED;
  57. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  58. starpu_data_unregister_submit(handle);
  59. ret = starpu_task_submit(t1);
  60. if (ret == -ENODEV)
  61. return STARPU_TEST_SKIPPED;
  62. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  63. ret = starpu_task_wait(t2);
  64. if (ret == -ENODEV)
  65. return STARPU_TEST_SKIPPED;
  66. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
  67. while (starpu_data_lookup(buffer) != NULL)
  68. usleep(100000);
  69. starpu_shutdown();
  70. return EXIT_SUCCESS;
  71. }