Skip to content
Snippets Groups Projects
bexchange.c 32.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • Debolskiy Andrey's avatar
    Debolskiy Andrey committed
    // -------------------------------------------------------------------------- //
    int P_BExchange_opt_free ( bexchange, exch_mode ) 
    	BExchange *bexchange;
    	int exch_mode;
    {
    	if (exch_mode == IS_MPI_TYPED) {
    		return P_BExchange_free(bexchange);
    	}
    	if (exch_mode == IS_MPI_MANUAL_PACK) {
    		return P_BExchange_mp_free(bexchange);
    	}
    	if (exch_mode == IS_MPI_TYPED_PERSISTENT) {
    		return PST_BExchange_free(bexchange);
    	}
    	if (exch_mode == IS_MPI_MANUAL_PACK_PERSISTENT) {
    		return PST_BExchange_mp_free(bexchange);
    	}
    
    	return 999;
    }
    // -------------------------------------------------------------------------- //
    
    // -------------------------------------------------------------------------- //
    int P_BExchange_opt ( a, ndims, stride, blklen, bdim, overlap, datatype, 
    	comm, period, exch_mode )
    	
    	void *a;
    	int ndims, *stride, *blklen, bdim, overlap[2];
    	MPI_Datatype datatype;
    	MPI_Comm comm;
    	int period;
    	int exch_mode;
    {
    	BExchange bexchange;
    	int ierr;
    
    	if (exch_mode == IS_MPI_TYPED) {
    		if (ierr = P_BExchange_init(ndims, stride, blklen, bdim, overlap, datatype,
    			comm, period, &bexchange) != 0) {
    			return ierr;
    		}
    
    		P_BExchange_start(a, &bexchange);
    		P_BExchange_end(&bexchange);
    		P_BExchange_free(&bexchange);
    		return 0;
    	}
    	if (exch_mode == IS_MPI_MANUAL_PACK) {
    		if (ierr = P_BExchange_mp_init(ndims, stride, blklen, bdim, overlap, datatype,
    			comm, period, &bexchange) != 0) {
    			return ierr;
    		}
    
    		P_BExchange_mp_start(a, &bexchange);
    		P_BExchange_mp_end(a, &bexchange);
    		P_BExchange_mp_free(&bexchange);
    		return 0;
    	}
    	if (exch_mode == IS_MPI_TYPED_PERSISTENT) {
    		if (ierr = PST_BExchange_init(a, ndims, stride, blklen, bdim, overlap, datatype,
    			comm, period, &bexchange) != 0) {
    			return ierr;
    		}
    
    		PST_BExchange_start(&bexchange);
    		PST_BExchange_end(&bexchange);
    		PST_BExchange_free(&bexchange);
    		return 0;
    	}
    	if (exch_mode == IS_MPI_MANUAL_PACK_PERSISTENT) {
    		if (ierr = PST_BExchange_mp_init(ndims, stride, blklen, bdim, overlap, datatype,
    			comm, period, &bexchange) != 0) {
    			return ierr;
    		}
    		PST_BExchange_mp_start(a, &bexchange);
    		PST_BExchange_mp_end(a, &bexchange);
    		PST_BExchange_mp_free(&bexchange);
    		return 0;
    	}
    
    	return 999;
    }
    
    Debolskiy Andrey's avatar
    Debolskiy Andrey committed
    // -------------------------------------------------------------------------- //
    
    // -------------------------------------------------------------------------- //
    int P_BExchange_period_opt ( a, ndims, stride, blklen, bdim, overlap, datatype, 
    	comm, exch_mode )
    	
    	void *a;
    	int ndims, *stride, *blklen, bdim, overlap[2];
    	MPI_Datatype datatype;
    	MPI_Comm comm;
    	int exch_mode;
    {
    	const int period = 1; 
    	const int only_period = 1;
    
    	BExchange bexchange;
    	int ierr;
    
    	if (exch_mode == IS_MPI_TYPED) {
    		if (ierr = P_BExchange_ginit(ndims, stride, blklen, bdim, overlap, datatype,
    			comm, period, only_period, &bexchange) != 0) {
    			return ierr;
    		}
    
    		P_BExchange_start(a, &bexchange);
    		P_BExchange_end(&bexchange);
    		P_BExchange_free(&bexchange);
    		return 0;
    	}
    	if (exch_mode == IS_MPI_MANUAL_PACK) {
    		if (ierr = P_BExchange_mp_ginit(ndims, stride, blklen, bdim, overlap, datatype,
    			comm, period, only_period, &bexchange) != 0) {
    			return ierr;
    		}
    
    		P_BExchange_mp_start(a, &bexchange);
    		P_BExchange_mp_end(a, &bexchange);
    		P_BExchange_mp_free(&bexchange);
    		return 0;
    	}
    	if (exch_mode == IS_MPI_TYPED_PERSISTENT) {
    		if (ierr = PST_BExchange_ginit(a, ndims, stride, blklen, bdim, overlap, datatype,
    			comm, period, only_period, &bexchange) != 0) {
    			return ierr;
    		}
    
    		PST_BExchange_start(&bexchange);
    		PST_BExchange_end(&bexchange);
    		PST_BExchange_free(&bexchange);
    		return 0;
    	}
    	if (exch_mode == IS_MPI_MANUAL_PACK_PERSISTENT) {
    		if (ierr = PST_BExchange_mp_ginit(ndims, stride, blklen, bdim, overlap, datatype,
    			comm, period, only_period, &bexchange) != 0) {
    			return ierr;
    		}
    		PST_BExchange_mp_start(a, &bexchange);
    		PST_BExchange_mp_end(a, &bexchange);
    		PST_BExchange_mp_free(&bexchange);
    		return 0;
    	}
    
    	return 999;
    }
    // -------------------------------------------------------------------------- //