detect_combined_workers.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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 <starpu.h>
  17. #include <common/config.h>
  18. #include <common/utils.h>
  19. #include <core/workers.h>
  20. void _starpu_sched_find_worker_combinations(struct starpu_machine_topology_s *topology)
  21. {
  22. //#ifdef STARPU_HAVE_HWLOC
  23. //#error TODO !
  24. //#else
  25. struct starpu_machine_config_s *config = _starpu_get_machine_config();
  26. /* We put the id of all CPU workers in this array */
  27. int cpu_workers[STARPU_NMAXWORKERS];
  28. unsigned ncpus = 0;
  29. unsigned i;
  30. for (i = 0; i < topology->nworkers; i++)
  31. {
  32. if (config->workers[i].perf_arch == STARPU_CPU_DEFAULT)
  33. cpu_workers[ncpus++] = i;
  34. }
  35. unsigned size;
  36. for (size = 2; size <= ncpus; size *= 2)
  37. {
  38. unsigned first_cpu;
  39. for (first_cpu = 0; first_cpu < ncpus; first_cpu += size)
  40. {
  41. if (first_cpu + size <= ncpus)
  42. {
  43. int workerids[size];
  44. for (i = 0; i < size; i++)
  45. workerids[i] = cpu_workers[first_cpu + i];
  46. /* We register this combination */
  47. int ret;
  48. ret = starpu_combined_worker_assign_workerid(size, workerids);
  49. STARPU_ASSERT(ret >= 0);
  50. }
  51. }
  52. }
  53. //#endif
  54. }