invalid_tasks.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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 void dummy_func(void *descr[], void *arg)
  18. {
  19. }
  20. static starpu_codelet cuda_only_cl =
  21. {
  22. .where = STARPU_CUDA,
  23. .cuda_func = dummy_func,
  24. .model = NULL,
  25. .nbuffers = 0
  26. };
  27. int main(int argc, char **argv)
  28. {
  29. int ret;
  30. /* We force StarPU to use 1 CPU only */
  31. struct starpu_conf conf;
  32. memset(&conf, 0, sizeof(conf));
  33. conf.ncpus = 1;
  34. starpu_init(&conf);
  35. struct starpu_task *task = starpu_task_create();
  36. task->cl = &cuda_only_cl;
  37. /* Only a CUDA device could execute that task ! */
  38. ret = starpu_task_submit(task);
  39. STARPU_ASSERT(ret == -ENODEV);
  40. struct starpu_task *task_specific = starpu_task_create();
  41. task_specific->cl = &cuda_only_cl;
  42. task_specific->execute_on_a_specific_worker = 1;
  43. task_specific->workerid = 0;
  44. /* Only a CUDA device could execute that task ! */
  45. ret = starpu_task_submit(task_specific);
  46. STARPU_ASSERT(ret == -ENODEV);
  47. starpu_shutdown();
  48. return 0;
  49. }