mpi_cholesky.c 2.2 KB

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