starpu_init_noworker.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <stdio.h>
  17. #include <unistd.h>
  18. #include <errno.h>
  19. #include <starpu.h>
  20. #include <stdlib.h>
  21. #include "../helper.h"
  22. /*
  23. * Test that starpu_initialize returns ENODEV when no worker is available
  24. */
  25. int main(int argc, char **argv)
  26. {
  27. int ret;
  28. /* We try to initialize StarPU without any worker */
  29. struct starpu_conf conf;
  30. starpu_conf_init(&conf);
  31. conf.precedence_over_environment_variables = 1;
  32. conf.ncpus = 0;
  33. conf.ncuda = 0;
  34. conf.nopencl = 0;
  35. conf.nmic = 0;
  36. conf.nmpi_ms = 0;
  37. /* starpu_init should return -ENODEV */
  38. ret = starpu_initialize(&conf, &argc, &argv);
  39. if (ret == -ENODEV)
  40. return EXIT_SUCCESS;
  41. else
  42. {
  43. unsigned ncpu = starpu_cpu_worker_get_count();
  44. unsigned ncuda = starpu_cuda_worker_get_count();
  45. unsigned nopencl = starpu_opencl_worker_get_count();
  46. unsigned nmic = starpu_mic_worker_get_count();
  47. unsigned nmpi_ms = starpu_mpi_ms_worker_get_count();
  48. FPRINTF(stderr, "StarPU has found :\n");
  49. FPRINTF(stderr, "\t%u CPU cores\n", ncpu);
  50. FPRINTF(stderr, "\t%u CUDA devices\n", ncuda);
  51. FPRINTF(stderr, "\t%u OpenCL devices\n", nopencl);
  52. FPRINTF(stderr, "\t%u MIC devices\n", nmic);
  53. FPRINTF(stderr, "\t%u MPI Master-Slaves devices\n", nmpi_ms);
  54. return EXIT_FAILURE;
  55. }
  56. }