Esempio n. 1
0
File: mxm.c Progetto: akva2/tma4280
int main(int argc, char **argv )
{
  int size, rank;
  long i, j, l, m, n, k, iter, loop;
  Matrix a, b, c;
  double t1, t2, dt, dt1, r;

  init_app(argc, argv, &rank, &size);

  if( argc < 3 ) {
    if (rank == 0)
      printf("need atleast 2 arguments - n & flag\n");
    close_app();
    return 1;
  }

  k = m = n = atoi(argv[1]);
  a = createMatrix(m, k);
  b = createMatrix(k, n);
  c = createMatrix(m, n);

  for (i=0; i  < m; i++) {
    for (l=0; l < k; l++) {
      a->data[l][i] = i+1.0;
    }
  }
  for (l=0; l  < k; l++) {
    for (j=0; j < n; j++) {
      b->data[j][l] = j+1.0;
    }
  }
  loop = 5;

  t1 = WallTime(); 
  for (iter=0; iter < loop; iter++)
    mxm (a,b,c,atoi(argv[2]));
  t2 = WallTime();

  dt = t2 - t1;
  dt1 = dt/(m*2*k*n);
  dt1 = dt1/loop;
  r    = 1.e-6/dt1;
  printf (" matrix-matrix : (m,k,n)= (%ld,%ld,%ld)    dt= %lf (s) dt1= %le r= %lf\n" ,m, k, n, dt, dt1, r);

  freeMatrix(a);
  freeMatrix(b);
  freeMatrix(c);

  close_app();

  return 0;
}
Esempio n. 2
0
int main(int argc, char** argv)
{
  int rank, size;
  init_app(argc, argv, &rank, &size);

  if (argc < 3) {
    printf("need two parameters, the matrix size and the number of vectors\n");
    close_app();
    return 1;
  }
  int N=atoi(argv[1]);
  int K=atoi(argv[2]);

  Matrix A = createMatrix(N,N);
  // identity matrix
  for (int i=0;i<N;++i)
    A->data[i][i] = 1.0;
  
  int *displ, *cols;
  splitVector(K, size, &cols, &displ);
  Matrix v = createMatrix(N,cols[rank]);
  // fill with column number
  for (int i=0;i<cols[rank];++i)
    for (int j=0;j<N;++j)
      v->data[i][j] = i+displ[rank];

  double time = WallTime();
  double sum = dosum(A,v);

  if (rank == 0) {
    printf("sum: %f\n", sum);
    printf("elapsed: %f\n", WallTime()-time);
  }

  char s[128];
  sprintf(s,"vec-%i.asc", rank);
  saveVectorSerial(s, v->as_vec);
  sprintf(s,"mat-%i.asc", rank);
  saveMatrixSerial(s, v);

  sprintf(s,"vec.asc");
  saveVectorMPI(s, v->as_vec);

  freeMatrix(v);
  freeMatrix(A);
  free(displ);
  free(cols);

  close_app();
  return 0;
}
Esempio n. 3
0
int main(int argc, char** argv)
{
  int rank, size;
  init_app(argc, argv, &rank, &size);

  if (argc < 2) {
    printf("usage: %s <N> [L]\n",argv[0]);
    close_app();
    return 1;
  }

  /* the total number of grid points in each spatial direction is (N+1) */
  /* the total number of degrees-of-freedom in each spatial direction is (N-1) */
  int N  = atoi(argv[1]);
  int M  = N-1;
  double L=1.0;
  if (argc > 2)
    L = atof(argv[2]);

  double h = L/N;
  poisson_info_t ctx;
  ctx.A = createPoisson1D(M);

  Vector grid = createVector(M);
  for (int i=0;i<M;++i)
    grid->data[i] = (i+1)*h;

  Matrix u = createMatrix(M, M);
  evalMesh(u->as_vec, grid, grid, poisson_source);
  scaleVector(u->as_vec, h*h);

  double time = WallTime();
  cg(evaluate, u, 1.e-6, &ctx);

  evalMesh2(u->as_vec, grid, grid, exact_solution, -1.0);
  double max = maxNorm(u->as_vec);

  if (rank == 0) {
    printf("elapsed: %f\n", WallTime()-time);
    printf("max: %f\n", max);
  }

  freeMatrix(u);
  freeVector(grid);
  freeMatrix(ctx.A);

  close_app();
  return 0;
}
Esempio n. 4
0
int main(int argc, char** argv)
{
  int i, j, N, K;
  Matrix A, v;
  double time, sum;
  int rank, size;
  int *displ, *cols;

  init_app(argc, argv, &rank, &size);

  if (argc < 3) {
    printf("need two parameters, the matrix size and the number of vectors\n");
    close_app();
    return 1;
  }
  N=atoi(argv[1]);
  K=atoi(argv[2]);

  A = createMatrix(N,N);
  // identity matrix
  for (i=0;i<N;++i)
    A->data[i][i] = 1.0;
  
  splitVector(K, size, &cols, &displ);
  v = createMatrix(N,cols[rank]);
  // fill with column number
  for (i=0;i<cols[rank];++i)
    for (j=0;j<N;++j)
      v->data[i][j] = i+displ[rank];

  time = WallTime();
  sum = dosum(A,v);

  if (rank == 0) {
    printf("sum: %f\n", sum);
    printf("elapsed: %f\n", WallTime()-time);
  }

  freeMatrix(v);
  freeMatrix(A);
  free(displ);
  free(cols);

  close_app();
  return 0;
}
Esempio n. 5
0
int main(int argc, char** argv)
{
  int rank, size;
  init_app(argc, argv, &rank, &size);

  if (argc < 3) {
    printf("need two parameters, the matrix size and the number of vectors\n");
    close_app();
    return 1;
  }
  int N=atoi(argv[1]);
  int K=atoi(argv[2]);

  int *displ, *cols;
  splitVector(K, size, &cols, &displ);

  Matrix A = createMatrixMPI(N, -1, N, N, &WorldComm);
  // identity matrix
  for (int i=0;i<A->cols;++i)
    A->data[i][i] = 1.0;
  
  Matrix v = createMatrixMPI(-1, K, N, K, &WorldComm);
  // fill with column number
  for (int i=0;i<v->rows;++i)
    for (int j=0;j<v->cols;++j)
      v->data[j][i] = j;

  double time = WallTime();
  double sum = dosum(A,v);

  if (rank == 0) {
    printf("sum: %f\n", sum);
    printf("elapsed: %f\n", WallTime()-time);
  }

  freeMatrix(v);
  freeMatrix(A);
  close_app();
  return 0;
}
Esempio n. 6
0
File: mxm.c Progetto: akva2/tma4280
void mxm (Matrix a, Matrix b, Matrix c, int flag)
{
  if (flag == 0)
    mxm_std(a, b, c); 
  else if (flag == 1 && a->cols == 10)
    mxm_unr(a, b, c); 
  else if (flag == 2)
    mxm_blas(a, b, c);
  else {
    printf (" Incorrect setting of variable flag in mxm \n");
    close_app();
    exit(1);
  }
}
Esempio n. 7
0
File: main.c Progetto: TheBB/TMA4280
int main(int argc, char **argv)
{
    int rank, size;
    init_app(argc, argv, &rank, &size);

    Vector vec = createVectorMPI(30, &WorldComm, 1);

    if (rank == 0) {
        for (size_t i = 0; i < size; i++) {
            printf(">> Proc %d owns [%d,%d]\n", i, vec->displ[i],
                   vec->displ[i] + vec->sizes[i] - 1);
        }
    }

    close_app();
    return 0;
}
Esempio n. 8
0
int main(int argc, char** argv)
{
  int i, j, N, flag;
  Vector grid;
  Matrix b, e;
  double time, sum, h;
  int rank, size;
  int mpi_top_coords[2];
  int mpi_top_sizes[2];

  init_app(argc, argv, &rank, &size);

  N=atoi(argv[1]);

  // setup topology
  mpi_top_sizes[0] = mpi_top_sizes[1] = 0;
  MPI_Dims_create(size, 2, mpi_top_sizes);
  int periodic[2] = {0, 0};
  MPI_Comm comm;
  MPI_Cart_create(MPI_COMM_WORLD, 2, mpi_top_sizes, periodic, 0, &comm);
  MPI_Cart_coords(comm, rank, 2, mpi_top_coords);

  int* size1;
  int* displ1;
  int* size2;
  int* displ2;
  splitVector(N, mpi_top_sizes[0], &size1, &displ1);
  splitVector(N, mpi_top_sizes[1], &size2, &displ2);

  b = createMatrix(size1[mpi_top_coords[0]], size2[mpi_top_coords[1]]);
  for (j=0;j<b->cols;++j)
    for(i=0;i<b->rows;++i)
      b->data[j][i] = (j+displ2[mpi_top_coords[1]])*N+1+(i+displ1[mpi_top_coords[0]]);
  b->glob_rows = N;
  b->glob_cols = N;
  b->as_vec->comm = &comm;

  saveMatrixMPI(b, "meh.asc");

  freeMatrix(b);
  MPI_Comm_free(&comm);

  close_app();
  return 0;
}
Esempio n. 9
0
void *handle_connections()
{
  L("\nWaiting for a connection\n");
  struct sockaddr_in from;
  int fromlen = sizeof(struct sockaddr_in);
  int n;

  while (1) {
    n = recvfrom(hServerSocket,pBuffer,BUFFER_SIZE,0,(struct sockaddr *)&from,&fromlen);
    if (n < 0) perror("recvfrom");

    //L("Recebido: %s\n",pBuffer);

    if (strstr(pBuffer,"~PING|")!=NULL)
    {
      char *resp="~PONG|";
      n = sendto(hServerSocket,resp,strlen(resp),
                 0,(struct sockaddr *)&from,fromlen);
      if (n  < 0) perror("sendto");
    }
    else if (strstr(pBuffer,"~KILL|")!=NULL)
    close_app();
  }
}
int main(int argc, char **argv)
{
  //pipe signals
  signal(SIGINT, close_app);
  signal(SIGKILL, close_app);
  signal(SIGILL, close_app);
  long usec;

  if(argc > 1) {
    int i=1;
    int r;
    while(i < argc) {
      if(*argv[i] == '-') {
        switch(*(argv[i] + 1)) {
          case 'h':
          printUsage(argv);
          exit(0); 
          break;
          case 'p': 
          i++; 
          strcpy(VNC_PASSWORD,argv[i]);
          break;
          case 'f': 
          i++; 
          FB_setDevice(argv[i]);
          break;
          case 'z': 
          i++; 
          display_rotate_180=1;
          break;
          case 'P': 
          i++; 
          VNC_PORT=atoi(argv[i]);
          break;
          case 'r':
          i++; 
          r = atoi(argv[i]);
          if (r==0 || r==90 || r==180 || r==270)
          rotation = r;
          L("rotating to %d degrees\n",rotation);
          break;
          case 's':
          i++;
          r=atoi(argv[i]); 
          if (r >= 1 && r <= 150)
          scaling = r;
          else 
          scaling = 100;
          L("scaling to %d%%\n",scaling);
          break;
          case 'R':
          i++;
          extractReverseHostPort(argv[i]);
          break;
          case 'm':
          i++;
          if (!strcmp(argv[i],"adb")){
            method = ADB;
            L("ADB display grabber selected\n");
          } else if (!strcmp(argv[i],"fb")) {
            method = FRAMEBUFFER;
            L("Framebuffer display grabber selected\n");
          } else if (!strcmp(argv[i],"gralloc")) {
            method = GRALLOC;
            L("Gralloc display grabber selected\n");
          } else if (!strcmp(argv[i],"flinger")) {
            method = FLINGER;
            L("Flinger display grabber selected\n");
          } else {
            L("Grab method \"%s\" not found, sticking with auto-detection.\n",argv[i]);
          }
          break;
          }
        }
      i++;
      }
    }

    L("Initializing grabber method...\n");
    initGrabberMethod();

    L("Initializing virtual keyboard and touch device...\n");
    initInput(); 

    L("Initializing VNC server:\n");
    L("	width:  %d\n", (int)screenformat.width);
    L("	height: %d\n", (int)screenformat.height);
    L("	bpp:    %d\n", (int)screenformat.bitsPerPixel);
    L("	port:   %d\n", (int)VNC_PORT);


    L("Colourmap_rgba=%d:%d:%d:%d    lenght=%d:%d:%d:%d\n", screenformat.redShift, screenformat.greenShift, screenformat.blueShift,screenformat.alphaShift,
      screenformat.redMax,screenformat.greenMax,screenformat.blueMax,screenformat.alphaMax);  

    initVncServer(argc, argv);

    bindIPCserver();
    sendServerStarted();

    if (rhost) {
      rfbClientPtr cl;
      cl = rfbReverseConnection(vncscr, rhost, rport);
      if (cl == NULL) {
        char *str=malloc(255*sizeof(char));
        sprintf(str,"~SHOW|Couldn't connect to remote host:\n%s\n",rhost);

        L("Couldn't connect to remote host: %s\n",rhost);
        sendMsgToGui(str);
        free(str);
      } else {
        cl->onHold = FALSE;
        rfbStartOnHoldClient(cl);
      }
    }


    while (1) {
        usec=(vncscr->deferUpdateTime+standby)*1000;
        //clock_t start = clock();
        rfbProcessEvents(vncscr,usec);
      
      if (idle)
        standby+=2;
      else
        standby=2;
      
      if (vncscr->clientHead == NULL)
      {
        idle=1;
        standby=50;
        continue;
      }

      update_screen(); 
      //printf ( "%f\n", ( (double)clock() - start )*1000 / CLOCKS_PER_SEC );
    }
    close_app();
}
void initVncServer(int argc, char **argv)
{ 

  vncbuf = calloc(screenformat.width * screenformat.height, screenformat.bitsPerPixel/CHAR_BIT);
  cmpbuf = calloc(screenformat.width * screenformat.height, screenformat.bitsPerPixel/CHAR_BIT);

  assert(vncbuf != NULL);
  assert(cmpbuf != NULL);

  if (rotation==0 || rotation==180) 
  vncscr = rfbGetScreen(&argc, argv, screenformat.width , screenformat.height, 0 /* not used */ , 3,  screenformat.bitsPerPixel/CHAR_BIT);
  else
  vncscr = rfbGetScreen(&argc, argv, screenformat.height, screenformat.width, 0 /* not used */ , 3,  screenformat.bitsPerPixel/CHAR_BIT);

  assert(vncscr != NULL);

  vncscr->desktopName = "Android";
  vncscr->frameBuffer =(char *)vncbuf;
  vncscr->port = VNC_PORT;
  vncscr->kbdAddEvent = keyEvent;
  vncscr->ptrAddEvent = ptrEvent;
  vncscr->newClientHook = (rfbNewClientHookPtr)clientHook;
  vncscr->setXCutText = CutText;

  if (strcmp(VNC_PASSWORD,"")!=0)
  {
    char **passwords = (char **)malloc(2 * sizeof(char **));
    passwords[0] = VNC_PASSWORD;
    passwords[1] = NULL;
    vncscr->authPasswdData = passwords;
    vncscr->passwordCheck = rfbCheckPasswordByList;
  } 

  vncscr->httpDir = "webclients/";
//  vncscr->httpEnableProxyConnect = TRUE;
  vncscr->sslcertfile = "self.pem";

  vncscr->serverFormat.redShift = screenformat.redShift;
  vncscr->serverFormat.greenShift = screenformat.greenShift;
  vncscr->serverFormat.blueShift = screenformat.blueShift;

  vncscr->serverFormat.redMax = (( 1 << screenformat.redMax) -1);
  vncscr->serverFormat.greenMax = (( 1 << screenformat.greenMax) -1);
  vncscr->serverFormat.blueMax = (( 1 << screenformat.blueMax) -1);

  vncscr->serverFormat.trueColour = TRUE; 
  vncscr->serverFormat.bitsPerPixel = screenformat.bitsPerPixel;

  vncscr->alwaysShared = TRUE;
  vncscr->handleEventsEagerly = TRUE;
  vncscr->deferUpdateTime = 5;

  rfbInitServer(vncscr);

    //assign update_screen depending on bpp
    if (vncscr->serverFormat.bitsPerPixel == 32)
    update_screen=&CONCAT2E(update_screen_,32);
    else if (vncscr->serverFormat.bitsPerPixel == 16)
    update_screen=&CONCAT2E(update_screen_,16);
    else if (vncscr->serverFormat.bitsPerPixel == 8)
    update_screen=&CONCAT2E(update_screen_,8);
    else {
      L("Unsupported pixel depth: %d\n",
        vncscr->serverFormat.bitsPerPixel);

      sendMsgToGui("~SHOW|Unsupported pixel depth, please send bug report.\n");
      close_app();
      exit(-1);
    }

    /* Mark as dirty since we haven't sent any updates at all yet. */
    rfbMarkRectAsModified(vncscr, 0, 0, vncscr->width, vncscr->height);
    }
Esempio n. 12
0
int main(int argc, char** argv)
{
  int i, j, N, flag;
  Matrix A=NULL, Q=NULL;
  Vector b, grid, e, lambda=NULL;
  double time, sum, h, tol=1e-6;
  int rank, size;
  int mpi_top_coords;
  int mpi_top_sizes;

  init_app(argc, argv, &rank, &size);

  if (argc < 3) {
    printf("need two parameters, N and flag [and tolerance]\n");
    printf(" - N is the problem size (in each direction\n");
    printf(" - flag = 1  -> Matrix-free Gauss-Jacobi iterations\n");
    printf(" - flag = 2  -> Matrix-free red-black Gauss-Seidel iterations\n");
    printf(" - flag = 3  -> Matrix-free CG iterations\n");
    printf(" - flag = 4  -> Matrix-free additive schwarz preconditioned+Cholesky CG iterations\n");
    printf(" - flag = 5  -> Matrix-free additive schwarz preconditioned+CG CG iterations\n");
    return 1;
  }
  N=atoi(argv[1]);
  flag=atoi(argv[2]);
  if (argc > 3)
    tol=atof(argv[3]);

  if (N < 0) {
    if (rank == 0)
      printf("invalid problem size given\n");
    close_app();
    return 2;
  }

  if (flag < 0 || flag > 5) {
    if (rank == 0)
      printf("invalid flag given\n");
    close_app();
    return 3;
  }

  if (flag == 2 && (N-1)%2 != 0 && ((N-1)/size) % 2 != 0) {
    if (rank == 0)
      printf("need an even size (per process) for red-black iterations\n");
    close_app();
    return 4;
  }

  // setup topology
  mpi_top_coords = 0;
  mpi_top_sizes = 0;
  MPI_Dims_create(size, 1, &mpi_top_sizes);
  int periodic = 0;
  MPI_Comm comm;
  MPI_Cart_create(MPI_COMM_WORLD, 1, &mpi_top_sizes, &periodic, 0, &comm);
  MPI_Cart_coords(comm, rank, 1, &mpi_top_coords);

  b = createVectorMPI(N+1, &comm, 1, 1);
  e = createVectorMPI(N+1, &comm, 1, 1);

  grid = equidistantMesh(0.0, 1.0, N);
  h = 1.0/N;

  evalMeshDispl(b, grid, source);
  scaleVector(b, pow(h, 2));
  evalMeshDispl(e, grid, exact);
  axpy(b, e, alpha);
  b->data[0] = b->data[b->len-1] = 0.0;

  if (flag == 4) {
    int size = b->len;
    if (b->comm_rank == 0)
      size--;
    if (b->comm_rank == b->comm_size-1)
      size--;
    A1D = createMatrix(size, size);
    A1Dfactored = 0;
    diag(A1D, -1, -1.0);
    diag(A1D, 0, 2.0+alpha);
    diag(A1D, 1, -1.0);
  }

  int its=-1;
  char method[128];
  time = WallTime();
  if (flag == 1) {
    its=GaussJacobiPoisson1D(b, tol, 1000000);
    sprintf(method,"Gauss-Jacobi");
  }
  if (flag == 2) {
    its=GaussSeidelPoisson1Drb(b, tol, 1000000);
    sprintf(method,"Gauss-Seidel");
  }
  if (flag == 3) {
    its=cgMatrixFree(Poisson1D, b, tol);
    sprintf(method,"CG");
  }
  if (flag == 4 || flag == 5) {
    its=pcgMatrixFree(Poisson1D, Poisson1DPre, b, tol);
    sprintf(method,"PCG");
  }
  if (rank == 0) {
    printf("%s used %i iterations\n", method, its);
    printf("elapsed: %f\n", WallTime()-time);
  }

  evalMeshDispl(e, grid, exact);
  axpy(b,e,-1.0);
  b->data[0] = b->data[b->len-1] = 0.0;

  h = maxNorm(b);
  if (rank == 0)
    printf("max error: %e\n", h);
  
  if (A)
    freeMatrix(A);
  if (Q)
    freeMatrix(Q);
  freeVector(grid);
  freeVector(b);
  freeVector(e);
  if (lambda)
    freeVector(lambda);
  if (A1D)
    freeMatrix(A1D);

  MPI_Comm_free(&comm);

  close_app();
  return 0;
}
Esempio n. 13
0
int main(int argc, char** argv)
{
  int rank, size;
  init_app(argc, argv, &rank, &size);

  if (argc < 2) {
    printf("usage: %s <N> [L]\n",argv[0]);
    close_app();
    return 1;
  }

  /* the total number of grid points in each spatial direction is (N+1) */
  /* the total number of degrees-of-freedom in each spatial direction is (N-1) */
  int N  = atoi(argv[1]);
  int M  = N-1;
  double L=1;
  if (argc > 2)
    L = atof(argv[2]);

  double h = L/N;
  Vector lambda = createEigenValues(M);

  Vector grid = createVector(M);
  for (int i=0;i<M;++i)
    grid->data[i] = (i+1)*h;

  Matrix u = createMatrix(M, M);
  Matrix ut = createMatrix(M, M);
  evalMesh(u->as_vec, grid, grid, poisson_source);
  scaleVector(u->as_vec, h*h);

  int NN = 4*N;
  Vector z    = createVector(NN);

  double time = WallTime();

  for (int j=0; j < M; j++)
    fst(u->data[j], &N, z->data, &NN);

  transposeMatrix(ut, u);

  for (int i=0; i < M; i++)
    fstinv(ut->data[i], &N, z->data, &NN);

  for (int j=0; j < M; j++)
    for (int i=0; i < M; i++)
      ut->data[j][i] /= lambda->data[i]+lambda->data[j];

  for (int i=0; i < M; i++)
    fst(ut->data[i], &N, z->data, &NN);

  transposeMatrix(u, ut);

  for (int j=0; j < M; j++)
    fstinv(u->data[j], &N, z->data, &NN);

  evalMesh2(u->as_vec, grid, grid, exact_solution, -1.0);
  double max = maxNorm(u->as_vec);

  if (rank == 0) {
    printf("elapsed: %f\n", WallTime()-time);
    printf("max: %f\n", max);
  }

  freeMatrix(u);
  freeMatrix(ut);
  freeVector(grid);
  freeVector(z);
  freeVector(lambda);

  close_app();
  return 0;
}
Esempio n. 14
0
int main(int argc, char** argv)
{
  int rank, size;
  init_app(argc, argv, &rank, &size);

  if (argc < 2) {
    printf("usage: %s <N> [L]\n",argv[0]);
    close_app();
    return 1;
  }

  /* the total number of grid points in each spatial direction is (N+1) */
  /* the total number of degrees-of-freedom in each spatial direction is (N-1) */
  int N  = atoi(argv[1]);
  int M  = N-1;
  double L=1.0;
  if (argc > 2)
    L = atof(argv[2]);

  double h = L/N;

  Vector grid = createVector(M);
  for (int i=0;i<M;++i)
    grid->data[i] = (i+1)*h;

  int coords[2] = {0};
  int sizes[2] = {1};
#ifdef HAVE_MPI
  sizes[0] = sizes[1] = 0;
  MPI_Dims_create(size,2,sizes);
  int periodic[2];
  periodic[0] = periodic[1] = 0;
  MPI_Comm comm;
  MPI_Cart_create(MPI_COMM_WORLD,2,sizes,periodic,0,&comm);
  MPI_Cart_coords(comm,rank,2,coords);
#endif

  int* len[2];
  int* displ[2];
  splitVector(M, sizes[0], &len[0], &displ[0]);
  splitVector(M, sizes[1], &len[1], &displ[1]);

#ifdef HAVE_MPI
  Matrix u = createMatrixMPI(len[0][coords[0]]+2, len[1][coords[1]]+2, M, M, &comm);
#else
  Matrix u = createMatrix(M+2, M+2);
#endif
  evalMeshDispl(u, grid, grid, poisson_source,
                displ[0][coords[0]], displ[1][coords[1]]);
  scaleVector(u->as_vec, h*h);

  double time = WallTime();
  GS(u, 1e-6, 5000);

  evalMesh2Displ(u, grid, grid, exact_solution, -1.0,
                 displ[0][coords[0]], displ[1][coords[1]]);
  double max = maxNorm(u->as_vec);

  if (rank == 0) {
    printf("elapsed: %f\n", WallTime()-time);
    printf("max: %f\n", max);
  }

  freeMatrix(u);
  freeVector(grid);
  for (int i=0;i<2;++i) {
    free(len[i]);
    free(displ[i]);
  }

  close_app();
  return 0;
}