invalid_tasks.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2011 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. #ifdef STARPU_USE_CPU
  20. static void dummy_func(void *descr[], void *arg)
  21. {
  22. }
  23. static starpu_codelet cuda_only_cl =
  24. {
  25. .where = STARPU_CUDA,
  26. .cuda_func = dummy_func,
  27. .model = NULL,
  28. .nbuffers = 0
  29. };
  30. #endif
  31. int main(int argc, char **argv)
  32. {
  33. #ifdef STARPU_USE_CPU
  34. int ret;
  35. /* We force StarPU to use 1 CPU only */
  36. struct starpu_conf conf;
  37. memset(&conf, 0, sizeof(conf));
  38. conf.ncpus = 1;
  39. ret = starpu_init(&conf);
  40. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  41. struct starpu_task *task = starpu_task_create();
  42. task->cl = &cuda_only_cl;
  43. /* Only a CUDA device could execute that task ! */
  44. ret = starpu_task_submit(task);
  45. STARPU_ASSERT(ret == -ENODEV);
  46. struct starpu_task *task_specific = starpu_task_create();
  47. task_specific->cl = &cuda_only_cl;
  48. task_specific->execute_on_a_specific_worker = 1;
  49. task_specific->workerid = 0;
  50. /* Only a CUDA device could execute that task ! */
  51. ret = starpu_task_submit(task_specific);
  52. STARPU_ASSERT(ret == -ENODEV);
  53. starpu_shutdown();
  54. return 0;
  55. #else
  56. fprintf(stderr,"WARNING: Can not test this without CPUs\n");
  57. return 77;
  58. #endif
  59. }