starpu_init_noworker.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2021 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. starpu_conf_noworker(&conf);
  33. /* starpu_init should return -ENODEV */
  34. ret = starpu_initialize(&conf, &argc, &argv);
  35. if (ret == -ENODEV)
  36. return EXIT_SUCCESS;
  37. else
  38. {
  39. unsigned ncpu = starpu_cpu_worker_get_count();
  40. unsigned ncuda = starpu_cuda_worker_get_count();
  41. unsigned nopencl = starpu_opencl_worker_get_count();
  42. unsigned nmic = starpu_mic_worker_get_count();
  43. unsigned nmpi_ms = starpu_mpi_ms_worker_get_count();
  44. FPRINTF(stderr, "StarPU has found :\n");
  45. FPRINTF(stderr, "\t%u CPU cores\n", ncpu);
  46. FPRINTF(stderr, "\t%u CUDA devices\n", ncuda);
  47. FPRINTF(stderr, "\t%u OpenCL devices\n", nopencl);
  48. FPRINTF(stderr, "\t%u MIC devices\n", nmic);
  49. FPRINTF(stderr, "\t%u MPI Master-Slaves devices\n", nmpi_ms);
  50. return EXIT_FAILURE;
  51. }
  52. }