mpi_cholesky.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2013,2015-2017 CNRS
  4. * Copyright (C) 2009-2012,2014,2015,2018 Université de Bordeaux
  5. * Copyright (C) 2012 Inria
  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_mpi_init_conf(&argc, &argv, 1, MPI_COMM_WORLD, NULL);
  34. STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init_conf");
  35. starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
  36. starpu_mpi_comm_size(MPI_COMM_WORLD, &nodes);
  37. starpu_cublas_init();
  38. if (starpu_cpu_worker_get_count() + starpu_cuda_worker_get_count() == 0)
  39. {
  40. if (rank == 0)
  41. {
  42. FPRINTF(stderr, "We need at least 1 CPU or CUDA worker.\n");
  43. }
  44. starpu_mpi_shutdown();
  45. return STARPU_TEST_SKIPPED;
  46. }
  47. parse_args(argc, argv, nodes);
  48. matrix_init(&bmat, rank, nodes, 1);
  49. matrix_display(bmat, rank);
  50. dw_cholesky(bmat, size/nblocks, rank, nodes, &timing, &flops);
  51. starpu_cublas_shutdown();
  52. starpu_mpi_shutdown();
  53. #ifndef STARPU_SIMGRID
  54. matrix_display(bmat, rank);
  55. dw_cholesky_check_computation(bmat, rank, nodes, &correctness, &flops);
  56. #endif
  57. matrix_free(&bmat, rank, nodes, 1);
  58. #ifndef STARPU_SIMGRID
  59. assert(correctness);
  60. #endif
  61. if (rank == 0)
  62. {
  63. FPRINTF(stdout, "Computation time (in ms): %2.2f\n", timing/1000);
  64. FPRINTF(stdout, "Synthetic GFlops : %2.2f\n", (flops/timing/1000.0f));
  65. }
  66. return 0;
  67. }