123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- #include <starpu_mpi.h>
- #include "mpi_cholesky.h"
- #include "mpi_cholesky_models.h"
- #include "mpi_cholesky_codelets.h"
- int my_distrib(int x, int y, int nb_nodes)
- {
-
- return (x%dblockx)+(y%dblocky)*dblockx;
- }
- int main(int argc, char **argv)
- {
-
- float ***bmat;
- int rank, nodes, ret;
- parse_args(argc, argv);
- ret = starpu_init(NULL);
- STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
- starpu_mpi_initialize_extended(&rank, &nodes);
- starpu_helper_cublas_init();
- if (dblockx == -1 || dblocky == -1)
- {
- int factor;
- dblockx = nodes;
- dblocky = 1;
- for(factor=sqrt(nodes) ; factor>1 ; factor--)
- {
- if (nodes % factor == 0)
- {
- dblockx = nodes/factor;
- dblocky = factor;
- break;
- }
- }
- }
- unsigned i,j,x,y;
- bmat = malloc(nblocks * sizeof(float *));
- for(x=0 ; x<nblocks ; x++)
- {
- bmat[x] = malloc(nblocks * sizeof(float *));
- for(y=0 ; y<nblocks ; y++)
- {
- int mpi_rank = my_distrib(x, y, nodes);
- if (mpi_rank == rank)
- {
- starpu_malloc((void **)&bmat[x][y], BLOCKSIZE*BLOCKSIZE*sizeof(float));
- for (i = 0; i < BLOCKSIZE; i++)
- {
- for (j = 0; j < BLOCKSIZE; j++)
- {
- 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);
-
- }
- }
- }
- }
- }
- double timing, flops;
- dw_cholesky(bmat, size, size/nblocks, nblocks, rank, nodes, &timing, &flops);
- starpu_mpi_shutdown();
- if (rank == 0)
- {
- fprintf(stdout, "Computation time (in ms): %2.2f\n", timing/1000);
- fprintf(stdout, "Synthetic GFlops : %2.2f\n", (flops/timing/1000.0f));
- }
- for(x=0 ; x<nblocks ; x++)
- {
- for(y=0 ; y<nblocks ; y++)
- {
- int mpi_rank = my_distrib(x, y, nodes);
- if (mpi_rank == rank)
- {
- starpu_free((void *)bmat[x][y]);
- }
- }
- free(bmat[x]);
- }
- free(bmat);
- starpu_helper_cublas_shutdown();
- starpu_shutdown();
- return 0;
- }
|