mpi_decomposition_params.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  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 "mpi_cholesky.h"
  17. #include "helper.h"
  18. #include <string.h>
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21. #include <math.h>
  22. #ifdef STARPU_HAVE_VALGRIND_H
  23. #include <valgrind/valgrind.h>
  24. #endif
  25. #ifdef STARPU_QUICK_CHECK
  26. unsigned size = 2*320;
  27. unsigned nblocks = 2;
  28. unsigned nbigblocks = 2;
  29. #elif !defined(STARPU_LONG_CHECK)
  30. unsigned size = 4*320;
  31. unsigned nblocks = 4;
  32. unsigned nbigblocks = 2;
  33. #else
  34. unsigned size = 16*320;
  35. unsigned nblocks = 16;
  36. unsigned nbigblocks = 2;
  37. #endif
  38. unsigned noprio = 0;
  39. unsigned check = 0;
  40. unsigned display = 0;
  41. int dblockx = -1;
  42. int dblocky = -1;
  43. enum submission submission = TRIANGLES;
  44. void parse_args(int argc, char **argv, int nodes)
  45. {
  46. int i;
  47. for (i = 1; i < argc; i++)
  48. {
  49. if (strcmp(argv[i], "-size") == 0)
  50. {
  51. char *argptr;
  52. size = strtol(argv[++i], &argptr, 10);
  53. }
  54. else if (strcmp(argv[i], "-dblockx") == 0)
  55. {
  56. char *argptr;
  57. dblockx = strtol(argv[++i], &argptr, 10);
  58. }
  59. else if (strcmp(argv[i], "-dblocky") == 0)
  60. {
  61. char *argptr;
  62. dblocky = strtol(argv[++i], &argptr, 10);
  63. }
  64. else if (strcmp(argv[i], "-nblocks") == 0)
  65. {
  66. char *argptr;
  67. nblocks = strtol(argv[++i], &argptr, 10);
  68. }
  69. else if (strcmp(argv[i], "-nbigblocks") == 0)
  70. {
  71. char *argptr;
  72. nbigblocks = strtol(argv[++i], &argptr, 10);
  73. }
  74. else if (strcmp(argv[i], "-columns") == 0)
  75. {
  76. submission = COLUMNS;
  77. }
  78. else if (strcmp(argv[i], "-antidiagonals") == 0)
  79. {
  80. submission = ANTIDIAGONALS;
  81. }
  82. else if (strcmp(argv[i], "-prios") == 0)
  83. {
  84. submission = PRIOS;
  85. }
  86. else if (strcmp(argv[i], "-no-prio") == 0)
  87. {
  88. noprio = 1;
  89. }
  90. else if (strcmp(argv[i], "-check") == 0)
  91. {
  92. check = 1;
  93. }
  94. else if (strcmp(argv[i], "-display") == 0)
  95. {
  96. display = 1;
  97. }
  98. else
  99. /* if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) */
  100. {
  101. printf("usage : %s [-size size] [-nblocks nblocks] [-columns] [-antidiagonals] [-prios] [-no-prio] [-display] [-check]\n", argv[0]);
  102. fprintf(stderr,"Currently selected: %ux%u and %ux%u blocks\n", size, size, nblocks, nblocks);
  103. exit(0);
  104. }
  105. }
  106. #ifdef STARPU_HAVE_VALGRIND_H
  107. if (RUNNING_ON_VALGRIND)
  108. size = 16;
  109. #endif
  110. if (nblocks > size)
  111. nblocks = size;
  112. if (dblockx == -1 || dblocky == -1)
  113. {
  114. int factor;
  115. dblockx = nodes;
  116. dblocky = 1;
  117. for(factor=sqrt(nodes) ; factor>1 ; factor--)
  118. {
  119. if (nodes % factor == 0)
  120. {
  121. dblockx = nodes/factor;
  122. dblocky = factor;
  123. break;
  124. }
  125. }
  126. }
  127. FPRINTF(stdout, "size: %u - nblocks: %u - dblocksx: %d - dblocksy: %d\n", size, nblocks, dblockx, dblocky);
  128. }