pxlu_implicit.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2011, 2013-2015, 2017 Université de Bordeaux
  4. * Copyright (C) 2010, 2012, 2013, 2017 CNRS
  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 "pxlu.h"
  18. #include "pxlu_kernels.h"
  19. #include <sys/time.h>
  20. //#define VERBOSE_INIT 1
  21. //#define DEBUG 1
  22. static unsigned no_prio = 0;
  23. static unsigned nblocks = 0;
  24. static int rank = -1;
  25. static int world_size = -1;
  26. struct callback_arg
  27. {
  28. unsigned i, j, k;
  29. };
  30. /*
  31. * Task 11 (diagonal factorization)
  32. */
  33. static void create_task_11(unsigned k)
  34. {
  35. starpu_mpi_task_insert(MPI_COMM_WORLD,
  36. &STARPU_PLU(cl11),
  37. STARPU_VALUE, &k, sizeof(k),
  38. STARPU_VALUE, &k, sizeof(k),
  39. STARPU_VALUE, &k, sizeof(k),
  40. STARPU_RW, STARPU_PLU(get_block_handle)(k, k),
  41. STARPU_PRIORITY, !no_prio ?
  42. STARPU_MAX_PRIO : STARPU_MIN_PRIO,
  43. 0);
  44. }
  45. /*
  46. * Task 12 (Update lower left (TRSM))
  47. */
  48. static void create_task_12(unsigned k, unsigned j)
  49. {
  50. #ifdef STARPU_DEVEL
  51. #warning temporary fix
  52. #endif
  53. starpu_mpi_task_insert(MPI_COMM_WORLD,
  54. //&STARPU_PLU(cl12),
  55. &STARPU_PLU(cl21),
  56. STARPU_VALUE, &j, sizeof(j),
  57. STARPU_VALUE, &j, sizeof(j),
  58. STARPU_VALUE, &k, sizeof(k),
  59. STARPU_R, STARPU_PLU(get_block_handle)(k, k),
  60. STARPU_RW, STARPU_PLU(get_block_handle)(k, j),
  61. STARPU_PRIORITY, !no_prio && (j == k+1) ?
  62. STARPU_MAX_PRIO : STARPU_MIN_PRIO,
  63. 0);
  64. }
  65. /*
  66. * Task 21 (Update upper right (TRSM))
  67. */
  68. static void create_task_21(unsigned k, unsigned i)
  69. {
  70. #ifdef STARPU_DEVEL
  71. #warning temporary fix
  72. #endif
  73. starpu_mpi_task_insert(MPI_COMM_WORLD,
  74. //&STARPU_PLU(cl21),
  75. &STARPU_PLU(cl12),
  76. STARPU_VALUE, &i, sizeof(i),
  77. STARPU_VALUE, &i, sizeof(i),
  78. STARPU_VALUE, &k, sizeof(k),
  79. STARPU_R, STARPU_PLU(get_block_handle)(k, k),
  80. STARPU_RW, STARPU_PLU(get_block_handle)(i, k),
  81. STARPU_PRIORITY, !no_prio && (i == k+1) ?
  82. STARPU_MAX_PRIO : STARPU_MIN_PRIO,
  83. 0);
  84. }
  85. /*
  86. * Task 22 (GEMM)
  87. */
  88. static void create_task_22(unsigned k, unsigned i, unsigned j)
  89. {
  90. starpu_mpi_task_insert(MPI_COMM_WORLD,
  91. &STARPU_PLU(cl22),
  92. STARPU_VALUE, &i, sizeof(i),
  93. STARPU_VALUE, &j, sizeof(j),
  94. STARPU_VALUE, &k, sizeof(k),
  95. STARPU_R, STARPU_PLU(get_block_handle)(k, j),
  96. STARPU_R, STARPU_PLU(get_block_handle)(i, k),
  97. STARPU_RW, STARPU_PLU(get_block_handle)(i, j),
  98. STARPU_PRIORITY, !no_prio && (i == k + 1) && (j == k +1) ?
  99. STARPU_MAX_PRIO : STARPU_MIN_PRIO,
  100. 0);
  101. }
  102. /*
  103. * code to bootstrap the factorization
  104. */
  105. double STARPU_PLU(plu_main)(unsigned _nblocks, int _rank, int _world_size)
  106. {
  107. double start;
  108. double end;
  109. nblocks = _nblocks;
  110. rank = _rank;
  111. world_size = _world_size;
  112. /* create all the DAG nodes */
  113. unsigned i,j,k;
  114. starpu_mpi_barrier(MPI_COMM_WORLD);
  115. start = starpu_timing_now();
  116. for (k = 0; k < nblocks; k++)
  117. {
  118. starpu_iteration_push(k);
  119. create_task_11(k);
  120. for (i = k+1; i<nblocks; i++)
  121. {
  122. create_task_12(k, i);
  123. create_task_21(k, i);
  124. }
  125. starpu_mpi_cache_flush(MPI_COMM_WORLD, STARPU_PLU(get_block_handle)(k,k));
  126. if (get_block_rank(k, k) == _rank)
  127. starpu_data_wont_use(STARPU_PLU(get_block_handle)(k,k));
  128. for (i = k+1; i<nblocks; i++)
  129. {
  130. for (j = k+1; j<nblocks; j++)
  131. {
  132. create_task_22(k, i, j);
  133. }
  134. }
  135. for (i = k+1; i<nblocks; i++)
  136. {
  137. starpu_mpi_cache_flush(MPI_COMM_WORLD, STARPU_PLU(get_block_handle)(k,i));
  138. if (get_block_rank(k, i) == _rank)
  139. starpu_data_wont_use(STARPU_PLU(get_block_handle)(k,i));
  140. starpu_mpi_cache_flush(MPI_COMM_WORLD, STARPU_PLU(get_block_handle)(i,k));
  141. if (get_block_rank(i, k) == _rank)
  142. starpu_data_wont_use(STARPU_PLU(get_block_handle)(i,k));
  143. }
  144. starpu_iteration_pop();
  145. }
  146. starpu_task_wait_for_all();
  147. starpu_mpi_barrier(MPI_COMM_WORLD);
  148. end = starpu_timing_now();
  149. double timing = end - start;
  150. // fprintf(stderr, "RANK %d -> took %f ms\n", rank, timing/1000);
  151. return timing;
  152. }