Merge pull request #1929 from edgargabriel/pr/ompio-code-reorg
io/ompio: next step in code-reorganization
Этот коммит содержится в:
Коммит
4709f4229b
@ -18,6 +18,8 @@
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
if OMPI_PROVIDE_MPI_FILE_INTERFACE
|
||||
|
||||
headers = \
|
||||
common_ompio_print_queue.h \
|
||||
common_ompio.h
|
||||
@ -25,6 +27,7 @@ headers = \
|
||||
sources = \
|
||||
common_ompio_print_queue.c \
|
||||
common_ompio_file_open.c \
|
||||
common_ompio_file_view.c \
|
||||
common_ompio_file_read.c \
|
||||
common_ompio_file_write.c
|
||||
|
||||
@ -84,3 +87,14 @@ clean-local:
|
||||
if test -z "$(lib_LTLIBRARIES)"; then \
|
||||
rm -f "$(comp_inst)"; \
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
# Need to have empty targets because AM can't handle having an
|
||||
# AM_CONDITIONAL was targets in the "if" statement but not in the
|
||||
# "else". :-(
|
||||
|
||||
all-local:
|
||||
clean-local:
|
||||
|
||||
endif
|
||||
|
@ -82,7 +82,10 @@ OMPI_DECLSPEC int mca_common_ompio_file_close (mca_io_ompio_file_t *ompio_fh);
|
||||
OMPI_DECLSPEC int mca_common_ompio_file_get_size (mca_io_ompio_file_t *ompio_fh, OMPI_MPI_OFFSET_TYPE *size);
|
||||
OMPI_DECLSPEC int mca_common_ompio_file_get_position (mca_io_ompio_file_t *fh,OMPI_MPI_OFFSET_TYPE *offset);
|
||||
OMPI_DECLSPEC int mca_common_ompio_set_explicit_offset (mca_io_ompio_file_t *fh, OMPI_MPI_OFFSET_TYPE offset);
|
||||
|
||||
OMPI_DECLSPEC int mca_common_ompio_set_file_defaults (mca_io_ompio_file_t *fh);
|
||||
OMPI_DECLSPEC int mca_common_ompio_set_view (mca_io_ompio_file_t *fh, OMPI_MPI_OFFSET_TYPE disp,
|
||||
ompi_datatype_t *etype, ompi_datatype_t *filetype, const char *datarep,
|
||||
ompi_info_t *info);
|
||||
|
||||
|
||||
#endif /* MCA_COMMON_OMPIO_H */
|
||||
|
@ -91,7 +91,7 @@ int mca_common_ompio_file_open (ompi_communicator_t *comm,
|
||||
ompio_fh->f_info = info;
|
||||
ompio_fh->f_atomicity = 0;
|
||||
|
||||
ompi_io_ompio_set_file_defaults (ompio_fh);
|
||||
mca_common_ompio_set_file_defaults (ompio_fh);
|
||||
ompio_fh->f_filename = filename;
|
||||
|
||||
ompio_fh->f_split_coll_req = NULL;
|
||||
@ -105,9 +105,6 @@ int mca_common_ompio_file_open (ompi_communicator_t *comm,
|
||||
ompio_fh->f_decode_datatype=ompi_io_ompio_decode_datatype;
|
||||
ompio_fh->f_generate_current_file_view=ompi_io_ompio_generate_current_file_view;
|
||||
|
||||
ompio_fh->f_sort=ompi_io_ompio_sort;
|
||||
ompio_fh->f_sort_iovec=ompi_io_ompio_sort_iovec;
|
||||
|
||||
ompio_fh->f_get_num_aggregators=mca_io_ompio_get_num_aggregators;
|
||||
ompio_fh->f_get_bytes_per_agg=mca_io_ompio_get_bytes_per_agg;
|
||||
ompio_fh->f_set_aggregator_props=mca_io_ompio_set_aggregator_props;
|
||||
@ -377,4 +374,78 @@ int mca_common_ompio_file_get_position (mca_io_ompio_file_t *fh,
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
int mca_common_ompio_set_file_defaults (mca_io_ompio_file_t *fh)
|
||||
{
|
||||
|
||||
if (NULL != fh) {
|
||||
ompi_datatype_t *types[2];
|
||||
int blocklen[2] = {1, 1};
|
||||
OPAL_PTRDIFF_TYPE d[2], base;
|
||||
int i;
|
||||
|
||||
fh->f_io_array = NULL;
|
||||
fh->f_perm = OMPIO_PERM_NULL;
|
||||
fh->f_flags = 0;
|
||||
fh->f_bytes_per_agg = mca_io_ompio_bytes_per_agg;
|
||||
fh->f_datarep = strdup ("native");
|
||||
|
||||
fh->f_offset = 0;
|
||||
fh->f_disp = 0;
|
||||
fh->f_position_in_file_view = 0;
|
||||
fh->f_index_in_file_view = 0;
|
||||
fh->f_total_bytes = 0;
|
||||
|
||||
fh->f_init_procs_per_group = -1;
|
||||
fh->f_init_procs_in_group = NULL;
|
||||
|
||||
fh->f_procs_per_group = -1;
|
||||
fh->f_procs_in_group = NULL;
|
||||
|
||||
fh->f_init_num_aggrs = -1;
|
||||
fh->f_init_aggr_list = NULL;
|
||||
|
||||
|
||||
/* Default file View */
|
||||
fh->f_iov_type = MPI_DATATYPE_NULL;
|
||||
fh->f_stripe_size = mca_io_ompio_bytes_per_agg;
|
||||
/*Decoded iovec of the file-view*/
|
||||
fh->f_decoded_iov = NULL;
|
||||
fh->f_etype = NULL;
|
||||
fh->f_filetype = NULL;
|
||||
fh->f_orig_filetype = NULL;
|
||||
|
||||
mca_common_ompio_set_view(fh,
|
||||
0,
|
||||
&ompi_mpi_byte.dt,
|
||||
&ompi_mpi_byte.dt,
|
||||
"native",
|
||||
fh->f_info);
|
||||
|
||||
|
||||
/*Create a derived datatype for the created iovec */
|
||||
types[0] = &ompi_mpi_long.dt;
|
||||
types[1] = &ompi_mpi_long.dt;
|
||||
|
||||
d[0] = (OPAL_PTRDIFF_TYPE) fh->f_decoded_iov;
|
||||
d[1] = (OPAL_PTRDIFF_TYPE) &fh->f_decoded_iov[0].iov_len;
|
||||
|
||||
base = d[0];
|
||||
for (i=0 ; i<2 ; i++) {
|
||||
d[i] -= base;
|
||||
}
|
||||
|
||||
ompi_datatype_create_struct (2,
|
||||
blocklen,
|
||||
d,
|
||||
types,
|
||||
&fh->f_iov_type);
|
||||
ompi_datatype_commit (&fh->f_iov_type);
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
else {
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
279
ompi/mca/common/ompio/common_ompio_file_view.c
Обычный файл
279
ompi/mca/common/ompio/common_ompio_file_view.c
Обычный файл
@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
* Corporation. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
* of Tennessee Research Foundation. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "ompi_config.h"
|
||||
#include "opal/datatype/opal_convertor.h"
|
||||
#include "ompi/datatype/ompi_datatype.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common_ompio.h"
|
||||
#include "ompi/mca/fcoll/base/base.h"
|
||||
|
||||
static OMPI_MPI_OFFSET_TYPE get_contiguous_chunk_size (mca_io_ompio_file_t *);
|
||||
static int datatype_duplicate (ompi_datatype_t *oldtype, ompi_datatype_t **newtype );
|
||||
static int datatype_duplicate (ompi_datatype_t *oldtype, ompi_datatype_t **newtype )
|
||||
{
|
||||
ompi_datatype_t *type;
|
||||
if( ompi_datatype_is_predefined(oldtype) ) {
|
||||
*newtype = oldtype;
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
if ( OMPI_SUCCESS != ompi_datatype_duplicate (oldtype, &type)){
|
||||
ompi_datatype_destroy (&type);
|
||||
return MPI_ERR_INTERN;
|
||||
}
|
||||
|
||||
ompi_datatype_set_args( type, 0, NULL, 0, NULL, 1, &oldtype, MPI_COMBINER_DUP );
|
||||
|
||||
*newtype = type;
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int mca_common_ompio_set_view (mca_io_ompio_file_t *fh,
|
||||
OMPI_MPI_OFFSET_TYPE disp,
|
||||
ompi_datatype_t *etype,
|
||||
ompi_datatype_t *filetype,
|
||||
const char *datarep,
|
||||
ompi_info_t *info)
|
||||
{
|
||||
|
||||
size_t max_data = 0;
|
||||
int i;
|
||||
int num_groups = 0;
|
||||
mca_io_ompio_contg *contg_groups;
|
||||
|
||||
size_t ftype_size;
|
||||
OPAL_PTRDIFF_TYPE ftype_extent, lb, ub;
|
||||
ompi_datatype_t *newfiletype;
|
||||
|
||||
if ( NULL != fh->f_etype ) {
|
||||
ompi_datatype_destroy (&fh->f_etype);
|
||||
}
|
||||
if ( NULL != fh->f_filetype ) {
|
||||
ompi_datatype_destroy (&fh->f_filetype);
|
||||
}
|
||||
if ( NULL != fh->f_orig_filetype ) {
|
||||
ompi_datatype_destroy (&fh->f_orig_filetype);
|
||||
}
|
||||
if (NULL != fh->f_decoded_iov) {
|
||||
free (fh->f_decoded_iov);
|
||||
fh->f_decoded_iov = NULL;
|
||||
}
|
||||
|
||||
if (NULL != fh->f_datarep) {
|
||||
free (fh->f_datarep);
|
||||
fh->f_datarep = NULL;
|
||||
}
|
||||
|
||||
/* Reset the flags first */
|
||||
fh->f_flags = 0;
|
||||
|
||||
fh->f_flags |= OMPIO_FILE_VIEW_IS_SET;
|
||||
fh->f_datarep = strdup (datarep);
|
||||
datatype_duplicate (filetype, &fh->f_orig_filetype );
|
||||
|
||||
opal_datatype_get_extent(&filetype->super, &lb, &ftype_extent);
|
||||
opal_datatype_type_size (&filetype->super, &ftype_size);
|
||||
|
||||
if ( etype == filetype &&
|
||||
ompi_datatype_is_predefined (filetype ) &&
|
||||
ftype_extent == (OPAL_PTRDIFF_TYPE)ftype_size ){
|
||||
ompi_datatype_create_contiguous(MCA_IO_DEFAULT_FILE_VIEW_SIZE,
|
||||
&ompi_mpi_byte.dt,
|
||||
&newfiletype);
|
||||
ompi_datatype_commit (&newfiletype);
|
||||
}
|
||||
else {
|
||||
newfiletype = filetype;
|
||||
}
|
||||
|
||||
fh->f_iov_count = 0;
|
||||
fh->f_disp = disp;
|
||||
fh->f_offset = disp;
|
||||
fh->f_total_bytes = 0;
|
||||
fh->f_index_in_file_view=0;
|
||||
fh->f_position_in_file_view=0;
|
||||
|
||||
ompi_io_ompio_decode_datatype (fh,
|
||||
newfiletype,
|
||||
1,
|
||||
NULL,
|
||||
&max_data,
|
||||
&fh->f_decoded_iov,
|
||||
&fh->f_iov_count);
|
||||
|
||||
opal_datatype_get_extent(&newfiletype->super, &lb, &fh->f_view_extent);
|
||||
opal_datatype_type_ub (&newfiletype->super, &ub);
|
||||
opal_datatype_type_size (&etype->super, &fh->f_etype_size);
|
||||
opal_datatype_type_size (&newfiletype->super, &fh->f_view_size);
|
||||
datatype_duplicate (etype, &fh->f_etype);
|
||||
// This file type is our own representation. The original is stored
|
||||
// in orig_file type, No need to set args on this one.
|
||||
ompi_datatype_duplicate (newfiletype, &fh->f_filetype);
|
||||
|
||||
fh->f_cc_size = get_contiguous_chunk_size (fh);
|
||||
|
||||
if (opal_datatype_is_contiguous_memory_layout(&etype->super,1)) {
|
||||
if (opal_datatype_is_contiguous_memory_layout(&filetype->super,1) &&
|
||||
fh->f_view_extent == (OPAL_PTRDIFF_TYPE)fh->f_view_size ) {
|
||||
fh->f_flags |= OMPIO_CONTIGUOUS_FVIEW;
|
||||
}
|
||||
}
|
||||
|
||||
contg_groups = (mca_io_ompio_contg*) calloc ( 1, fh->f_size * sizeof(mca_io_ompio_contg));
|
||||
if (NULL == contg_groups) {
|
||||
opal_output (1, "OUT OF MEMORY\n");
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
for( i = 0; i < fh->f_size; i++){
|
||||
contg_groups[i].procs_in_contg_group = (int*)calloc (1,fh->f_size * sizeof(int));
|
||||
if(NULL == contg_groups[i].procs_in_contg_group){
|
||||
int j;
|
||||
opal_output (1, "OUT OF MEMORY\n");
|
||||
for(j=0; j<i; j++) {
|
||||
free(contg_groups[j].procs_in_contg_group);
|
||||
}
|
||||
free(contg_groups);
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( SIMPLE != mca_io_ompio_grouping_option ) {
|
||||
if( OMPI_SUCCESS != mca_io_ompio_fview_based_grouping(fh,
|
||||
&num_groups,
|
||||
contg_groups)){
|
||||
opal_output(1, "mca_common_ompio_set_view: mca_io_ompio_fview_based_grouping failed\n");
|
||||
free(contg_groups);
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( OMPI_SUCCESS != mca_io_ompio_simple_grouping(fh,
|
||||
&num_groups,
|
||||
contg_groups)){
|
||||
opal_output(1, "mca_common_ompio_set_view: mca_io_ompio_simple_grouping failed\n");
|
||||
free(contg_groups);
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( OMPI_SUCCESS != mca_io_ompio_finalize_initial_grouping(fh,
|
||||
num_groups,
|
||||
contg_groups) ){
|
||||
opal_output(1, "mca_common_ompio_set_view: mca_io_ompio_finalize_initial_grouping failed\n");
|
||||
free(contg_groups);
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
for( i = 0; i < fh->f_size; i++){
|
||||
free(contg_groups[i].procs_in_contg_group);
|
||||
}
|
||||
free(contg_groups);
|
||||
|
||||
if ( etype == filetype &&
|
||||
ompi_datatype_is_predefined (filetype ) &&
|
||||
ftype_extent == (OPAL_PTRDIFF_TYPE)ftype_size ){
|
||||
ompi_datatype_destroy ( &newfiletype );
|
||||
}
|
||||
|
||||
|
||||
if (OMPI_SUCCESS != mca_fcoll_base_file_select (fh, NULL)) {
|
||||
opal_output(1, "mca_common_ompio_set_view: mca_fcoll_base_file_select() failed\n");
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
OMPI_MPI_OFFSET_TYPE get_contiguous_chunk_size (mca_io_ompio_file_t *fh)
|
||||
{
|
||||
int uniform = 0;
|
||||
OMPI_MPI_OFFSET_TYPE avg[3] = {0,0,0};
|
||||
OMPI_MPI_OFFSET_TYPE global_avg[3] = {0,0,0};
|
||||
int i = 0;
|
||||
|
||||
/* This function does two things: first, it determines the average data chunk
|
||||
** size in the file view for each process and across all processes.
|
||||
** Second, it establishes whether the view across all processes is uniform.
|
||||
** By definition, uniform means:
|
||||
** 1. the file view of each process has the same number of contiguous sections
|
||||
** 2. each section in the file view has exactly the same size
|
||||
*/
|
||||
|
||||
for (i=0 ; i<(int)fh->f_iov_count ; i++) {
|
||||
avg[0] += fh->f_decoded_iov[i].iov_len;
|
||||
if (i && 0 == uniform) {
|
||||
if (fh->f_decoded_iov[i].iov_len != fh->f_decoded_iov[i-1].iov_len) {
|
||||
uniform = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( 0 != fh->f_iov_count ) {
|
||||
avg[0] = avg[0]/fh->f_iov_count;
|
||||
}
|
||||
avg[1] = (OMPI_MPI_OFFSET_TYPE) fh->f_iov_count;
|
||||
avg[2] = (OMPI_MPI_OFFSET_TYPE) uniform;
|
||||
|
||||
fh->f_comm->c_coll.coll_allreduce (avg,
|
||||
global_avg,
|
||||
3,
|
||||
OMPI_OFFSET_DATATYPE,
|
||||
MPI_SUM,
|
||||
fh->f_comm,
|
||||
fh->f_comm->c_coll.coll_allreduce_module);
|
||||
global_avg[0] = global_avg[0]/fh->f_size;
|
||||
global_avg[1] = global_avg[1]/fh->f_size;
|
||||
|
||||
#if 0
|
||||
/* Disabling the feature since we are not using it anyway. Saves us one allreduce operation. */
|
||||
int global_uniform=0;
|
||||
|
||||
if ( global_avg[0] == avg[0] &&
|
||||
global_avg[1] == avg[1] &&
|
||||
0 == avg[2] &&
|
||||
0 == global_avg[2] ) {
|
||||
uniform = 0;
|
||||
}
|
||||
else {
|
||||
uniform = 1;
|
||||
}
|
||||
|
||||
/* second confirmation round to see whether all processes agree
|
||||
** on having a uniform file view or not
|
||||
*/
|
||||
fh->f_comm->c_coll.coll_allreduce (&uniform,
|
||||
&global_uniform,
|
||||
1,
|
||||
MPI_INT,
|
||||
MPI_MAX,
|
||||
fh->f_comm,
|
||||
fh->f_comm->c_coll.coll_allreduce_module);
|
||||
|
||||
if ( 0 == global_uniform ){
|
||||
/* yes, everybody agrees on having a uniform file view */
|
||||
fh->f_flags |= OMPIO_UNIFORM_FVIEW;
|
||||
}
|
||||
#endif
|
||||
return global_avg[0];
|
||||
}
|
||||
|
||||
|
@ -26,4 +26,5 @@ libmca_fcoll_la_SOURCES += \
|
||||
base/fcoll_base_file_select.c \
|
||||
base/fcoll_base_file_unselect.c \
|
||||
base/fcoll_base_find_available.c \
|
||||
base/fcoll_base_sort.c \
|
||||
base/fcoll_base_coll_array.c
|
||||
|
@ -47,6 +47,8 @@ OMPI_DECLSPEC int mca_fcoll_base_find_available(bool enable_progress_threads,
|
||||
OMPI_DECLSPEC int mca_fcoll_base_init_file (struct mca_io_ompio_file_t *file);
|
||||
|
||||
OMPI_DECLSPEC int mca_fcoll_base_get_param (struct mca_io_ompio_file_t *file, int keyval);
|
||||
OMPI_DECLSPEC int fcoll_base_sort_iovec (struct iovec *iov, int num_entries, int *sorted);
|
||||
|
||||
/*
|
||||
* Globals
|
||||
*/
|
||||
|
131
ompi/mca/fcoll/base/fcoll_base_sort.c
Обычный файл
131
ompi/mca/fcoll/base/fcoll_base_sort.c
Обычный файл
@ -0,0 +1,131 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
* Corporation. All rights reserved.
|
||||
* Copyright (c) 2004-2007 The University of Tennessee and The University
|
||||
* of Tennessee Research Foundation. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "ompi_config.h"
|
||||
#include "base.h"
|
||||
#include "ompi/mca/common/ompio/common_ompio.h"
|
||||
|
||||
|
||||
int fcoll_base_sort_iovec (struct iovec *iov,
|
||||
int num_entries,
|
||||
int *sorted)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
int largest = 0;
|
||||
int heap_size = num_entries - 1;
|
||||
int temp = 0;
|
||||
unsigned char done = 0;
|
||||
int* temp_arr = NULL;
|
||||
|
||||
if (0 == num_entries) {
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
temp_arr = (int*)malloc(num_entries*sizeof(int));
|
||||
if (NULL == temp_arr) {
|
||||
opal_output (1, "OUT OF MEMORY\n");
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
temp_arr[0] = 0;
|
||||
for (i = 1; i < num_entries; ++i) {
|
||||
temp_arr[i] = i;
|
||||
}
|
||||
/* num_entries can be a large no. so NO RECURSION */
|
||||
for (i = num_entries/2-1 ; i>=0 ; i--) {
|
||||
done = 0;
|
||||
j = i;
|
||||
largest = j;
|
||||
|
||||
while (!done) {
|
||||
left = j*2+1;
|
||||
right = j*2+2;
|
||||
if ((left <= heap_size) &&
|
||||
(iov[temp_arr[left]].iov_base > iov[temp_arr[j]].iov_base)) {
|
||||
largest = left;
|
||||
}
|
||||
else {
|
||||
largest = j;
|
||||
}
|
||||
if ((right <= heap_size) &&
|
||||
(iov[temp_arr[right]].iov_base >
|
||||
iov[temp_arr[largest]].iov_base)) {
|
||||
largest = right;
|
||||
}
|
||||
if (largest != j) {
|
||||
temp = temp_arr[largest];
|
||||
temp_arr[largest] = temp_arr[j];
|
||||
temp_arr[j] = temp;
|
||||
j = largest;
|
||||
}
|
||||
else {
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = num_entries-1; i >=1; --i) {
|
||||
temp = temp_arr[0];
|
||||
temp_arr[0] = temp_arr[i];
|
||||
temp_arr[i] = temp;
|
||||
heap_size--;
|
||||
done = 0;
|
||||
j = 0;
|
||||
largest = j;
|
||||
|
||||
while (!done) {
|
||||
left = j*2+1;
|
||||
right = j*2+2;
|
||||
|
||||
if ((left <= heap_size) &&
|
||||
(iov[temp_arr[left]].iov_base >
|
||||
iov[temp_arr[j]].iov_base)) {
|
||||
largest = left;
|
||||
}
|
||||
else {
|
||||
largest = j;
|
||||
}
|
||||
if ((right <= heap_size) &&
|
||||
(iov[temp_arr[right]].iov_base >
|
||||
iov[temp_arr[largest]].iov_base)) {
|
||||
largest = right;
|
||||
}
|
||||
if (largest != j) {
|
||||
temp = temp_arr[largest];
|
||||
temp_arr[largest] = temp_arr[j];
|
||||
temp_arr[j] = temp;
|
||||
j = largest;
|
||||
}
|
||||
else {
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
sorted[i] = temp_arr[i];
|
||||
}
|
||||
sorted[0] = temp_arr[0];
|
||||
|
||||
if (NULL != temp_arr) {
|
||||
free(temp_arr);
|
||||
temp_arr = NULL;
|
||||
}
|
||||
return OMPI_SUCCESS;
|
||||
}
|
@ -307,7 +307,7 @@ mca_fcoll_dynamic_file_read_all (mca_io_ompio_file_t *fh,
|
||||
ret = OMPI_ERR_OUT_OF_RESOURCE;
|
||||
goto exit;
|
||||
}
|
||||
fh->f_sort_iovec (global_iov_array, total_fview_count, sorted);
|
||||
fcoll_base_sort_iovec (global_iov_array, total_fview_count, sorted);
|
||||
}
|
||||
|
||||
if (NULL != local_iov_array) {
|
||||
|
@ -327,7 +327,7 @@ mca_fcoll_dynamic_file_write_all (mca_io_ompio_file_t *fh,
|
||||
ret = OMPI_ERR_OUT_OF_RESOURCE;
|
||||
goto exit;
|
||||
}
|
||||
fh->f_sort_iovec (global_iov_array, total_fview_count, sorted);
|
||||
fcoll_base_sort_iovec (global_iov_array, total_fview_count, sorted);
|
||||
}
|
||||
|
||||
if (NULL != local_iov_array){
|
||||
|
@ -307,7 +307,7 @@ mca_fcoll_dynamic_gen2_file_read_all (mca_io_ompio_file_t *fh,
|
||||
ret = OMPI_ERR_OUT_OF_RESOURCE;
|
||||
goto exit;
|
||||
}
|
||||
fh->f_sort_iovec (global_iov_array, total_fview_count, sorted);
|
||||
fcoll_base_sort_iovec (global_iov_array, total_fview_count, sorted);
|
||||
}
|
||||
|
||||
if (NULL != local_iov_array) {
|
||||
|
@ -455,7 +455,7 @@ int mca_fcoll_dynamic_gen2_file_write_all (mca_io_ompio_file_t *fh,
|
||||
ret = OMPI_ERR_OUT_OF_RESOURCE;
|
||||
goto exit;
|
||||
}
|
||||
fh->f_sort_iovec (aggr_data[i]->global_iov_array, total_fview_count, aggr_data[i]->sorted);
|
||||
fcoll_base_sort_iovec (aggr_data[i]->global_iov_array, total_fview_count, aggr_data[i]->sorted);
|
||||
}
|
||||
|
||||
if (NULL != local_iov_array){
|
||||
|
@ -38,93 +38,8 @@
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_SYS_STATFS_H
|
||||
#include <sys/statfs.h> /* or <sys/vfs.h> */
|
||||
#endif
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_MOUNT_H
|
||||
#include <sys/mount.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include "io_ompio.h"
|
||||
|
||||
int ompi_io_ompio_set_file_defaults (mca_io_ompio_file_t *fh)
|
||||
{
|
||||
|
||||
if (NULL != fh) {
|
||||
ompi_datatype_t *types[2];
|
||||
int blocklen[2] = {1, 1};
|
||||
OPAL_PTRDIFF_TYPE d[2], base;
|
||||
int i;
|
||||
|
||||
fh->f_io_array = NULL;
|
||||
fh->f_perm = OMPIO_PERM_NULL;
|
||||
fh->f_flags = 0;
|
||||
fh->f_bytes_per_agg = mca_io_ompio_bytes_per_agg;
|
||||
fh->f_datarep = strdup ("native");
|
||||
|
||||
fh->f_offset = 0;
|
||||
fh->f_disp = 0;
|
||||
fh->f_position_in_file_view = 0;
|
||||
fh->f_index_in_file_view = 0;
|
||||
fh->f_total_bytes = 0;
|
||||
|
||||
fh->f_init_procs_per_group = -1;
|
||||
fh->f_init_procs_in_group = NULL;
|
||||
|
||||
fh->f_procs_per_group = -1;
|
||||
fh->f_procs_in_group = NULL;
|
||||
|
||||
fh->f_init_num_aggrs = -1;
|
||||
fh->f_init_aggr_list = NULL;
|
||||
|
||||
|
||||
/* Default file View */
|
||||
fh->f_iov_type = MPI_DATATYPE_NULL;
|
||||
fh->f_stripe_size = mca_io_ompio_bytes_per_agg;
|
||||
/*Decoded iovec of the file-view*/
|
||||
fh->f_decoded_iov = NULL;
|
||||
fh->f_etype = NULL;
|
||||
fh->f_filetype = NULL;
|
||||
fh->f_orig_filetype = NULL;
|
||||
|
||||
mca_io_ompio_set_view_internal(fh,
|
||||
0,
|
||||
&ompi_mpi_byte.dt,
|
||||
&ompi_mpi_byte.dt,
|
||||
"native",
|
||||
fh->f_info);
|
||||
|
||||
|
||||
/*Create a derived datatype for the created iovec */
|
||||
types[0] = &ompi_mpi_long.dt;
|
||||
types[1] = &ompi_mpi_long.dt;
|
||||
|
||||
d[0] = (OPAL_PTRDIFF_TYPE) fh->f_decoded_iov;
|
||||
d[1] = (OPAL_PTRDIFF_TYPE) &fh->f_decoded_iov[0].iov_len;
|
||||
|
||||
base = d[0];
|
||||
for (i=0 ; i<2 ; i++) {
|
||||
d[i] -= base;
|
||||
}
|
||||
|
||||
ompi_datatype_create_struct (2,
|
||||
blocklen,
|
||||
d,
|
||||
types,
|
||||
&fh->f_iov_type);
|
||||
ompi_datatype_commit (&fh->f_iov_type);
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
else {
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
int ompi_io_ompio_generate_current_file_view (struct mca_io_ompio_file_t *fh,
|
||||
size_t max_data,
|
||||
@ -619,215 +534,7 @@ int ompi_io_ompio_decode_datatype (struct mca_io_ompio_file_t *fh,
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
int ompi_io_ompio_sort (mca_io_ompio_io_array_t *io_array,
|
||||
int num_entries,
|
||||
int *sorted)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
int largest = 0;
|
||||
int heap_size = num_entries - 1;
|
||||
int temp = 0;
|
||||
unsigned char done = 0;
|
||||
int* temp_arr = NULL;
|
||||
|
||||
temp_arr = (int*)malloc(num_entries*sizeof(int));
|
||||
if (NULL == temp_arr) {
|
||||
opal_output (1, "OUT OF MEMORY\n");
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
temp_arr[0] = 0;
|
||||
for (i = 1; i < num_entries; ++i) {
|
||||
temp_arr[i] = i;
|
||||
}
|
||||
/* num_entries can be a large no. so NO RECURSION */
|
||||
for (i = num_entries/2-1 ; i>=0 ; i--) {
|
||||
done = 0;
|
||||
j = i;
|
||||
largest = j;
|
||||
|
||||
while (!done) {
|
||||
left = j*2+1;
|
||||
right = j*2+2;
|
||||
if ((left <= heap_size) &&
|
||||
(io_array[temp_arr[left]].offset > io_array[temp_arr[j]].offset)) {
|
||||
largest = left;
|
||||
}
|
||||
else {
|
||||
largest = j;
|
||||
}
|
||||
if ((right <= heap_size) &&
|
||||
(io_array[temp_arr[right]].offset >
|
||||
io_array[temp_arr[largest]].offset)) {
|
||||
largest = right;
|
||||
}
|
||||
if (largest != j) {
|
||||
temp = temp_arr[largest];
|
||||
temp_arr[largest] = temp_arr[j];
|
||||
temp_arr[j] = temp;
|
||||
j = largest;
|
||||
}
|
||||
else {
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = num_entries-1; i >=1; --i) {
|
||||
temp = temp_arr[0];
|
||||
temp_arr[0] = temp_arr[i];
|
||||
temp_arr[i] = temp;
|
||||
heap_size--;
|
||||
done = 0;
|
||||
j = 0;
|
||||
largest = j;
|
||||
|
||||
while (!done) {
|
||||
left = j*2+1;
|
||||
right = j*2+2;
|
||||
|
||||
if ((left <= heap_size) &&
|
||||
(io_array[temp_arr[left]].offset >
|
||||
io_array[temp_arr[j]].offset)) {
|
||||
largest = left;
|
||||
}
|
||||
else {
|
||||
largest = j;
|
||||
}
|
||||
if ((right <= heap_size) &&
|
||||
(io_array[temp_arr[right]].offset >
|
||||
io_array[temp_arr[largest]].offset)) {
|
||||
largest = right;
|
||||
}
|
||||
if (largest != j) {
|
||||
temp = temp_arr[largest];
|
||||
temp_arr[largest] = temp_arr[j];
|
||||
temp_arr[j] = temp;
|
||||
j = largest;
|
||||
}
|
||||
else {
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
sorted[i] = temp_arr[i];
|
||||
}
|
||||
sorted[0] = temp_arr[0];
|
||||
|
||||
if (NULL != temp_arr) {
|
||||
free(temp_arr);
|
||||
temp_arr = NULL;
|
||||
}
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
int ompi_io_ompio_sort_iovec (struct iovec *iov,
|
||||
int num_entries,
|
||||
int *sorted)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
int largest = 0;
|
||||
int heap_size = num_entries - 1;
|
||||
int temp = 0;
|
||||
unsigned char done = 0;
|
||||
int* temp_arr = NULL;
|
||||
|
||||
if (0 == num_entries) {
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
temp_arr = (int*)malloc(num_entries*sizeof(int));
|
||||
if (NULL == temp_arr) {
|
||||
opal_output (1, "OUT OF MEMORY\n");
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
temp_arr[0] = 0;
|
||||
for (i = 1; i < num_entries; ++i) {
|
||||
temp_arr[i] = i;
|
||||
}
|
||||
/* num_entries can be a large no. so NO RECURSION */
|
||||
for (i = num_entries/2-1 ; i>=0 ; i--) {
|
||||
done = 0;
|
||||
j = i;
|
||||
largest = j;
|
||||
|
||||
while (!done) {
|
||||
left = j*2+1;
|
||||
right = j*2+2;
|
||||
if ((left <= heap_size) &&
|
||||
(iov[temp_arr[left]].iov_base > iov[temp_arr[j]].iov_base)) {
|
||||
largest = left;
|
||||
}
|
||||
else {
|
||||
largest = j;
|
||||
}
|
||||
if ((right <= heap_size) &&
|
||||
(iov[temp_arr[right]].iov_base >
|
||||
iov[temp_arr[largest]].iov_base)) {
|
||||
largest = right;
|
||||
}
|
||||
if (largest != j) {
|
||||
temp = temp_arr[largest];
|
||||
temp_arr[largest] = temp_arr[j];
|
||||
temp_arr[j] = temp;
|
||||
j = largest;
|
||||
}
|
||||
else {
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = num_entries-1; i >=1; --i) {
|
||||
temp = temp_arr[0];
|
||||
temp_arr[0] = temp_arr[i];
|
||||
temp_arr[i] = temp;
|
||||
heap_size--;
|
||||
done = 0;
|
||||
j = 0;
|
||||
largest = j;
|
||||
|
||||
while (!done) {
|
||||
left = j*2+1;
|
||||
right = j*2+2;
|
||||
|
||||
if ((left <= heap_size) &&
|
||||
(iov[temp_arr[left]].iov_base >
|
||||
iov[temp_arr[j]].iov_base)) {
|
||||
largest = left;
|
||||
}
|
||||
else {
|
||||
largest = j;
|
||||
}
|
||||
if ((right <= heap_size) &&
|
||||
(iov[temp_arr[right]].iov_base >
|
||||
iov[temp_arr[largest]].iov_base)) {
|
||||
largest = right;
|
||||
}
|
||||
if (largest != j) {
|
||||
temp = temp_arr[largest];
|
||||
temp_arr[largest] = temp_arr[j];
|
||||
temp_arr[j] = temp;
|
||||
j = largest;
|
||||
}
|
||||
else {
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
sorted[i] = temp_arr[i];
|
||||
}
|
||||
sorted[0] = temp_arr[0];
|
||||
|
||||
if (NULL != temp_arr) {
|
||||
free(temp_arr);
|
||||
temp_arr = NULL;
|
||||
}
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
int ompi_io_ompio_sort_offlen (mca_io_ompio_offlen_array_t *io_array,
|
||||
int num_entries,
|
||||
|
@ -180,18 +180,6 @@ typedef int (*mca_io_ompio_generate_current_file_view_fn_t) (struct mca_io_ompio
|
||||
struct iovec **f_iov,
|
||||
int *iov_count);
|
||||
|
||||
/*
|
||||
* Function that sorts an io_array according to the offset by filling
|
||||
* up an array of the indices into the array (HEAP SORT)
|
||||
*/
|
||||
typedef int (*mca_io_ompio_sort_fn_t) (mca_io_ompio_io_array_t *io_array,
|
||||
int num_entries,
|
||||
int *sorted);
|
||||
|
||||
typedef int (*mca_io_ompio_sort_iovec_fn_t) (struct iovec *iov,
|
||||
int num_entries,
|
||||
int *sorted);
|
||||
|
||||
/* functions to retrieve the number of aggregators and the size of the
|
||||
temporary buffer on aggregators from the fcoll modules */
|
||||
typedef void (*mca_io_ompio_get_num_aggregators_fn_t) ( int *num_aggregators);
|
||||
@ -288,9 +276,6 @@ struct mca_io_ompio_file_t {
|
||||
mca_io_ompio_decode_datatype_fn_t f_decode_datatype;
|
||||
mca_io_ompio_generate_current_file_view_fn_t f_generate_current_file_view;
|
||||
|
||||
mca_io_ompio_sort_fn_t f_sort;
|
||||
mca_io_ompio_sort_iovec_fn_t f_sort_iovec;
|
||||
|
||||
mca_io_ompio_get_num_aggregators_fn_t f_get_num_aggregators;
|
||||
mca_io_ompio_get_bytes_per_agg_fn_t f_get_bytes_per_agg;
|
||||
mca_io_ompio_set_aggregator_props_fn_t f_set_aggregator_props;
|
||||
@ -311,9 +296,6 @@ typedef struct mca_io_ompio_data_t mca_io_ompio_data_t;
|
||||
OMPI_DECLSPEC void mca_io_ompio_get_num_aggregators ( int *num_aggregators);
|
||||
OMPI_DECLSPEC void mca_io_ompio_get_bytes_per_agg ( int *bytes_per_agg);
|
||||
|
||||
|
||||
OMPI_DECLSPEC int ompi_io_ompio_set_file_defaults (mca_io_ompio_file_t *fh);
|
||||
|
||||
/*
|
||||
* Function that takes in a datatype and buffer, and decodes that datatype
|
||||
* into an iovec using the convertor_raw function
|
||||
@ -330,14 +312,6 @@ OMPI_DECLSPEC int ompi_io_ompio_decode_datatype (struct mca_io_ompio_file_t *fh,
|
||||
* Function that sorts an io_array according to the offset by filling
|
||||
* up an array of the indices into the array (HEAP SORT)
|
||||
*/
|
||||
OMPI_DECLSPEC int ompi_io_ompio_sort (mca_io_ompio_io_array_t *io_array,
|
||||
int num_entries,
|
||||
int *sorted);
|
||||
|
||||
OMPI_DECLSPEC int ompi_io_ompio_sort_iovec (struct iovec *iov,
|
||||
int num_entries,
|
||||
int *sorted);
|
||||
|
||||
OMPI_DECLSPEC int ompi_io_ompio_sort_offlen (mca_io_ompio_offlen_array_t *io_array,
|
||||
int num_entries,
|
||||
int *sorted);
|
||||
@ -367,13 +341,6 @@ int mca_io_ompio_file_set_view (struct ompi_file_t *fh,
|
||||
const char *datarep,
|
||||
struct ompi_info_t *info);
|
||||
|
||||
int mca_io_ompio_set_view_internal (struct mca_io_ompio_file_t *fh,
|
||||
OMPI_MPI_OFFSET_TYPE disp,
|
||||
struct ompi_datatype_t *etype,
|
||||
struct ompi_datatype_t *filetype,
|
||||
const char *datarep,
|
||||
struct ompi_info_t *info);
|
||||
|
||||
int mca_io_ompio_file_get_view (struct ompi_file_t *fh,
|
||||
OMPI_MPI_OFFSET_TYPE *disp,
|
||||
struct ompi_datatype_t **etype,
|
||||
|
@ -24,11 +24,6 @@
|
||||
#include "ompi/communicator/communicator.h"
|
||||
#include "ompi/info/info.h"
|
||||
#include "ompi/file/file.h"
|
||||
#include "ompi/mca/fs/fs.h"
|
||||
#include "ompi/mca/fs/base/base.h"
|
||||
#include "ompi/mca/fcoll/fcoll.h"
|
||||
#include "ompi/mca/fcoll/base/base.h"
|
||||
#include "ompi/mca/sharedfp/sharedfp.h"
|
||||
#include "ompi/mca/pml/pml.h"
|
||||
#include "opal/datatype/opal_convertor.h"
|
||||
#include "ompi/datatype/ompi_datatype.h"
|
||||
@ -38,8 +33,6 @@
|
||||
#include <unistd.h>
|
||||
#include "io_ompio.h"
|
||||
|
||||
static OMPI_MPI_OFFSET_TYPE get_contiguous_chunk_size (mca_io_ompio_file_t *);
|
||||
|
||||
static int datatype_duplicate (ompi_datatype_t *oldtype, ompi_datatype_t **newtype );
|
||||
static int datatype_duplicate (ompi_datatype_t *oldtype, ompi_datatype_t **newtype )
|
||||
{
|
||||
@ -60,165 +53,6 @@ static int datatype_duplicate (ompi_datatype_t *oldtype, ompi_datatype_t **newt
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int mca_io_ompio_set_view_internal(mca_io_ompio_file_t *fh,
|
||||
OMPI_MPI_OFFSET_TYPE disp,
|
||||
ompi_datatype_t *etype,
|
||||
ompi_datatype_t *filetype,
|
||||
const char *datarep,
|
||||
ompi_info_t *info)
|
||||
{
|
||||
|
||||
size_t max_data = 0;
|
||||
int i;
|
||||
int num_groups = 0;
|
||||
mca_io_ompio_contg *contg_groups;
|
||||
|
||||
size_t ftype_size;
|
||||
OPAL_PTRDIFF_TYPE ftype_extent, lb, ub;
|
||||
ompi_datatype_t *newfiletype;
|
||||
|
||||
if ( NULL != fh->f_etype ) {
|
||||
ompi_datatype_destroy (&fh->f_etype);
|
||||
}
|
||||
if ( NULL != fh->f_filetype ) {
|
||||
ompi_datatype_destroy (&fh->f_filetype);
|
||||
}
|
||||
if ( NULL != fh->f_orig_filetype ) {
|
||||
ompi_datatype_destroy (&fh->f_orig_filetype);
|
||||
}
|
||||
if (NULL != fh->f_decoded_iov) {
|
||||
free (fh->f_decoded_iov);
|
||||
fh->f_decoded_iov = NULL;
|
||||
}
|
||||
|
||||
if (NULL != fh->f_datarep) {
|
||||
free (fh->f_datarep);
|
||||
fh->f_datarep = NULL;
|
||||
}
|
||||
|
||||
/* Reset the flags first */
|
||||
fh->f_flags = 0;
|
||||
|
||||
fh->f_flags |= OMPIO_FILE_VIEW_IS_SET;
|
||||
fh->f_datarep = strdup (datarep);
|
||||
datatype_duplicate (filetype, &fh->f_orig_filetype );
|
||||
|
||||
opal_datatype_get_extent(&filetype->super, &lb, &ftype_extent);
|
||||
opal_datatype_type_size (&filetype->super, &ftype_size);
|
||||
|
||||
if ( etype == filetype &&
|
||||
ompi_datatype_is_predefined (filetype ) &&
|
||||
ftype_extent == (OPAL_PTRDIFF_TYPE)ftype_size ){
|
||||
ompi_datatype_create_contiguous(MCA_IO_DEFAULT_FILE_VIEW_SIZE,
|
||||
&ompi_mpi_byte.dt,
|
||||
&newfiletype);
|
||||
ompi_datatype_commit (&newfiletype);
|
||||
}
|
||||
else {
|
||||
newfiletype = filetype;
|
||||
}
|
||||
|
||||
|
||||
|
||||
fh->f_iov_count = 0;
|
||||
fh->f_disp = disp;
|
||||
fh->f_offset = disp;
|
||||
fh->f_total_bytes = 0;
|
||||
fh->f_index_in_file_view=0;
|
||||
fh->f_position_in_file_view=0;
|
||||
|
||||
ompi_io_ompio_decode_datatype (fh,
|
||||
newfiletype,
|
||||
1,
|
||||
NULL,
|
||||
&max_data,
|
||||
&fh->f_decoded_iov,
|
||||
&fh->f_iov_count);
|
||||
|
||||
opal_datatype_get_extent(&newfiletype->super, &lb, &fh->f_view_extent);
|
||||
opal_datatype_type_ub (&newfiletype->super, &ub);
|
||||
opal_datatype_type_size (&etype->super, &fh->f_etype_size);
|
||||
opal_datatype_type_size (&newfiletype->super, &fh->f_view_size);
|
||||
datatype_duplicate (etype, &fh->f_etype);
|
||||
// This file type is our own representation. The original is stored
|
||||
// in orig_file type, No need to set args on this one.
|
||||
ompi_datatype_duplicate (newfiletype, &fh->f_filetype);
|
||||
|
||||
fh->f_cc_size = get_contiguous_chunk_size (fh);
|
||||
|
||||
if (opal_datatype_is_contiguous_memory_layout(&etype->super,1)) {
|
||||
if (opal_datatype_is_contiguous_memory_layout(&filetype->super,1) &&
|
||||
fh->f_view_extent == (OPAL_PTRDIFF_TYPE)fh->f_view_size ) {
|
||||
fh->f_flags |= OMPIO_CONTIGUOUS_FVIEW;
|
||||
}
|
||||
}
|
||||
|
||||
contg_groups = (mca_io_ompio_contg*) calloc ( 1, fh->f_size * sizeof(mca_io_ompio_contg));
|
||||
if (NULL == contg_groups) {
|
||||
opal_output (1, "OUT OF MEMORY\n");
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
for( i = 0; i < fh->f_size; i++){
|
||||
contg_groups[i].procs_in_contg_group = (int*)calloc (1,fh->f_size * sizeof(int));
|
||||
if(NULL == contg_groups[i].procs_in_contg_group){
|
||||
int j;
|
||||
opal_output (1, "OUT OF MEMORY\n");
|
||||
for(j=0; j<i; j++) {
|
||||
free(contg_groups[j].procs_in_contg_group);
|
||||
}
|
||||
free(contg_groups);
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( SIMPLE != mca_io_ompio_grouping_option ) {
|
||||
if( OMPI_SUCCESS != mca_io_ompio_fview_based_grouping(fh,
|
||||
&num_groups,
|
||||
contg_groups)){
|
||||
opal_output(1, "mca_io_ompio_set_view_internal: mca_io_ompio_fview_based_grouping failed\n");
|
||||
free(contg_groups);
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( OMPI_SUCCESS != mca_io_ompio_simple_grouping(fh,
|
||||
&num_groups,
|
||||
contg_groups)){
|
||||
opal_output(1, "mca_io_ompio_set_view_internal: mca_io_ompio_simple_grouping failed\n");
|
||||
free(contg_groups);
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( OMPI_SUCCESS != mca_io_ompio_finalize_initial_grouping(fh,
|
||||
num_groups,
|
||||
contg_groups) ){
|
||||
opal_output(1, "mca_io_ompio_set_view_internal: mca_io_ompio_finalize_initial_grouping failed\n");
|
||||
free(contg_groups);
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
for( i = 0; i < fh->f_size; i++){
|
||||
free(contg_groups[i].procs_in_contg_group);
|
||||
}
|
||||
free(contg_groups);
|
||||
|
||||
if ( etype == filetype &&
|
||||
ompi_datatype_is_predefined (filetype ) &&
|
||||
ftype_extent == (OPAL_PTRDIFF_TYPE)ftype_size ){
|
||||
ompi_datatype_destroy ( &newfiletype );
|
||||
}
|
||||
|
||||
|
||||
if (OMPI_SUCCESS != mca_fcoll_base_file_select (fh, NULL)) {
|
||||
opal_output(1, "mca_io_ompio_set_view_internal: mca_fcoll_base_file_select() failed\n");
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
int mca_io_ompio_file_set_view (ompi_file_t *fp,
|
||||
OMPI_MPI_OFFSET_TYPE disp,
|
||||
ompi_datatype_t *etype,
|
||||
@ -237,11 +71,11 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp,
|
||||
file pointer, once for the shared file pointer (if it is existent)
|
||||
*/
|
||||
fh = &data->ompio_fh;
|
||||
ret = mca_io_ompio_set_view_internal(fh, disp, etype, filetype, datarep, info);
|
||||
ret = mca_common_ompio_set_view(fh, disp, etype, filetype, datarep, info);
|
||||
|
||||
if ( NULL != fh->f_sharedfp_data) {
|
||||
sh = ((struct mca_sharedfp_base_data_t *)fh->f_sharedfp_data)->sharedfh;
|
||||
ret = mca_io_ompio_set_view_internal(sh, disp, etype, filetype, datarep, info);
|
||||
ret = mca_common_ompio_set_view(sh, disp, etype, filetype, datarep, info);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -267,76 +101,3 @@ int mca_io_ompio_file_get_view (struct ompi_file_t *fp,
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
OMPI_MPI_OFFSET_TYPE get_contiguous_chunk_size (mca_io_ompio_file_t *fh)
|
||||
{
|
||||
int uniform = 0;
|
||||
OMPI_MPI_OFFSET_TYPE avg[3] = {0,0,0};
|
||||
OMPI_MPI_OFFSET_TYPE global_avg[3] = {0,0,0};
|
||||
int i = 0;
|
||||
|
||||
/* This function does two things: first, it determines the average data chunk
|
||||
** size in the file view for each process and across all processes.
|
||||
** Second, it establishes whether the view across all processes is uniform.
|
||||
** By definition, uniform means:
|
||||
** 1. the file view of each process has the same number of contiguous sections
|
||||
** 2. each section in the file view has exactly the same size
|
||||
*/
|
||||
|
||||
for (i=0 ; i<(int)fh->f_iov_count ; i++) {
|
||||
avg[0] += fh->f_decoded_iov[i].iov_len;
|
||||
if (i && 0 == uniform) {
|
||||
if (fh->f_decoded_iov[i].iov_len != fh->f_decoded_iov[i-1].iov_len) {
|
||||
uniform = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( 0 != fh->f_iov_count ) {
|
||||
avg[0] = avg[0]/fh->f_iov_count;
|
||||
}
|
||||
avg[1] = (OMPI_MPI_OFFSET_TYPE) fh->f_iov_count;
|
||||
avg[2] = (OMPI_MPI_OFFSET_TYPE) uniform;
|
||||
|
||||
fh->f_comm->c_coll.coll_allreduce (avg,
|
||||
global_avg,
|
||||
3,
|
||||
OMPI_OFFSET_DATATYPE,
|
||||
MPI_SUM,
|
||||
fh->f_comm,
|
||||
fh->f_comm->c_coll.coll_allreduce_module);
|
||||
global_avg[0] = global_avg[0]/fh->f_size;
|
||||
global_avg[1] = global_avg[1]/fh->f_size;
|
||||
|
||||
#if 0
|
||||
/* Disabling the feature since we are not using it anyway. Saves us one allreduce operation. */
|
||||
int global_uniform=0;
|
||||
|
||||
if ( global_avg[0] == avg[0] &&
|
||||
global_avg[1] == avg[1] &&
|
||||
0 == avg[2] &&
|
||||
0 == global_avg[2] ) {
|
||||
uniform = 0;
|
||||
}
|
||||
else {
|
||||
uniform = 1;
|
||||
}
|
||||
|
||||
/* second confirmation round to see whether all processes agree
|
||||
** on having a uniform file view or not
|
||||
*/
|
||||
fh->f_comm->c_coll.coll_allreduce (&uniform,
|
||||
&global_uniform,
|
||||
1,
|
||||
MPI_INT,
|
||||
MPI_MAX,
|
||||
fh->f_comm,
|
||||
fh->f_comm->c_coll.coll_allreduce_module);
|
||||
|
||||
if ( 0 == global_uniform ){
|
||||
/* yes, everybody agrees on having a uniform file view */
|
||||
fh->f_flags |= OMPIO_UNIFORM_FVIEW;
|
||||
}
|
||||
#endif
|
||||
return global_avg[0];
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,12 +59,12 @@ int mca_sharedfp_addproc_file_open (struct ompi_communicator_t *comm,
|
||||
data = (mca_io_ompio_data_t *) fh->f_fh->f_io_selected_data;
|
||||
ompio_fh = &data->ompio_fh;
|
||||
|
||||
err = mca_io_ompio_set_view_internal (shfileHandle,
|
||||
ompio_fh->f_disp,
|
||||
ompio_fh->f_etype,
|
||||
ompio_fh->f_orig_filetype,
|
||||
ompio_fh->f_datarep,
|
||||
MPI_INFO_NULL);
|
||||
err = mca_common_ompio_set_view (shfileHandle,
|
||||
ompio_fh->f_disp,
|
||||
ompio_fh->f_etype,
|
||||
ompio_fh->f_orig_filetype,
|
||||
ompio_fh->f_datarep,
|
||||
MPI_INFO_NULL);
|
||||
|
||||
/*Memory is allocated here for the sh structure*/
|
||||
if ( mca_sharedfp_addproc_verbose ) {
|
||||
|
@ -60,13 +60,13 @@ int mca_sharedfp_lockedfile_file_open (struct ompi_communicator_t *comm,
|
||||
data = (mca_io_ompio_data_t *) fh->f_fh->f_io_selected_data;
|
||||
ompio_fh = &data->ompio_fh;
|
||||
|
||||
err = mca_io_ompio_set_view_internal (shfileHandle,
|
||||
ompio_fh->f_disp,
|
||||
ompio_fh->f_etype,
|
||||
ompio_fh->f_orig_filetype,
|
||||
ompio_fh->f_datarep,
|
||||
MPI_INFO_NULL);
|
||||
|
||||
err = mca_common_ompio_set_view (shfileHandle,
|
||||
ompio_fh->f_disp,
|
||||
ompio_fh->f_etype,
|
||||
ompio_fh->f_orig_filetype,
|
||||
ompio_fh->f_datarep,
|
||||
MPI_INFO_NULL);
|
||||
|
||||
|
||||
/*Memory is allocated here for the sh structure*/
|
||||
sh = (struct mca_sharedfp_base_data_t*)malloc(sizeof(struct mca_sharedfp_base_data_t));
|
||||
|
@ -79,12 +79,12 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
|
||||
data = (mca_io_ompio_data_t *) fh->f_fh->f_io_selected_data;
|
||||
ompio_fh = &data->ompio_fh;
|
||||
|
||||
err = mca_io_ompio_set_view_internal (shfileHandle,
|
||||
ompio_fh->f_disp,
|
||||
ompio_fh->f_etype,
|
||||
ompio_fh->f_orig_filetype,
|
||||
ompio_fh->f_datarep,
|
||||
MPI_INFO_NULL);
|
||||
err = mca_common_ompio_set_view (shfileHandle,
|
||||
ompio_fh->f_disp,
|
||||
ompio_fh->f_etype,
|
||||
ompio_fh->f_orig_filetype,
|
||||
ompio_fh->f_datarep,
|
||||
MPI_INFO_NULL);
|
||||
|
||||
/*Memory is allocated here for the sh structure*/
|
||||
if ( mca_sharedfp_sm_verbose ) {
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user