invalid_tasks.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #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. static void dummy_func(void *descr[], void *arg)
  28. {
  29. }
  30. static struct starpu_codelet gpu_only_cl =
  31. {
  32. .where = STARPU_CUDA,
  33. .cuda_funcs = {dummy_func, NULL},
  34. .opencl_funcs = {dummy_func, NULL},
  35. .model = NULL,
  36. .nbuffers = 0
  37. };
  38. int main(int argc, char **argv)
  39. {
  40. int ret;
  41. /* We force StarPU to use 1 CPU only */
  42. unsetenv("STARPU_NCUDA");
  43. unsetenv("STARPU_NOPENCL");
  44. unsetenv("STARPU_NCPUS");
  45. struct starpu_conf conf;
  46. memset(&conf, 0, sizeof(conf));
  47. conf.ncpus = 1;
  48. ret = starpu_init(&conf);
  49. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  50. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  51. struct starpu_task *task = starpu_task_create();
  52. task->cl = &gpu_only_cl;
  53. /* Only a CUDA device could execute that task ! */
  54. ret = starpu_task_submit(task);
  55. STARPU_ASSERT(ret == -ENODEV);
  56. task->destroy = 0;
  57. starpu_task_destroy(task);
  58. struct starpu_task *task_specific = starpu_task_create();
  59. task_specific->cl = &gpu_only_cl;
  60. task_specific->execute_on_a_specific_worker = 1;
  61. task_specific->workerid = 0;
  62. /* Only a CUDA device could execute that task ! */
  63. ret = starpu_task_submit(task_specific);
  64. STARPU_ASSERT(ret == -ENODEV);
  65. task_specific->destroy = 0;
  66. starpu_task_destroy(task_specific);
  67. starpu_shutdown();
  68. return EXIT_SUCCESS;
  69. }
  70. #endif