starpu_worker_exists.c 1.9 KB

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