modes_test.c 1.9 KB

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