starpu_machine_display.c 2.3 KB

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