invalid_tasks.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010 Université de Bordeaux 1
  4. * Copyright (C) 2010 Centre National de la Recherche Scientifique
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #include <starpu.h>
  18. static void dummy_func(void *descr[], void *arg)
  19. {
  20. }
  21. static starpu_codelet cuda_only_cl =
  22. {
  23. .where = STARPU_CUDA,
  24. .cuda_func = dummy_func,
  25. .model = NULL,
  26. .nbuffers = 0
  27. };
  28. int main(int argc, char **argv)
  29. {
  30. int ret;
  31. /* We force StarPU to use 1 CPU only */
  32. struct starpu_conf conf;
  33. memset(&conf, 0, sizeof(conf));
  34. conf.ncpus = 1;
  35. starpu_init(&conf);
  36. struct starpu_task *task = starpu_task_create();
  37. task->cl = &cuda_only_cl;
  38. /* Only a CUDA device could execute that task ! */
  39. ret = starpu_task_submit(task);
  40. STARPU_ASSERT(ret == -ENODEV);
  41. struct starpu_task *task_specific = starpu_task_create();
  42. task_specific->cl = &cuda_only_cl;
  43. task_specific->execute_on_a_specific_worker = 1;
  44. task_specific->workerid = 0;
  45. /* Only a CUDA device could execute that task ! */
  46. ret = starpu_task_submit(task_specific);
  47. STARPU_ASSERT(ret == -ENODEV);
  48. starpu_shutdown();
  49. return 0;
  50. }