double_parameter.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011 Université de Bordeaux 1
  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 "../common/helper.h"
  18. static void dummy_func(void *descr[] __attribute__ ((unused)), void *arg __attribute__ ((unused)))
  19. {
  20. }
  21. static struct starpu_codelet codelet =
  22. {
  23. .where = STARPU_CPU,
  24. .cpu_funcs = { dummy_func, NULL },
  25. .model = NULL,
  26. .nbuffers = 2
  27. };
  28. int main(int argc, char **argv)
  29. {
  30. float foo = 0.0f;
  31. starpu_data_handle_t handle;
  32. int ret;
  33. struct starpu_task *task;
  34. ret = starpu_init(NULL);
  35. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  36. starpu_variable_data_register(&handle, 0, (uintptr_t)&foo, sizeof(foo));
  37. task = starpu_task_create();
  38. #define SUBMIT(mode1, mode2) \
  39. task->cl = &codelet; \
  40. task->buffers[0].handle = handle; \
  41. task->buffers[0].mode = STARPU_##mode1; \
  42. task->buffers[1].handle = handle; \
  43. task->buffers[1].mode = STARPU_##mode2; \
  44. \
  45. ret = starpu_task_submit(task); \
  46. if (ret == -ENODEV) goto enodev; \
  47. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  48. SUBMIT(R,R);
  49. #if 0
  50. /* Not possible yet */
  51. SUBMIT(R,W);
  52. SUBMIT(R,RW);
  53. SUBMIT(W,R);
  54. SUBMIT(W,W);
  55. SUBMIT(W,RW);
  56. SUBMIT(RW,R);
  57. SUBMIT(RW,W);
  58. SUBMIT(RW,RW);
  59. #endif
  60. ret = starpu_task_wait_for_all();
  61. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
  62. starpu_data_unregister(handle);
  63. starpu_shutdown();
  64. return EXIT_SUCCESS;
  65. enodev:
  66. starpu_data_unregister(handle);
  67. fprintf(stderr, "WARNING: No one can execute this task\n");
  68. /* yes, we do not perform the computation but we did detect that no one
  69. * could perform the kernel, so this is not an error from StarPU */
  70. starpu_shutdown();
  71. return 77;
  72. }