invalid_tasks.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011 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. #include "../common/helper.h"
  19. static void dummy_func(void *descr[], void *arg)
  20. {
  21. }
  22. static starpu_codelet cuda_only_cl =
  23. {
  24. .where = STARPU_CUDA,
  25. .cuda_func = dummy_func,
  26. .model = NULL,
  27. .nbuffers = 0
  28. };
  29. int main(int argc, char **argv)
  30. {
  31. int ret;
  32. /* We force StarPU to use 1 CPU only */
  33. struct starpu_conf conf;
  34. memset(&conf, 0, sizeof(conf));
  35. conf.ncpus = 1;
  36. ret = starpu_init(&conf);
  37. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  38. struct starpu_task *task = starpu_task_create();
  39. task->cl = &cuda_only_cl;
  40. /* Only a CUDA device could execute that task ! */
  41. ret = starpu_task_submit(task);
  42. STARPU_ASSERT(ret == -ENODEV);
  43. struct starpu_task *task_specific = starpu_task_create();
  44. task_specific->cl = &cuda_only_cl;
  45. task_specific->execute_on_a_specific_worker = 1;
  46. task_specific->workerid = 0;
  47. /* Only a CUDA device could execute that task ! */
  48. ret = starpu_task_submit(task_specific);
  49. STARPU_ASSERT(ret == -ENODEV);
  50. starpu_shutdown();
  51. return 0;
  52. }