Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
libcdi
Commits
e2bf84ed
Commit
e2bf84ed
authored
8 years ago
by
Thomas Jahns
Committed by
Sergey Kosukhin
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Switch PIO MPI_File_write_ordered backend to reliable file IDs.
parent
218ed261
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!34
Version 2.2.0
,
!13
Consolidation with CDI-PIO (develop)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pio_mpi_fw_ordered.c
+36
-53
36 additions, 53 deletions
src/pio_mpi_fw_ordered.c
with
36 additions
and
53 deletions
src/pio_mpi_fw_ordered.c
+
36
−
53
View file @
e2bf84ed
...
...
@@ -2,6 +2,7 @@
#include
"config.h"
#endif
#include
<assert.h>
#include
<inttypes.h>
#include
<limits.h>
#include
<stdbool.h>
...
...
@@ -24,22 +25,16 @@ struct fileMPIFWO
int
fileID
;
};
static
listSet
*
bibAFiledataM
;
static
int
fileIDTest
(
void
*
a
,
void
*
fileID
)
{
return
((
struct
fileMPIFWO
*
)
a
)
->
fileID
==
(
int
)
(
intptr_t
)
fileID
;
}
static
struct
fileMPIFWO
*
openFiles
;
static
unsigned
openFilesSize
,
openFilesFill
;
/***************************************************************/
static
struct
fileMPIFWO
*
initAFiledataFileWriteOrdered
(
const
char
*
filename
,
size_t
bs
)
static
void
initAFiledataFileWriteOrdered
(
struct
fileMPIFWO
*
of
,
const
char
*
filename
,
size_t
bs
)
{
MPI_Comm
commPio
=
commInqCommPio
();
size_t
nameSize
=
strlen
(
filename
)
+
1
;
struct
fileMPIFWO
*
of
=
Malloc
(
sizeof
(
*
of
));
of
->
name
=
Malloc
(
nameSize
);
strcpy
(
of
->
name
,
filename
);
...
...
@@ -56,16 +51,13 @@ initAFiledataFileWriteOrdered(const char *filename, size_t bs)
}
xmpi
(
MPI_File_open
(
commPio
,
of
->
name
,
MPI_MODE_CREATE
|
MPI_MODE_WRONLY
|
MPI_MODE_UNIQUE_OPEN
,
open_info
,
&
of
->
fh
));
xmpi
(
MPI_Info_free
(
&
open_info
));
return
of
;
}
/***************************************************************/
static
int
destroyAFiledataFileWriteOrdered
(
void
*
v
)
destroyAFiledataFileWriteOrdered
(
struct
fileMPIFWO
*
of
)
{
struct
fileMPIFWO
*
of
=
v
;
/* close file */
MPI_Offset
endpos
,
fsize
;
xmpi
(
MPI_File_get_position_shared
(
of
->
fh
,
&
endpos
));
...
...
@@ -78,27 +70,17 @@ destroyAFiledataFileWriteOrdered(void *v)
int
iret
=
MPI_File_close
(
&
of
->
fh
);
Free
(
of
->
name
);
of
->
name
=
NULL
;
Free
(
of
);
return
iret
==
MPI_SUCCESS
?
0
:
-
1
;
}
/***************************************************************/
static
bool
compareNamesFileWriteOrdered
(
void
*
v1
,
void
*
v2
)
{
struct
fileMPIFWO
*
afm1
=
v1
,
*
afm2
=
v2
;
return
!
strcmp
(
afm1
->
name
,
afm2
->
name
);
}
/***************************************************************/
static
size_t
fwFileWriteOrdered
(
int
fileID
,
const
void
*
buffer
,
size_t
len
)
{
struct
fileMPIFWO
*
of
=
listSetGet
(
bibAFiledataM
,
fileIDTest
,
(
void
*
)
(
intptr_t
)
fileID
);
xassert
(
of
)
;
assert
(
fileID
>=
0
&&
(
size_t
)
fileID
<
openFilesSize
&&
openFiles
[
fileID
].
name
);
struct
fileMPIFWO
*
of
=
openFiles
+
fileID
;
/* write buffer */
xassert
(
len
<=
INT_MAX
);
...
...
@@ -112,21 +94,13 @@ fwFileWriteOrdered(int fileID, const void *buffer, size_t len)
static
int
fcFileWriteOrdered
(
int
fileID
)
{
struct
fileMPIFWO
*
of
=
listSetGet
(
bibAFiledataM
,
fileIDTest
,
(
void
*
)
(
intptr_t
)
fileID
);
if
(
!
of
)
xabort
(
"listSet, fileID=%d not found"
,
fileID
)
;
int
iret
=
listSetRemove
(
bibAFiledataM
,
fileIDTest
,
(
void
*
)
(
intptr_t
)
fileID
);
assert
(
fileID
>=
0
&&
(
size_t
)
fileID
<
openFilesSize
&&
openFiles
[
fileID
].
name
);
struct
fileMPIFWO
*
of
=
openFiles
+
fileID
;
int
iret
=
destroyAFiledataFileWriteOrdered
(
of
);
return
iret
;
}
/***************************************************************/
static
void
elemCheck
(
void
*
q
,
void
*
nm
)
{
struct
fileMPIFWO
*
afm
=
q
;
const
char
*
name
=
nm
;
if
(
!
strcmp
(
name
,
afm
->
name
))
xabort
(
"Filename %s has already been added to set
\n
"
,
name
);
}
static
int
fowFileWriteOrdered
(
const
char
*
filename
,
const
char
*
mode
)
...
...
@@ -136,12 +110,28 @@ fowFileWriteOrdered(const char *filename, const char *mode)
struct
cdiPioConf
*
conf
=
cdiPioGetConf
();
listSetForeach
(
bibAFiledataM
,
elemCheck
,
(
void
*
)
filename
);
struct
fileMPIFWO
*
of
=
initAFiledataFileWriteOrdered
(
filename
,
conf
->
writeAggBufLim
);
int
id
;
if
((
of
->
fileID
=
id
=
listSetAdd
(
bibAFiledataM
,
of
))
<
0
)
xabort
(
"filename %s not unique"
,
of
->
name
);
return
id
;
size_t
fileID
=
SIZE_MAX
;
if
(
openFilesSize
==
openFilesFill
)
{
fileID
=
openFilesSize
;
if
(
openFilesSize
==
(
size_t
)
INT_MAX
+
1
)
return
CDI_ELIMIT
;
openFilesSize
=
openFilesSize
?
openFilesSize
*
2
:
4
;
if
(
openFilesSize
>
(
size_t
)
INT_MAX
+
1
)
openFilesSize
=
(
size_t
)
INT_MAX
+
1
;
openFiles
=
Realloc
(
openFiles
,
sizeof
(
*
openFiles
)
*
openFilesSize
);
for
(
size_t
i
=
fileID
;
i
<
openFilesSize
;
++
i
)
openFiles
[
i
].
name
=
NULL
;
}
else
{
for
(
size_t
i
=
0
;
i
<
openFilesSize
;
++
i
)
if
(
openFiles
[
i
].
name
==
NULL
)
{
fileID
=
i
;
break
;
}
}
struct
fileMPIFWO
*
of
=
openFiles
+
fileID
;
initAFiledataFileWriteOrdered
(
of
,
filename
,
conf
->
writeAggBufLim
);
return
(
int
)
fileID
;
}
/***************************************************************/
...
...
@@ -149,13 +139,10 @@ fowFileWriteOrdered(const char *filename, const char *mode)
static
void
finalizeFileWriteOrdered
(
void
)
{
if
(
!
listSetIsEmpty
(
bibAFiledataM
)
)
xabort
(
"
set bibAFiledataM not empty
"
);
if
(
openFilesFill
)
xabort
(
"
files still open on exit!
"
);
else
{
xdebug
(
"%s"
,
"destroy set"
);
listSetDelete
(
bibAFiledataM
);
}
Free
(
openFiles
);
}
/***************************************************************/
...
...
@@ -163,14 +150,10 @@ finalizeFileWriteOrdered(void)
void
cdiPioFileWriteOrderedInit
(
void
)
{
bibAFiledataM
=
listSetNew
(
destroyAFiledataFileWriteOrdered
,
compareNamesFileWriteOrdered
);
namespaceSwitchSet
(
NSSWITCH_FILE_OPEN
,
NSSW_FUNC
(
fowFileWriteOrdered
));
namespaceSwitchSet
(
NSSWITCH_FILE_CLOSE
,
NSSW_FUNC
(
fcFileWriteOrdered
));
namespaceSwitchSet
(
NSSWITCH_FILE_WRITE
,
NSSW_FUNC
(
fwFileWriteOrdered
));
namespaceSwitchSet
(
cdiPioExtraNSKeys
[
cdiPioEKFileWritingFinalize
],
NSSW_FUNC
(
finalizeFileWriteOrdered
));
if
(
bibAFiledataM
==
NULL
)
xabort
(
"listSetNew did not succeed"
);
}
/*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment