starpu_machine_display.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012 Inria
  4. * Copyright (C) 2011-2015,2017 Université de Bordeaux
  5. * Copyright (C) 2012-2014,2016-2017 CNRS
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #include <stdio.h>
  19. #include <starpu.h>
  20. #include <starpu_scheduler.h>
  21. #include <common/config.h>
  22. #define PROGNAME "starpu_machine_display"
  23. static void usage()
  24. {
  25. fprintf(stderr, "Show the processing units that StarPU can use,\n");
  26. fprintf(stderr, "and the bandwitdh and affinity measured between the memory nodes.\n");
  27. fprintf(stderr, "\n");
  28. fprintf(stderr, "Usage: %s [OPTION]\n", PROGNAME);
  29. fprintf(stderr, "\n");
  30. fprintf(stderr, "Options:\n");
  31. fprintf(stderr, "\t-h, --help display this help and exit\n");
  32. fprintf(stderr, "\t-v, --version output version information and exit\n");
  33. fprintf(stderr, "\t-i, --info display the name of the files containing the information\n");
  34. fprintf(stderr, "\t-f, --force force bus sampling and show measures \n");
  35. fprintf(stderr, "\n");
  36. fprintf(stderr, "Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
  37. }
  38. static void display_combined_worker(unsigned workerid)
  39. {
  40. int worker_size;
  41. int *combined_workerid;
  42. starpu_combined_worker_get_description(workerid, &worker_size, &combined_workerid);
  43. fprintf(stdout, "\t\t");
  44. int i;
  45. for (i = 0; i < worker_size; i++)
  46. {
  47. char name[256];
  48. starpu_worker_get_name(combined_workerid[i], name, 256);
  49. fprintf(stdout, "%s\t", name);
  50. }
  51. fprintf(stdout, "\n");
  52. }
  53. static void display_all_combined_workers(void)
  54. {
  55. unsigned ncombined_workers = starpu_combined_worker_get_count();
  56. if (ncombined_workers == 0)
  57. return;
  58. unsigned nworkers = starpu_worker_get_count();
  59. fprintf(stdout, "\t%u Combined workers\n", ncombined_workers);
  60. unsigned i;
  61. for (i = 0; i < ncombined_workers; i++)
  62. display_combined_worker(nworkers + i);
  63. }
  64. static void parse_args(int argc, char **argv, int *force, int *info)
  65. {
  66. int i;
  67. if (argc == 1)
  68. return;
  69. for (i = 1; i < argc; i++)
  70. {
  71. if (strncmp(argv[i], "--force", 7) == 0 || strncmp(argv[i], "-f", 2) == 0)
  72. {
  73. *force = 1;
  74. }
  75. else if (strncmp(argv[i], "--info", 6) == 0 || strncmp(argv[i], "-i", 2) == 0)
  76. {
  77. *info = 1;
  78. }
  79. else if (strncmp(argv[i], "--help", 6) == 0 || strncmp(argv[i], "-h", 2) == 0)
  80. {
  81. usage();
  82. exit(EXIT_FAILURE);
  83. }
  84. else if (strncmp(argv[i], "--version", 9) == 0 || strncmp(argv[i], "-v", 2) == 0)
  85. {
  86. fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
  87. exit(EXIT_FAILURE);
  88. }
  89. else
  90. {
  91. fprintf(stderr, "Unknown arg %s\n", argv[1]);
  92. usage();
  93. exit(EXIT_FAILURE);
  94. }
  95. }
  96. }
  97. int main(int argc, char **argv)
  98. {
  99. int ret;
  100. int force = 0;
  101. int info = 0;
  102. struct starpu_conf conf;
  103. parse_args(argc, argv, &force, &info);
  104. starpu_conf_init(&conf);
  105. if (force)
  106. conf.bus_calibrate = 1;
  107. /* Even if starpu_init returns -ENODEV, we should go on : we will just
  108. * print that we found no device. */
  109. ret = starpu_init(&conf);
  110. if (ret != 0 && ret != -ENODEV)
  111. {
  112. return ret;
  113. }
  114. if (info)
  115. {
  116. starpu_bus_print_filenames(stdout);
  117. starpu_shutdown();
  118. return 0;
  119. }
  120. fprintf(stdout, "StarPU has found :\n");
  121. starpu_worker_display_names(stdout, STARPU_CPU_WORKER);
  122. starpu_worker_display_names(stdout, STARPU_CUDA_WORKER);
  123. starpu_worker_display_names(stdout, STARPU_OPENCL_WORKER);
  124. #ifdef STARPU_USE_MIC
  125. starpu_worker_display_names(stdout, STARPU_MIC_WORKER);
  126. #endif
  127. #ifdef STARPU_USE_SCC
  128. starpu_worker_display_names(stdout, STARPU_SCC_WORKER);
  129. #endif
  130. #ifdef STARPU_USE_MPI_MASTER_SLAVE
  131. starpu_worker_display_names(stdout, STARPU_MPI_MS_WORKER);
  132. #endif
  133. display_all_combined_workers();
  134. if (ret != -ENODEV)
  135. {
  136. fprintf(stdout, "\ntopology ... (hwloc logical indexes)\n");
  137. starpu_topology_print(stdout);
  138. fprintf(stdout, "\nbandwidth and latency ...\n");
  139. starpu_bus_print_bandwidth(stdout);
  140. starpu_shutdown();
  141. }
  142. return 0;
  143. }