double_parameter.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "../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. #define SUBMIT(mode1, mode2) \
  38. task = starpu_task_create(); \
  39. \
  40. task->cl = &codelet; \
  41. task->buffers[0].handle = handle; \
  42. task->buffers[0].mode = STARPU_##mode1; \
  43. task->buffers[1].handle = handle; \
  44. task->buffers[1].mode = STARPU_##mode2; \
  45. \
  46. ret = starpu_task_submit(task); \
  47. if (ret == -ENODEV) goto enodev; \
  48. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  49. SUBMIT(R,R);
  50. SUBMIT(R,W);
  51. SUBMIT(R,RW);
  52. SUBMIT(W,R);
  53. SUBMIT(W,W);
  54. SUBMIT(W,RW);
  55. SUBMIT(RW,R);
  56. SUBMIT(RW,W);
  57. SUBMIT(RW,RW);
  58. ret = starpu_task_wait_for_all();
  59. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
  60. starpu_data_unregister(handle);
  61. starpu_shutdown();
  62. return EXIT_SUCCESS;
  63. enodev:
  64. starpu_data_unregister(handle);
  65. fprintf(stderr, "WARNING: No one can execute this task\n");
  66. /* yes, we do not perform the computation but we did detect that no one
  67. * could perform the kernel, so this is not an error from StarPU */
  68. starpu_shutdown();
  69. return STARPU_TEST_SKIPPED;
  70. }