/** * @brief Client reads the data using the MPI_Get function * * @param len Number of data structures sent. * @param source MPI rank of the sending process. */ int process_mpi_get( const int len, const int seed, const int validate, const int source) { int nbytes = len*sizeof(data_t); log_level debug_level = xfer_debug_level; int rc = 0; MPI_Status status; MPI_Request req; MPI_Win win; MPI_Group comm_group, group; int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); log_debug(debug_level, "%d: starting process_mpi_get(len=%d, seed=%d, validate=%d)", rank, len, seed, validate); // Allocate space for the incoming buffer data_array_t array; array.data_array_t_len = len; array.data_array_t_val = new data_t[len]; log_debug(debug_level, "%d: creating window", rank); // initialize the array xfer_init_data_array(seed, &array); // Collective call to create a window for the data being transferred (like registering the memory) MPI_Win_create(array.data_array_t_val, sizeof(data_t)*len, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win); MPI_Win_fence(0, win); log_debug(debug_level, "Waiting for client to get data"); MPI_Win_fence(0, win); log_debug(debug_level, "Data should be transferred"); // clean up MPI_Win_free(&win); delete [] array.data_array_t_val; return rc; }
int xfer_validate_array(const int seed, data_array_t *array) { int rc = 0; log_level debug_level = xfer_debug_level; /* Validate the array that was sent through the args */ data_array_t tmp_array; tmp_array.data_array_t_len = array->data_array_t_len; tmp_array.data_array_t_val = new data_t[array->data_array_t_len]; xfer_init_data_array(seed, &tmp_array); rc = xfer_compare_data_arrays(&tmp_array, array); if (rc != 0) { log_warn(debug_level, "Unable to validate array"); } delete [] tmp_array.data_array_t_val; return rc; }