LCOV - code coverage report
Current view: top level - mpi/examples/cholesky - mpi_cholesky_distributed.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 40 44 90.9 %
Date: 2012-12-09 Functions: 2 2 100.0 %
Branches: 24 32 75.0 %

           Branch data     Line data    Source code
       1                 :            : /* StarPU --- Runtime system for heterogeneous multicore architectures.
       2                 :            :  *
       3                 :            :  * Copyright (C) 2009-2011  Université de Bordeaux 1
       4                 :            :  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
       5                 :            :  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
       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                 :            : 
      19                 :            : #include <starpu_mpi.h>
      20                 :            : #include "mpi_cholesky.h"
      21                 :            : #include "mpi_cholesky_models.h"
      22                 :            : #include "mpi_cholesky_codelets.h"
      23                 :            : 
      24                 :            : /* Returns the MPI node number where data indexes index is */
      25                 :       1536 : int my_distrib(int x, int y, int nb_nodes)
      26                 :            : {
      27                 :            :         //return (x+y) % nb_nodes;
      28                 :       1536 :         return (x%dblockx)+(y%dblocky)*dblockx;
      29                 :            : }
      30                 :            : 
      31                 :          2 : int main(int argc, char **argv)
      32                 :            : {
      33                 :            :         /* create a simple definite positive symetric matrix example
      34                 :            :          *
      35                 :            :          *      Hilbert matrix : h(i,j) = 1/(i+j+1)
      36                 :            :          * */
      37                 :            : 
      38                 :            :         float ***bmat;
      39                 :            :         int rank, nodes, ret;
      40                 :            : 
      41                 :          2 :         parse_args(argc, argv);
      42                 :            : 
      43                 :          2 :         ret = starpu_init(NULL);
      44         [ -  + ]:          2 :         STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
      45                 :          2 :         ret = starpu_mpi_init(&argc, &argv, 1);
      46         [ -  + ]:          2 :         STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
      47                 :          2 :         MPI_Comm_rank(MPI_COMM_WORLD, &rank);
      48                 :          2 :         MPI_Comm_size(MPI_COMM_WORLD, &nodes);
      49                 :          2 :         starpu_helper_cublas_init();
      50                 :            : 
      51 [ -  + ][ #  # ]:          2 :         if (dblockx == -1 || dblocky == -1)
      52                 :            :         {
      53                 :            :                 int factor;
      54                 :          2 :                 dblockx = nodes;
      55                 :          2 :                 dblocky = 1;
      56         [ -  + ]:          2 :                 for(factor=sqrt(nodes) ; factor>1 ; factor--)
      57                 :            :                 {
      58         [ #  # ]:          0 :                         if (nodes % factor == 0)
      59                 :            :                         {
      60                 :          0 :                                 dblockx = nodes/factor;
      61                 :          0 :                                 dblocky = factor;
      62                 :          0 :                                 break;
      63                 :            :                         }
      64                 :            :                 }
      65                 :            :         }
      66                 :            : 
      67                 :            :         unsigned i,j,x,y;
      68                 :          2 :         bmat = malloc(nblocks * sizeof(float *));
      69         [ +  + ]:         34 :         for(x=0 ; x<nblocks ; x++)
      70                 :            :         {
      71                 :         32 :                 bmat[x] = malloc(nblocks * sizeof(float *));
      72         [ +  + ]:        544 :                 for(y=0 ; y<nblocks ; y++)
      73                 :            :                 {
      74                 :        512 :                         int mpi_rank = my_distrib(x, y, nodes);
      75         [ +  + ]:        512 :                         if (mpi_rank == rank)
      76                 :            :                         {
      77                 :        256 :                                 starpu_malloc((void **)&bmat[x][y], BLOCKSIZE*BLOCKSIZE*sizeof(float));
      78         [ +  + ]:      65792 :                                 for (i = 0; i < BLOCKSIZE; i++)
      79                 :            :                                 {
      80         [ +  + ]:   16842752 :                                         for (j = 0; j < BLOCKSIZE; j++)
      81                 :            :                                         {
      82         [ +  + ]:   16777216 :                                                 bmat[x][y][j +i*BLOCKSIZE] = (1.0f/(1.0f+(i+(x*BLOCKSIZE)+j+(y*BLOCKSIZE)))) + ((i+(x*BLOCKSIZE) == j+(y*BLOCKSIZE))?1.0f*size:0.0f);
      83                 :            :                                                 //mat[j +i*size] = ((i == j)?1.0f*size:0.0f);
      84                 :            :                                         }
      85                 :            :                                 }
      86                 :            :                         }
      87                 :            :                 }
      88                 :            :         }
      89                 :            : 
      90                 :            :         double timing, flops;
      91                 :          2 :         dw_cholesky(bmat, size, size/nblocks, nblocks, rank, nodes, &timing, &flops);
      92                 :            : 
      93                 :          2 :         starpu_mpi_shutdown();
      94                 :            : 
      95         [ +  + ]:          2 :         if (rank == 0)
      96                 :            :         {
      97                 :          1 :                 fprintf(stdout, "Computation time (in ms): %2.2f\n", timing/1000);
      98                 :          1 :                 fprintf(stdout, "Synthetic GFlops : %2.2f\n", (flops/timing/1000.0f));
      99                 :            :         }
     100                 :            : 
     101                 :            : 
     102         [ +  + ]:         34 :         for(x=0 ; x<nblocks ; x++)
     103                 :            :         {
     104         [ +  + ]:        544 :                 for(y=0 ; y<nblocks ; y++)
     105                 :            :                 {
     106                 :        512 :                         int mpi_rank = my_distrib(x, y, nodes);
     107         [ +  + ]:        512 :                         if (mpi_rank == rank)
     108                 :            :                         {
     109                 :        256 :                                 starpu_free((void *)bmat[x][y]);
     110                 :            :                         }
     111                 :            :                 }
     112                 :         32 :                 free(bmat[x]);
     113                 :            :         }
     114                 :          2 :         free(bmat);
     115                 :            : 
     116                 :          2 :         starpu_helper_cublas_shutdown();
     117                 :          2 :         starpu_shutdown();
     118                 :            : 
     119                 :          2 :         return 0;
     120                 :            : }

Generated by: LCOV version 1.9