modes_test.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  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. /* Dont change anything ! */
  17. struct starpu_codelet cummy_cl =
  18. {
  19. .cpu_funcs = { foo },
  20. .nbuffers = 42
  21. };
  22. /* Now, there is some work to do */
  23. struct starpu_codelet cl1 =
  24. {
  25. .cpu_funcs = { foo, bar },
  26. .nbuffers = 2,
  27. };
  28. int
  29. foo(void)
  30. {
  31. struct starpu_task *task = starpu_task_create();
  32. task->cl = &cl1;
  33. task->buffers[0].handle = handle1;
  34. task->buffers[0].mode = STARPU_R;
  35. task->synchronous = 1;
  36. task->buffers[1].handle = handles[1];
  37. task->buffers[1].mode = STARPU_W;
  38. }
  39. struct starpu_codelet cl2 =
  40. {
  41. .cpu_funcs = {foo},
  42. .nbuffers = 1
  43. };
  44. static void
  45. bar(void)
  46. {
  47. struct starpu_task *task = starpu_task_create();
  48. task->cl = &cl2;
  49. task->buffers[0].handle = h;
  50. task->buffers[0].mode = STARPU_RW;
  51. task->buffers[1].handle = h;
  52. task->buffers[1].mode = random_mode();
  53. }
  54. struct starpu_codelet cl3 =
  55. {
  56. .cpu_funcs = { bar, baz },
  57. .nbuffers = 1
  58. };
  59. static void
  60. baz(void)
  61. {
  62. struct starpu_task *blah;
  63. blah->cl = &cl3;
  64. blah->buffers[0].handle = some_handle;
  65. blah->buffers[0].mode = STARPU_RW;
  66. }