starpu_worker_exists.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #include "core/workers.h"
  18. static int can_always_execute(unsigned workerid,
  19. struct starpu_task *task,
  20. unsigned nimpl)
  21. {
  22. (void) workerid;
  23. (void) task;
  24. (void) nimpl;
  25. return 1;
  26. }
  27. static int can_never_execute(unsigned workerid,
  28. struct starpu_task *task,
  29. unsigned nimpl)
  30. {
  31. (void) workerid;
  32. (void) task;
  33. (void) nimpl;
  34. return 0;
  35. }
  36. static void fake(void *buffers[], void *args)
  37. {
  38. (void) buffers;
  39. (void) args;
  40. }
  41. static struct starpu_codelet cl =
  42. {
  43. .where = STARPU_CPU | STARPU_CUDA | STARPU_OPENCL,
  44. .cpu_funcs = { fake, NULL},
  45. .cuda_funcs = { fake, NULL},
  46. .opencl_funcs = { fake, NULL},
  47. .nbuffers = 0
  48. };
  49. int
  50. main(void)
  51. {
  52. int ret;
  53. struct starpu_task *task;
  54. starpu_init(NULL);
  55. task = starpu_task_create();
  56. task->cl = &cl;
  57. cl.can_execute = NULL;
  58. ret = _starpu_worker_exists(task);
  59. if (!ret)
  60. return EXIT_FAILURE;
  61. cl.can_execute = can_always_execute;
  62. ret = _starpu_worker_exists(task);
  63. if (!ret)
  64. return EXIT_FAILURE;
  65. cl.can_execute = can_never_execute;
  66. ret = _starpu_worker_exists(task);
  67. if (ret)
  68. return EXIT_FAILURE;
  69. starpu_shutdown();
  70. return EXIT_SUCCESS;
  71. }