starpu_worker_exists.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. static
  38. void fake(void *buffers[], void *args)
  39. {
  40. (void) buffers;
  41. (void) args;
  42. }
  43. static struct starpu_codelet cl =
  44. {
  45. .cpu_funcs = { fake, NULL},
  46. .cuda_funcs = { fake, NULL},
  47. .opencl_funcs = { fake, NULL},
  48. .cpu_funcs_name = { "fake", NULL},
  49. .nbuffers = 0
  50. };
  51. int
  52. main(int argc, char **argv)
  53. {
  54. int ret;
  55. struct starpu_task *task;
  56. ret = starpu_initialize(NULL, &argc, &argv);
  57. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  58. task = starpu_task_create();
  59. task->cl = &cl;
  60. task->destroy = 0;
  61. cl.can_execute = NULL;
  62. ret = _starpu_worker_exists(task);
  63. if (!ret)
  64. return EXIT_FAILURE;
  65. cl.can_execute = can_always_execute;
  66. ret = _starpu_worker_exists(task);
  67. if (!ret)
  68. return EXIT_FAILURE;
  69. cl.can_execute = can_never_execute;
  70. ret = _starpu_worker_exists(task);
  71. if (ret)
  72. return EXIT_FAILURE;
  73. starpu_task_destroy(task);
  74. starpu_shutdown();
  75. return EXIT_SUCCESS;
  76. }