starpu_worker_exists.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
  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. static int can_always_execute(unsigned workerid,
  18. struct starpu_task *task,
  19. unsigned nimpl)
  20. {
  21. (void) workerid;
  22. (void) task;
  23. (void) nimpl;
  24. return 1;
  25. }
  26. static int can_never_execute(unsigned workerid,
  27. struct starpu_task *task,
  28. unsigned nimpl)
  29. {
  30. (void) workerid;
  31. (void) task;
  32. (void) nimpl;
  33. return 0;
  34. }
  35. static void fake(void *buffers[], void *args)
  36. {
  37. (void) buffers;
  38. (void) args;
  39. }
  40. static struct starpu_codelet cl =
  41. {
  42. .where = STARPU_CPU | STARPU_CUDA | STARPU_OPENCL,
  43. .cpu_funcs = { fake, NULL},
  44. .cuda_funcs = { fake, NULL},
  45. .opencl_funcs = { fake, NULL},
  46. .nbuffers = 0
  47. };
  48. int
  49. main(void)
  50. {
  51. int ret;
  52. struct starpu_task *task;
  53. starpu_init(NULL);
  54. task = starpu_task_create();
  55. task->cl = &cl;
  56. cl.can_execute = NULL;
  57. ret = _starpu_worker_exists(task);
  58. if (!ret)
  59. return EXIT_FAILURE;
  60. cl.can_execute = can_always_execute;
  61. ret = _starpu_worker_exists(task);
  62. if (!ret)
  63. return EXIT_FAILURE;
  64. cl.can_execute = can_never_execute;
  65. ret = _starpu_worker_exists(task);
  66. if (ret)
  67. return EXIT_FAILURE;
  68. starpu_shutdown();
  69. return EXIT_SUCCESS;
  70. }