deprecated.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010 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 <starpu.h>
  17. #include "../helper.h"
  18. void cpu_codelet(void *descr[], __attribute__ ((unused)) void *_args)
  19. {
  20. int *valin = (int *)STARPU_VARIABLE_GET_PTR(descr[0]);
  21. int *valout = (int *)STARPU_VARIABLE_GET_PTR(descr[1]);
  22. *valout = *valin;
  23. }
  24. struct starpu_codelet cl_cpu_funcs =
  25. {
  26. .where = STARPU_CPU,
  27. .cpu_funcs = {cpu_codelet, NULL},
  28. .nbuffers = 2,
  29. .name = "cpu_funcs",
  30. };
  31. struct starpu_codelet cl_cpu_func =
  32. {
  33. .where = STARPU_CPU,
  34. .cpu_func = cpu_codelet,
  35. .nbuffers = 2,
  36. .name = "cpu_func",
  37. };
  38. struct starpu_codelet cl_cpu_multiple =
  39. {
  40. .where = STARPU_CPU,
  41. .cpu_func = STARPU_MULTIPLE_CPU_IMPLEMENTATIONS,
  42. .cpu_funcs = {cpu_codelet, NULL},
  43. .nbuffers = 2,
  44. .name = "cpu_multiple",
  45. };
  46. int submit_codelet(struct starpu_codelet *cl)
  47. {
  48. int x=42, y=14;
  49. starpu_data_handle_t handles[2];
  50. starpu_variable_data_register(&handles[0], 0, (uintptr_t)&x, sizeof(x));
  51. starpu_variable_data_register(&handles[1], 0, (uintptr_t)&y, sizeof(y));
  52. starpu_insert_task(cl,
  53. STARPU_R, handles[0],
  54. STARPU_W, handles[1],
  55. 0);
  56. starpu_task_wait_for_all();
  57. starpu_data_unregister(handles[0]);
  58. starpu_data_unregister(handles[1]);
  59. if (x != y)
  60. {
  61. FPRINTF(stderr, "error when executing codelet <%s>\n", cl->name);
  62. }
  63. else
  64. {
  65. FPRINTF(stderr, "success when executing codelet <%s>\n", cl->name);
  66. }
  67. return (x == y);
  68. }
  69. int main(int argc, char **argv)
  70. {
  71. int ret;
  72. ret = starpu_init(NULL);
  73. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  74. ret = submit_codelet(&cl_cpu_func);
  75. if (ret)
  76. {
  77. submit_codelet(&cl_cpu_funcs);
  78. }
  79. if (ret)
  80. {
  81. submit_codelet(&cl_cpu_multiple);
  82. }
  83. starpu_shutdown();
  84. return ret;
  85. }