starpu_init_noworker.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. {
  41. starpu_shutdown();
  42. return EXIT_SUCCESS;
  43. }
  44. else
  45. {
  46. unsigned ncpu = starpu_cpu_worker_get_count();
  47. unsigned ncuda = starpu_cuda_worker_get_count();
  48. unsigned nopencl = starpu_opencl_worker_get_count();
  49. unsigned nmic = starpu_mic_worker_get_count();
  50. unsigned nmpi_ms = starpu_mpi_ms_worker_get_count();
  51. FPRINTF(stderr, "StarPU has found :\n");
  52. FPRINTF(stderr, "\t%u CPU cores\n", ncpu);
  53. FPRINTF(stderr, "\t%u CUDA devices\n", ncuda);
  54. FPRINTF(stderr, "\t%u OpenCL devices\n", nopencl);
  55. FPRINTF(stderr, "\t%u MIC devices\n", nmic);
  56. FPRINTF(stderr, "\t%u MPI Master-Slaves devices\n", nmpi_ms);
  57. starpu_shutdown();
  58. return EXIT_FAILURE;
  59. }
  60. }