2011-08-26 00:08:17 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2011-10-04 18:56:34 +04:00
|
|
|
* Copyright (c) 2004-2011 The University of Tennessee and The University
|
2011-08-26 00:08:17 +04:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2015-06-24 06:59:57 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2011-08-26 00:08:17 +04:00
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2015-01-29 19:23:36 +03:00
|
|
|
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
|
2015-03-03 08:38:34 +03:00
|
|
|
* Copyright (c) 2015 Research Organization for Information Science
|
|
|
|
* and Technology (RIST). All rights reserved.
|
2011-08-26 00:08:17 +04:00
|
|
|
* $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2011-08-26 00:08:17 +04:00
|
|
|
* Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2011-08-26 00:08:17 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include "fbtl_posix.h"
|
|
|
|
|
2014-09-24 01:27:57 +04:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#if HAVE_AIO_H
|
|
|
|
#include <aio.h>
|
|
|
|
#endif
|
|
|
|
|
2011-08-26 00:08:17 +04:00
|
|
|
#include "mpi.h"
|
|
|
|
#include "ompi/constants.h"
|
|
|
|
#include "ompi/mca/fbtl/fbtl.h"
|
|
|
|
|
2014-09-24 01:27:57 +04:00
|
|
|
ssize_t mca_fbtl_posix_ipreadv (mca_io_ompio_file_t *fh,
|
|
|
|
ompi_request_t *request)
|
2011-08-26 00:08:17 +04:00
|
|
|
{
|
2014-09-24 01:27:57 +04:00
|
|
|
#if defined (FBTL_POSIX_HAVE_AIO)
|
|
|
|
mca_fbtl_posix_request_data_t *data;
|
|
|
|
mca_ompio_request_t *req = (mca_ompio_request_t *) request;
|
|
|
|
int i=0;
|
|
|
|
|
|
|
|
data = (mca_fbtl_posix_request_data_t *) malloc ( sizeof (mca_fbtl_posix_request_data_t));
|
|
|
|
if ( NULL == data ) {
|
|
|
|
opal_output (1,"could not allocate memory\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2014-09-24 01:27:57 +04:00
|
|
|
data->aio_req_count = fh->f_num_of_io_entries;
|
|
|
|
data->aio_open_reqs = fh->f_num_of_io_entries;
|
2015-01-29 19:23:36 +03:00
|
|
|
data->aio_req_type = FBTL_POSIX_READ;
|
|
|
|
data->aio_req_chunks = fbtl_posix_max_aio_active_reqs;
|
2014-09-24 01:27:57 +04:00
|
|
|
data->aio_total_len = 0;
|
2015-06-24 06:59:57 +03:00
|
|
|
data->aio_reqs = (struct aiocb *) malloc (sizeof(struct aiocb) *
|
2014-09-24 01:27:57 +04:00
|
|
|
fh->f_num_of_io_entries);
|
|
|
|
if (NULL == data->aio_reqs) {
|
|
|
|
opal_output(1, "OUT OF MEMORY\n");
|
2015-03-03 08:38:34 +03:00
|
|
|
free(data);
|
2014-09-24 01:27:57 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->aio_req_status = (int *) malloc (sizeof(int) * fh->f_num_of_io_entries);
|
|
|
|
if (NULL == data->aio_req_status) {
|
|
|
|
opal_output(1, "OUT OF MEMORY\n");
|
2015-03-03 08:38:34 +03:00
|
|
|
free(data->aio_reqs);
|
|
|
|
free(data);
|
2014-09-24 01:27:57 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( i=0; i<fh->f_num_of_io_entries; i++ ) {
|
|
|
|
data->aio_reqs[i].aio_offset = (OMPI_MPI_OFFSET_TYPE)(intptr_t)
|
|
|
|
fh->f_io_array[i].offset;
|
|
|
|
data->aio_reqs[i].aio_buf = fh->f_io_array[i].memory_address;
|
|
|
|
data->aio_reqs[i].aio_nbytes = fh->f_io_array[i].length;
|
|
|
|
data->aio_reqs[i].aio_fildes = fh->fd;
|
|
|
|
data->aio_reqs[i].aio_reqprio = 0;
|
|
|
|
data->aio_reqs[i].aio_sigevent.sigev_notify = SIGEV_NONE;
|
|
|
|
data->aio_req_status[i] = EINPROGRESS;
|
2015-01-29 19:23:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
data->aio_first_active_req = 0;
|
|
|
|
if ( data->aio_req_count > data->aio_req_chunks ) {
|
|
|
|
data->aio_last_active_req = data->aio_req_chunks;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
data->aio_last_active_req = data->aio_req_count;
|
2015-06-24 06:59:57 +03:00
|
|
|
}
|
2015-01-29 19:23:36 +03:00
|
|
|
for (i=0; i < data->aio_last_active_req; i++) {
|
2014-09-24 01:27:57 +04:00
|
|
|
if (-1 == aio_read(&data->aio_reqs[i])) {
|
2015-03-03 08:38:34 +03:00
|
|
|
opal_output(1, "aio_read() error: %s", strerror(errno));
|
|
|
|
free(data->aio_reqs);
|
|
|
|
free(data->aio_req_status);
|
|
|
|
free(data);
|
2014-09-24 01:27:57 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
req->req_data = data;
|
|
|
|
req->req_progress_fn = mca_fbtl_posix_progress;
|
|
|
|
req->req_free_fn = mca_fbtl_posix_request_free;
|
|
|
|
#endif
|
2011-08-26 00:08:17 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|