📄 mpich-1.2.6-lustre.patch
字号:
diff -r -u --new-file mpich-1.2.6/romio/adio/ad_lustre/ad_lustre.c mpich-1.2.6/romio/adio/ad_lustre/ad_lustre.c--- mpich-1.2.6/romio/adio/ad_lustre/ad_lustre.c 1969-12-31 19:00:00.000000000 -0500+++ mpich-1.2.6/romio/adio/ad_lustre/ad_lustre.c 2005-12-06 11:54:37.883130927 -0500@@ -0,0 +1,37 @@+/* -*- Mode: C; c-basic-offset:4 ; -*- */+/* + * $Id: ad_lustre.c,v 1.1.1.1 2004/11/04 11:03:38 liam Exp $+ *+ * Copyright (C) 2001 University of Chicago. + * See COPYRIGHT notice in top-level directory.+ */++#include "ad_lustre.h"++/* adioi.h has the ADIOI_Fns_struct define */+#include "adioi.h"++struct ADIOI_Fns_struct ADIO_LUSTRE_operations = {+ ADIOI_LUSTRE_Open, /* Open */+ ADIOI_LUSTRE_ReadContig, /* ReadContig */+ ADIOI_LUSTRE_WriteContig, /* WriteContig */+ ADIOI_GEN_ReadStridedColl, /* ReadStridedColl */+ ADIOI_GEN_WriteStridedColl, /* WriteStridedColl */+ ADIOI_GEN_SeekIndividual, /* SeekIndividual */+ ADIOI_LUSTRE_Fcntl, /* Fcntl */+ ADIOI_LUSTRE_SetInfo, /* SetInfo */+ ADIOI_GEN_ReadStrided, /* ReadStrided */+ ADIOI_GEN_WriteStrided, /* WriteStrided */+ ADIOI_LUSTRE_Close, /* Close */+ ADIOI_LUSTRE_IreadContig, /* IreadContig */+ ADIOI_LUSTRE_IwriteContig, /* IwriteContig */+ ADIOI_LUSTRE_ReadDone, /* ReadDone */+ ADIOI_LUSTRE_WriteDone, /* WriteDone */+ ADIOI_LUSTRE_ReadComplete, /* ReadComplete */+ ADIOI_LUSTRE_WriteComplete, /* WriteComplete */+ ADIOI_LUSTRE_IreadStrided, /* IreadStrided */+ ADIOI_LUSTRE_IwriteStrided, /* IwriteStrided */+ ADIOI_GEN_Flush, /* Flush */+ ADIOI_LUSTRE_Resize, /* Resize */+ ADIOI_GEN_Delete, /* Delete */+};diff -r -u --new-file mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_close.c mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_close.c--- mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_close.c 1969-12-31 19:00:00.000000000 -0500+++ mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_close.c 2005-12-06 11:54:37.895129327 -0500@@ -0,0 +1,32 @@+/* -*- Mode: C; c-basic-offset:4 ; -*- */+/* + * $Id: ad_lustre_close.c,v 1.1.1.1 2004/11/04 11:03:38 liam Exp $ + *+ * Copyright (C) 1997 University of Chicago. + * See COPYRIGHT notice in top-level directory.+ */++#include "ad_lustre.h"++void ADIOI_LUSTRE_Close(ADIO_File fd, int *error_code)+{+ int err;+#if defined(MPICH2) || !defined(PRINT_ERR_MSG)+ static char myname[] = "ADIOI_LUSTRE_CLOSE";+#endif++ err = close(fd->fd_sys);+ if (err == -1) {+#ifdef MPICH2+ *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",+ "**io %s", strerror(errno));+#elif defined(PRINT_ERR_MSG)+ *error_code = MPI_ERR_UNKNOWN;+#else+ *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,+ myname, "I/O Error", "%s", strerror(errno));+ ADIOI_Error(fd, *error_code, myname); +#endif+ }+ else *error_code = MPI_SUCCESS;+}diff -r -u --new-file mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_done.c mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_done.c--- mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_done.c 1969-12-31 19:00:00.000000000 -0500+++ mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_done.c 2005-12-06 11:54:37.898128927 -0500@@ -0,0 +1,188 @@+/* -*- Mode: C; c-basic-offset:4 ; -*- */+/* + * $Id: ad_lustre_done.c,v 1.1.1.1 2004/11/04 11:03:38 liam Exp $ + *+ * Copyright (C) 1997 University of Chicago. + * See COPYRIGHT notice in top-level directory.+ */++#include "ad_lustre.h"++int ADIOI_LUSTRE_ReadDone(ADIO_Request *request, ADIO_Status *status, int *error_code) +{+#ifndef NO_AIO+ int done=0;+#if defined(MPICH2) || !defined(PRINT_ERR_MSG)+ static char myname[] = "ADIOI_LUSTRE_READDONE";+#endif+#ifdef AIO_SUN + aio_result_t *result=0, *tmp;+#else+ int err;+#endif+#ifdef AIO_HANDLE_IN_AIOCB+ struct aiocb *tmp1;+#endif+#endif++ if (*request == ADIO_REQUEST_NULL) {+ *error_code = MPI_SUCCESS;+ return 1;+ }++#ifdef NO_AIO+/* HP, FreeBSD, Linux */+#ifdef HAVE_STATUS_SET_BYTES+ MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);+#endif+ (*request)->fd->async_count--;+ ADIOI_Free_request((ADIOI_Req_node *) (*request));+ *request = ADIO_REQUEST_NULL;+ *error_code = MPI_SUCCESS;+ return 1;+#endif ++#ifdef AIO_SUN+ if ((*request)->queued) {+ tmp = (aio_result_t *) (*request)->handle;+ if (tmp->aio_return == AIO_INPROGRESS) {+ done = 0;+ *error_code = MPI_SUCCESS;+ }+ else if (tmp->aio_return != -1) {+ result = (aio_result_t *) aiowait(0); /* dequeue any one request */+ done = 1;+ (*request)->nbytes = tmp->aio_return;+ *error_code = MPI_SUCCESS;+ }+ else {+#ifdef MPICH2+ *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",+ "**io %s", strerror(tmp->aio_errno));+ return;+#elif defined(PRINT_ERR_MSG)+ *error_code = MPI_ERR_UNKNOWN;+#else+ *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,+ myname, "I/O Error", "%s", strerror(tmp->aio_errno));+ ADIOI_Error((*request)->fd, *error_code, myname); +#endif+ }+ } /* if ((*request)->queued) ... */+ else {+ /* ADIOI_Complete_Async completed this request, but request object+ was not freed. */+ done = 1;+ *error_code = MPI_SUCCESS;+ }+#ifdef HAVE_STATUS_SET_BYTES+ if (done && ((*request)->nbytes != -1))+ MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);+#endif++#endif++#ifdef AIO_HANDLE_IN_AIOCB+/* IBM */+ if ((*request)->queued) {+ tmp1 = (struct aiocb *) (*request)->handle;+ errno = aio_error(tmp1->aio_handle);+ if (errno == EINPROG) {+ done = 0;+ *error_code = MPI_SUCCESS;+ }+ else {+ err = aio_return(tmp1->aio_handle);+ (*request)->nbytes = err;+ errno = aio_error(tmp1->aio_handle);+ + done = 1;++ if (err == -1) {+#ifdef MPICH2+ *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",+ "**io %s", strerror(errno));+ return;+#elif defined(PRINT_ERR_MSG)+ *error_code = MPI_ERR_UNKNOWN;+#else+ *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,+ myname, "I/O Error", "%s", strerror(errno));+ ADIOI_Error((*request)->fd, *error_code, myname); +#endif+ }+ else *error_code = MPI_SUCCESS;+ }+ } /* if ((*request)->queued) */+ else {+ done = 1;+ *error_code = MPI_SUCCESS;+ }+#ifdef HAVE_STATUS_SET_BYTES+ if (done && ((*request)->nbytes != -1))+ MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);+#endif++#elif (!defined(NO_AIO) && !defined(AIO_SUN))+/* DEC, SGI IRIX 5 and 6 */+ if ((*request)->queued) {+ errno = aio_error((const struct aiocb *) (*request)->handle);+ if (errno == EINPROGRESS) {+ done = 0;+ *error_code = MPI_SUCCESS;+ }+ else {+ err = aio_return((struct aiocb *) (*request)->handle); + (*request)->nbytes = err;+ errno = aio_error((struct aiocb *) (*request)->handle);++ done = 1;++ if (err == -1) {+#ifdef MPICH2+ *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",+ "**io %s", strerror(errno));+ return;+#elif defined(PRINT_ERR_MSG)+ *error_code = MPI_ERR_UNKNOWN;+#else /* MPICH-1 */+ *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,+ myname, "I/O Error", "%s", strerror(errno));+ ADIOI_Error((*request)->fd, *error_code, myname); +#endif+ }+ else *error_code = MPI_SUCCESS;+ }+ } /* if ((*request)->queued) */+ else {+ done = 1;+ *error_code = MPI_SUCCESS;+ }+#ifdef HAVE_STATUS_SET_BYTES+ if (done && ((*request)->nbytes != -1))+ MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);+#endif++#endif++#ifndef NO_AIO+ if (done) {+ /* if request is still queued in the system, it is also there+ on ADIOI_Async_list. Delete it from there. */+ if ((*request)->queued) ADIOI_Del_req_from_list(request);++ (*request)->fd->async_count--;+ if ((*request)->handle) ADIOI_Free((*request)->handle);+ ADIOI_Free_request((ADIOI_Req_node *) (*request));+ *request = ADIO_REQUEST_NULL;+ }+ return done;+#endif++}+++int ADIOI_LUSTRE_WriteDone(ADIO_Request *request, ADIO_Status *status, int *error_code) +{+ return ADIOI_LUSTRE_ReadDone(request, status, error_code);+} diff -r -u --new-file mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_fcntl.c mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_fcntl.c--- mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_fcntl.c 1969-12-31 19:00:00.000000000 -0500+++ mpich-1.2.6/romio/adio/ad_lustre/ad_lustre_fcntl.c 2005-12-06 11:54:37.901128527 -0500@@ -0,0 +1,126 @@+/* -*- Mode: C; c-basic-offset:4 ; -*- */+/* + * $Id: ad_lustre_fcntl.c,v 1.1.1.1 2004/11/04 11:03:38 liam Exp $ + *+ * Copyright (C) 1997 University of Chicago. + * See COPYRIGHT notice in top-level directory.+ */++#include "ad_lustre.h"+#include "adio_extern.h"+/* #ifdef MPISGI+#include "mpisgi2.h"+#endif */++void ADIOI_LUSTRE_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)+{+ int i, ntimes;+ ADIO_Offset curr_fsize, alloc_size, size, len, done;+ ADIO_Status status;+ char *buf;+#if defined(MPICH2) || !defined(PRINT_ERR_MSG)+ static char myname[] = "ADIOI_LUSTRE_FCNTL";+#endif++ switch(flag) {+ case ADIO_FCNTL_GET_FSIZE:+ fcntl_struct->fsize = lseek(fd->fd_sys, 0, SEEK_END);+ if (fd->fp_sys_posn != -1) + lseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);+ if (fcntl_struct->fsize == -1) {+#ifdef MPICH2+ *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",+ "**io %s", strerror(errno));+#elif defined(PRINT_ERR_MSG)+ *error_code = MPI_ERR_UNKNOWN;+#else /* MPICH-1 */+ *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,+ myname, "I/O Error", "%s", strerror(errno));+ ADIOI_Error(fd, *error_code, myname); +#endif+ }+ else *error_code = MPI_SUCCESS;+ break;++ case ADIO_FCNTL_SET_DISKSPACE:+ /* will be called by one process only */+ /* On file systems with no preallocation function, I have to + explicitly write + to allocate space. Since there could be holes in the file, + I need to read up to the current file size, write it back, + and then write beyond that depending on how much + preallocation is needed.+ read/write in sizes of no more than ADIOI_PREALLOC_BUFSZ */++ curr_fsize = lseek(fd->fd_sys, 0, SEEK_END);+ alloc_size = fcntl_struct->diskspace;++ size = ADIOI_MIN(curr_fsize, alloc_size);+ + ntimes = (size + ADIOI_PREALLOC_BUFSZ - 1)/ADIOI_PREALLOC_BUFSZ;+ buf = (char *) ADIOI_Malloc(ADIOI_PREALLOC_BUFSZ);+ done = 0;++ for (i=0; i<ntimes; i++) {+ len = ADIOI_MIN(size-done, ADIOI_PREALLOC_BUFSZ);+ ADIO_ReadContig(fd, buf, len, MPI_BYTE, ADIO_EXPLICIT_OFFSET, done,+ &status, error_code);+ if (*error_code != MPI_SUCCESS) {+ ADIOI_Free(buf);+#ifdef MPICH2+ *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",+ "**io %s", strerror(errno));+#elif defined(PRINT_ERR_MSG)+ FPRINTF(stderr, "ADIOI_LUSTRE_Fcntl: To preallocate disk space, ROMIO needs to read the file and write it back, but is unable to read the file. Please give the file read permission and open it with MPI_MODE_RDWR.\n");+ MPI_Abort(MPI_COMM_WORLD, 1);+#else /* MPICH-1 */+ *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_PREALLOC_PERM,+ myname, (char *) 0, (char *) 0);+ ADIOI_Error(fd, *error_code, myname);+#endif+ return; + }+ ADIO_WriteContig(fd, buf, len, MPI_BYTE, ADIO_EXPLICIT_OFFSET, + done, &status, error_code);+ if (*error_code != MPI_SUCCESS) return;+ done += len;+ }++ if (alloc_size > curr_fsize) {+ memset(buf, 0, ADIOI_PREALLOC_BUFSZ); + size = alloc_size - curr_fsize;+ ntimes = (size + ADIOI_PREALLOC_BUFSZ - 1)/ADIOI_PREALLOC_BUFSZ;+ for (i=0; i<ntimes; i++) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -