invalid_tasks.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2012 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012 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 "../helper.h"
  19. #if !defined(STARPU_HAVE_UNSETENV) || !defined(STARPU_USE_CPU)
  20. #warning unsetenv is not defined or no cpu are available. Skipping test
  21. int main(int argc, char **argv)
  22. {
  23. return STARPU_TEST_SKIPPED;
  24. }
  25. #else
  26. static void dummy_func(void *descr[], void *arg)
  27. {
  28. }
  29. static struct starpu_codelet cuda_only_cl =
  30. {
  31. .where = STARPU_CUDA,
  32. .cuda_funcs = {dummy_func, NULL},
  33. .model = NULL,
  34. .nbuffers = 0
  35. };
  36. int main(int argc, char **argv)
  37. {
  38. int ret;
  39. /* We force StarPU to use 1 CPU only */
  40. unsetenv("STARPU_NCUDA");
  41. unsetenv("STARPU_NOPENCL");
  42. unsetenv("STARPU_NCPUS");
  43. struct starpu_conf conf;
  44. memset(&conf, 0, sizeof(conf));
  45. conf.ncpus = 1;
  46. ret = starpu_init(&conf);
  47. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  48. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  49. struct starpu_task *task = starpu_task_create();
  50. task->cl = &cuda_only_cl;
  51. /* Only a CUDA device could execute that task ! */
  52. ret = starpu_task_submit(task);
  53. STARPU_ASSERT(ret == -ENODEV);
  54. starpu_task_destroy(task);
  55. struct starpu_task *task_specific = starpu_task_create();
  56. task_specific->cl = &cuda_only_cl;
  57. task_specific->execute_on_a_specific_worker = 1;
  58. task_specific->workerid = 0;
  59. /* Only a CUDA device could execute that task ! */
  60. ret = starpu_task_submit(task_specific);
  61. STARPU_ASSERT(ret == -ENODEV);
  62. starpu_task_destroy(task_specific);
  63. starpu_shutdown();
  64. return EXIT_SUCCESS;
  65. }
  66. #endif