Skip to content

Commit e47e525

Browse files
committed
formatting for resize
1 parent d0a143f commit e47e525

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

src/mpi/romio/adio/ad_unify/Makefile.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ romio_other_sources += \
1616
adio/ad_unify/ad_unify_io.c \
1717
adio/ad_unify/ad_unify_flush.c \
1818
adio/ad_unify/ad_unify_delete.c \
19-
adio/ad_unify/ad_unify_fcntl.c
19+
adio/ad_unify/ad_unify_fcntl.c \
20+
adio/ad_unify/ad_unify_resize.c
2021

2122
endif BUILD_AD_UNIFY
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (C) by Argonne National Laboratory
3+
* See COPYRIGHT in top-level directory
4+
*/
5+
6+
#include "ad_unify.h"
7+
#include "ad_unify_common.h"
8+
9+
/* as with ADIOI_PVFS2_Flush, implement the resize operation in a scalable
10+
* manner. one process does the work, then broadcasts the result to everyone
11+
* else. fortunately, this operation is defined to be collective */
12+
void ADIOI_UNIFY_Resize(ADIO_File fd, ADIO_Offset size, int *error_code)
13+
{
14+
int ret, rank;
15+
ADIOI_UNIFY_fs *unifyfs_blob = fd->fs_ptr;
16+
17+
*error_code = MPI_SUCCESS;
18+
19+
unifyfs_io_request truncate_req = {
20+
.gfid = unifyfs_blob->gfid,
21+
.offset = size,
22+
.op = UNIFYFS_IOREQ_OP_TRUNC,
23+
};
24+
25+
MPI_Comm_rank(fd->comm, &rank);
26+
27+
/* MPI-IO semantics treat conflicting MPI_File_set_size requests the
28+
* same as conflicting write requests. Thus, a resize from one
29+
* process does not have to be visible to the other processes until a
30+
* synchronization point is reached */
31+
32+
if (rank == fd->hints->ranklist[0]) {
33+
ret = unifyfs_dispatch_io(unifyfs_blob->fshdl, 1, &truncate_req);
34+
if (ret != UNIFYFS_SUCCESS) {
35+
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
36+
MPIR_ERR_RECOVERABLE,
37+
__func__, __LINE__, MPI_ERR_IO, "Error in Dispatch:",
38+
"%s", strerror(ret));
39+
goto exit;
40+
}
41+
ret = unifyfs_wait_io(unifyfs_blob->fshdl, 1, &truncate_req, 1);
42+
if (ret != UNIFYFS_SUCCESS) {
43+
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
44+
MPIR_ERR_RECOVERABLE,
45+
__func__, __LINE__, MPI_ERR_IO, "Error in I/O Wait:",
46+
"%s", strerror(ret));
47+
goto exit;
48+
}
49+
if (truncate_req.result.error != UNIFYFS_SUCCESS) {
50+
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
51+
MPIR_ERR_RECOVERABLE,
52+
__func__, __LINE__, MPI_ERR_IO,
53+
"Error in I/O operation:", "%s",
54+
strerror(truncate_req.result.error));
55+
ret = truncate_req.result.error;
56+
goto exit;
57+
}
58+
59+
}
60+
exit:
61+
MPI_Bcast(&ret, 1, MPI_INT, fd->hints->ranklist[0], fd->comm);
62+
/* --BEGIN ERROR HANDLING-- */
63+
if (ret != 0) {
64+
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
65+
MPIR_ERR_RECOVERABLE,
66+
__func__, __LINE__,
67+
MPI_ERR_IO, "Error in Unify Truncate", 0);
68+
return;
69+
}
70+
/* --END ERROR HANDLING-- */
71+
}

0 commit comments

Comments
 (0)