mpi_cholesky.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. * Copyright (C) 2010 Mehdi Juhoor
  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 "mpi_cholesky.h"
  18. #include "helper.h"
  19. int main(int argc, char **argv)
  20. {
  21. /* create a simple definite positive symetric matrix example
  22. *
  23. * Hilbert matrix : h(i,j) = 1/(i+j+1)
  24. * */
  25. float ***bmat;
  26. int rank, nodes, ret;
  27. double timing, flops;
  28. #ifndef STARPU_SIMGRID
  29. int correctness;
  30. #endif
  31. ret = starpu_mpi_init_conf(&argc, &argv, 1, MPI_COMM_WORLD, NULL);
  32. STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init_conf");
  33. starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
  34. starpu_mpi_comm_size(MPI_COMM_WORLD, &nodes);
  35. starpu_cublas_init();
  36. if (starpu_cpu_worker_get_count() + starpu_cuda_worker_get_count() == 0)
  37. {
  38. if (rank == 0)
  39. {
  40. FPRINTF(stderr, "We need at least 1 CPU or CUDA worker.\n");
  41. }
  42. starpu_mpi_shutdown();
  43. return STARPU_TEST_SKIPPED;
  44. }
  45. parse_args(argc, argv, nodes);
  46. matrix_init(&bmat, rank, nodes, 1);
  47. matrix_display(bmat, rank, nodes);
  48. dw_cholesky(bmat, size/nblocks, rank, nodes, &timing, &flops);
  49. #ifndef STARPU_SIMGRID
  50. matrix_display(bmat, rank, nodes);
  51. if (check && rank == 0)
  52. dw_cholesky_check_computation(bmat, rank, nodes, &correctness, &flops, 0.001);
  53. #endif
  54. matrix_free(&bmat, rank, nodes, 1);
  55. starpu_cublas_shutdown();
  56. starpu_mpi_shutdown();
  57. #ifndef STARPU_SIMGRID
  58. if (check && rank == 0)
  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. }