AccFFT
accfft_common.cpp
Go to the documentation of this file.
1 
4 /*
5  * Copyright (c) 2014-2015, Amir Gholami, George Biros
6  * All rights reserved.
7  * This file is part of AccFFT library.
8  *
9  * AccFFT is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * AccFFT is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with AccFFT. If not, see <http://www.gnu.org/licenses/>.
21  *
22 */
23 
24 #include <mpi.h>
25 #include <omp.h>
26 #include <iostream>
27 #include <cmath>
28 #include <math.h>
29 #include "accfft_common.h"
30 
35 void* accfft_alloc(ptrdiff_t size){
36  void * ptr=fftw_malloc(size);
37  return ptr;
38 }
43 void accfft_free(void * ptr){
44  fftw_free(ptr);
45  return;
46 }
56 void accfft_create_comm(MPI_Comm in_comm,int * c_dims,MPI_Comm *c_comm){
57 
58  int nprocs, procid;
59  MPI_Comm_rank(in_comm, &procid);
60  MPI_Comm_size(in_comm, &nprocs);
61 
62  if(c_dims[0]*c_dims[1]!=nprocs){
63  PCOUT<<"ERROR c_dims!=nprocs --> "<<c_dims[0]<<"*"<<c_dims[1]<<" !="<<nprocs<<std::endl;
64  c_dims[0]=0;c_dims[1]=0;
65  MPI_Dims_create(nprocs,2, c_dims);
66  //std::swap(c_dims[0],c_dims[1]);
67  PCOUT<<"Switching to c_dims_0="<< c_dims[0]<<" , c_dims_1="<<c_dims[1]<<std::endl;
68  }
69 
70  /* Create Cartesian Communicator */
71  int period[2], reorder;
72  int coord[2];
73  period[0]=0; period[1]=0;
74  reorder=1;
75 
76  MPI_Cart_create(in_comm, 2, c_dims, period, reorder, c_comm);
77  //PCOUT<<"dim[0]= "<<c_dims[0]<<" dim[1]= "<<c_dims[1]<<std::endl;
78 
79  //MPI_Cart_coords(c_comm, procid, 2, coord);
80 
81  return;
82 
83 }
89  return 0;
90 }
void accfft_create_comm(MPI_Comm in_comm, int *c_dims, MPI_Comm *c_comm)
int accfft_init()
void * accfft_alloc(ptrdiff_t size)
void accfft_free(void *ptr)