// MPS_conv_mpi.cc // Author: Mario J. Bencomo // last modified: 11/10/16 #include "MPS_conv.hh" //#define VERBOSE_MJB #ifdef IWAVE_USE_MPI namespace TSOpt{ //----------------------------------------------------------------------// void MPS_conv_kern_MPI( vector s_pos, int MPS_dim, int MPS_idx, string x_file, vector y_files, vector k_files ){ //----------------------------------------------------------------------// try{ #ifdef VERBOSE_MJB if( retrieveGlobalRank()==0 ){ cerr << "*************************************************\n" << " Inside MPS_conv_kern_MPI\n" << "*************************************************\n\n"; cerr << "x file = " << x_file << "\n" << "y files = "; print_vec(y_files); cerr << "k files = "; print_vec(k_files); cerr << "MPS_dim = " << MPS_dim << "\n" << "MPS_idx = " << MPS_idx << "\n"; } MPI_Barrier(retrieveGlobalComm()); #endif FILE *fp_x, *fp_y, *fp_k; segy tr_x, tr_y, tr_k; //MPI variables int RANK = retrieveGlobalRank(); int rank = retrieveRank(); int SIZE = retrieveGlobalSize(); int size = retrieveSize(); int N_gr = retrieveNumGroups(); int grID = retrieveGroupID(); MPI_Comm COMM = retrieveGlobalComm(); MPI_Comm comm = retrieveComm(); int N_src = s_pos.size(); //total number of sources int N_src_loc; //number of sources at current process int NS_x, NS_y, NS_k; //total number of time sample points per trace int NTR_x, NTR_y, NTR_k; //total number of traces int NTR_x_loc, NTR_y_loc, NTR_k_loc; //total number of traces at current process int NTPS_x, NTPS_y, NTPS_k; //number of traces per source float dt_x, dt_y, dt_k; float delrt_x, delrt_y, delrt_k; //global arrays float * x_arr = NULL; float * y_arr = NULL; float * k_arr = NULL; //local arrays float * x_arr_loc = NULL; float * y_arr_loc = NULL; float * k_arr_loc = NULL; //other arrays int *NSPG = NULL; //array containing number of sources per group, for each group int *snd_sz = NULL; //array containing size of data to be sent via scatterv/gatherv int *offsets = NULL; //array of offsets for data to be sent via scatterv/gatherv fpos_t pos_y; if( MPS_idx<0 || MPS_idx>=MPS_dim ){ RVLException e; e << "MPS_idx="<< MPS_idx << " out of bounds!\n"; throw e; } //setting up number of sources per group (NSPG) array NSPG = new int[N_gr]; for( int g=0; g s_pos, int MPS_dim, int MPS_idx, string x_file, vector y_files, vector k_files ){ //----------------------------------------------------------------------// try{ #ifdef VERBOSE_MJB MPI_Barrier(retrieveGlobalComm()); if( retrieveGlobalRank()==0 ){ cerr << "*************************************************\n" << " Inside MPS_corr_kern_MPI\n" << "*************************************************\n\n"; cerr << "x file = " << x_file << "\n" << "y files = "; print_vec(y_files); cerr << "k files = "; print_vec(k_files); cerr << "MPS_dim = " << MPS_dim << "\n" << "MPS_idx = " << MPS_idx << "\n"; } MPI_Barrier(retrieveGlobalComm()); #endif FILE *fp_x, *fp_y, *fp_k; segy tr_x, tr_y, tr_k; //MPI variables int RANK = retrieveGlobalRank(); int rank = retrieveRank(); int SIZE = retrieveGlobalSize(); int size = retrieveSize(); int N_gr = retrieveNumGroups(); int grID = retrieveGroupID(); MPI_Comm COMM = retrieveGlobalComm(); MPI_Comm comm = retrieveComm(); int N_src = s_pos.size(); //total number of sources int N_src_loc; //number of sources at current process int NS_x, NS_y, NS_k; //total number of time sample points per trace int NTR_x, NTR_y, NTR_k; //total number of traces int NTR_x_loc, NTR_y_loc, NTR_k_loc; //total number of traces at current process int NTPS_x, NTPS_y, NTPS_k; //number of traces per source float dt_x, dt_y, dt_k; float delrt_x, delrt_y, delrt_k; //global arrays float * x_arr = NULL; float * y_arr = NULL; float * k_arr = NULL; //local arrays float * x_arr_loc = NULL; float * y_arr_loc = NULL; float * k_arr_loc = NULL; float * x_arr_red = NULL; //buffer for group root reduction float * x_buff = NULL; //single trace buffer //other arrays int *NSPG = NULL; //array containing number of sources per group, for each group int *snd_sz = NULL; //array containing size of data to be sent via scatterv/gatherv int *offsets = NULL; //array of offsets for data to be sent via scatterv/gatherv fpos_t pos_x; if( MPS_idx<0 || MPS_idx>=MPS_dim ){ RVLException e; e << "MPS_idx="<< MPS_idx << " out of bounds!\n"; throw e; } //setting up number of sources per group (NSPG) array NSPG = new int[N_gr]; for( int g=0; g