mpi_decomposition_params.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #include <string.h>
  18. #include <stdlib.h>
  19. #include <stdio.h>
  20. #include <math.h>
  21. unsigned size = 4*1024;
  22. unsigned nblocks = 16;
  23. unsigned nbigblocks = 2;
  24. unsigned noprio = 0;
  25. unsigned display = 0;
  26. int dblockx = -1;
  27. int dblocky = -1;
  28. void parse_args(int argc, char **argv, int nodes)
  29. {
  30. int i;
  31. for (i = 1; i < argc; i++)
  32. {
  33. if (strcmp(argv[i], "-size") == 0)
  34. {
  35. char *argptr;
  36. size = strtol(argv[++i], &argptr, 10);
  37. }
  38. if (strcmp(argv[i], "-dblockx") == 0)
  39. {
  40. char *argptr;
  41. dblockx = strtol(argv[++i], &argptr, 10);
  42. }
  43. if (strcmp(argv[i], "-dblocky") == 0)
  44. {
  45. char *argptr;
  46. dblocky = strtol(argv[++i], &argptr, 10);
  47. }
  48. if (strcmp(argv[i], "-nblocks") == 0)
  49. {
  50. char *argptr;
  51. nblocks = strtol(argv[++i], &argptr, 10);
  52. }
  53. if (strcmp(argv[i], "-nbigblocks") == 0)
  54. {
  55. char *argptr;
  56. nbigblocks = strtol(argv[++i], &argptr, 10);
  57. }
  58. if (strcmp(argv[i], "-no-prio") == 0)
  59. {
  60. noprio = 1;
  61. }
  62. if (strcmp(argv[i], "-display") == 0)
  63. {
  64. display = 1;
  65. }
  66. if (strcmp(argv[i], "-h") == 0)
  67. {
  68. printf("usage : %s [-display] [-size size] [-nblocks nblocks]\n", argv[0]);
  69. }
  70. }
  71. if (nblocks > size) nblocks = size;
  72. if (dblockx == -1 || dblocky == -1)
  73. {
  74. int factor;
  75. dblockx = nodes;
  76. dblocky = 1;
  77. for(factor=sqrt(nodes) ; factor>1 ; factor--)
  78. {
  79. if (nodes % factor == 0)
  80. {
  81. dblockx = nodes/factor;
  82. dblocky = factor;
  83. break;
  84. }
  85. }
  86. }
  87. }