mpi_cholesky.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012 Inria
  4. * Copyright (C) 2009-2012,2014-2015 Université de Bordeaux
  5. * Copyright (C) 2010-2013,2015-2017 CNRS
  6. * Copyright (C) 2010 Mehdi Juhoor
  7. *
  8. * StarPU is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation; either version 2.1 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * StarPU is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. */
  19. #include "mpi_cholesky.h"
  20. #include "helper.h"
  21. int main(int argc, char **argv)
  22. {
  23. /* create a simple definite positive symetric matrix example
  24. *
  25. * Hilbert matrix : h(i,j) = 1/(i+j+1)
  26. * */
  27. float ***bmat;
  28. int rank, nodes, ret;
  29. double timing, flops;
  30. #ifndef STARPU_SIMGRID
  31. int correctness;
  32. #endif
  33. ret = starpu_init(NULL);
  34. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  35. ret = starpu_mpi_init(&argc, &argv, 1);
  36. STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
  37. starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
  38. starpu_mpi_comm_size(MPI_COMM_WORLD, &nodes);
  39. starpu_cublas_init();
  40. if (starpu_cpu_worker_get_count() + starpu_cuda_worker_get_count() == 0)
  41. {
  42. if (rank == 0)
  43. {
  44. FPRINTF(stderr, "We need at least 1 CPU or CUDA worker.\n");
  45. }
  46. starpu_mpi_shutdown();
  47. starpu_shutdown();
  48. return STARPU_TEST_SKIPPED;
  49. }
  50. parse_args(argc, argv, nodes);
  51. matrix_init(&bmat, rank, nodes, 1);
  52. matrix_display(bmat, rank);
  53. dw_cholesky(bmat, size/nblocks, rank, nodes, &timing, &flops);
  54. starpu_mpi_shutdown();
  55. #ifndef STARPU_SIMGRID
  56. matrix_display(bmat, rank);
  57. dw_cholesky_check_computation(bmat, rank, nodes, &correctness, &flops);
  58. #endif
  59. matrix_free(&bmat, rank, nodes, 1);
  60. starpu_cublas_shutdown();
  61. starpu_shutdown();
  62. #ifndef STARPU_SIMGRID
  63. assert(correctness);
  64. #endif
  65. if (rank == 0)
  66. {
  67. FPRINTF(stdout, "Computation time (in ms): %2.2f\n", timing/1000);
  68. FPRINTF(stdout, "Synthetic GFlops : %2.2f\n", (flops/timing/1000.0f));
  69. }
  70. return 0;
  71. }