invalid_tasks.c 2.2 KB

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