starpu_machine_display.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011 Université de Bordeaux 1
  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 <starpu.h>
  18. static void display_worker_names(enum starpu_archtype type)
  19. {
  20. unsigned nworkers = starpu_worker_get_count_by_type(type);
  21. int ids[nworkers];
  22. starpu_worker_get_ids_by_type(type, ids, nworkers);
  23. unsigned i;
  24. for (i = 0; i < nworkers; i++)
  25. {
  26. char name[256];
  27. starpu_worker_get_name(ids[i], name, 256);
  28. fprintf(stdout, "\t\t%s\n", name);
  29. }
  30. }
  31. static void display_combined_worker(unsigned workerid)
  32. {
  33. int worker_size;
  34. int *combined_workerid;
  35. starpu_combined_worker_get_description(workerid, &worker_size, &combined_workerid);
  36. fprintf(stdout, "\t\t");
  37. int i;
  38. for (i = 0; i < worker_size; i++)
  39. {
  40. char name[256];
  41. starpu_worker_get_name(combined_workerid[i], name, 256);
  42. fprintf(stdout, "%s\t", name);
  43. }
  44. fprintf(stdout, "\n");
  45. }
  46. static void display_all_combined_workers(void)
  47. {
  48. unsigned ncombined_workers = starpu_combined_worker_get_count();
  49. if (ncombined_workers == 0)
  50. return;
  51. unsigned nworkers = starpu_worker_get_count();
  52. fprintf(stdout, "\t%d Combined workers\n", ncombined_workers);
  53. unsigned i;
  54. for (i = 0; i < ncombined_workers; i++)
  55. display_combined_worker(nworkers + i);
  56. }
  57. int main(int argc, char **argv)
  58. {
  59. starpu_init(NULL);
  60. unsigned ncpu = starpu_cpu_worker_get_count();
  61. unsigned ncuda = starpu_cuda_worker_get_count();
  62. unsigned nopencl = starpu_opencl_worker_get_count();
  63. fprintf(stdout, "StarPU has found :\n");
  64. fprintf(stdout, "\t%d CPU cores\n", ncpu);
  65. display_worker_names(STARPU_CPU_WORKER);
  66. fprintf(stdout, "\t%d CUDA devices\n", ncuda);
  67. display_worker_names(STARPU_CUDA_WORKER);
  68. fprintf(stdout, "\t%d OpenCL devices\n", nopencl);
  69. display_worker_names(STARPU_OPENCL_WORKER);
  70. display_all_combined_workers();
  71. starpu_print_bus_bandwidth(stdout);
  72. starpu_shutdown();
  73. return 0;
  74. }