Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
d9c7e662
Commit
d9c7e662
authored
8 months ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for ResumingUtils checkpointing
parent
16d445be
No related branches found
No related tags found
1 merge request
!199
Integrate checkpointing
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/CMakeLists.txt
+3
-1
3 additions, 1 deletion
tests/CMakeLists.txt
tests/test_checkpointing_ResumingUtils.cpp
+77
-0
77 additions, 0 deletions
tests/test_checkpointing_ResumingUtils.cpp
with
80 additions
and
1 deletion
tests/CMakeLists.txt
+
3
−
1
View file @
d9c7e662
...
...
@@ -157,7 +157,9 @@ add_executable (unit_tests
test_WhileProcessor.cpp
)
set
(
checkpointing_TESTS
)
set
(
checkpointing_TESTS
test_checkpointing_ResumingUtils.cpp
)
if
(
PUGS_HAS_HDF5
)
list
(
APPEND checkpointing_TESTS
...
...
This diff is collapsed.
Click to expand it.
tests/test_checkpointing_ResumingUtils.cpp
0 → 100644
+
77
−
0
View file @
d9c7e662
#include
<catch2/catch_test_macros.hpp>
#include
<catch2/matchers/catch_matchers_all.hpp>
#include
<utils/HighFivePugsUtils.hpp>
#include
<utils/Messenger.hpp>
#include
<utils/checkpointing/ResumingUtils.hpp>
#include
<filesystem>
// clazy:excludeall=non-pod-global-static
TEST_CASE
(
"ResumingUtils"
,
"[utils/checkpointing]"
)
{
#ifdef PUGS_HAS_HDF5
std
::
string
tmp_dirname
;
{
{
if
(
parallel
::
rank
()
==
0
)
{
tmp_dirname
=
[
&
]()
->
std
::
string
{
std
::
string
temp_filename
=
std
::
filesystem
::
temp_directory_path
()
/
"pugs_checkpointing_XXXXXX"
;
return
std
::
string
{
mkdtemp
(
&
temp_filename
[
0
])};
}();
}
parallel
::
broadcast
(
tmp_dirname
,
0
);
}
std
::
filesystem
::
path
path
=
tmp_dirname
;
const
std
::
string
filename
=
path
/
"checkpoint.h5"
;
const
std
::
string
data_file0
=
R"(Un tiens vaut mieux que deux tu l'auras,
Un tiens vaut mieux que deux tu l'auras,...)"
;
const
std
::
string
data_file1
=
R"(All work and no play makes Jack a dull boy,
All work and no play makes Jack a dull boy,...)"
;
const
std
::
string
data_file2
=
R"(solo trabajo y nada de juego hacen de Jack un chico aburrido,
solo trabajo y nada de juego hacen de Jack un chico aburrido,...)"
;
HighFive
::
FileAccessProps
fapl
;
fapl
.
add
(
HighFive
::
MPIOFileAccess
{
MPI_COMM_WORLD
,
MPI_INFO_NULL
});
fapl
.
add
(
HighFive
::
MPIOCollectiveMetadata
{});
HighFive
::
File
file
=
HighFive
::
File
(
filename
,
HighFive
::
File
::
Truncate
,
fapl
);
file
.
createGroup
(
"/checkpoint_0"
).
createAttribute
(
"data.pgs"
,
data_file0
);
file
.
createGroup
(
"/checkpoint_1"
).
createAttribute
(
"data.pgs"
,
data_file1
);
file
.
createGroup
(
"/checkpoint_2"
).
createAttribute
(
"data.pgs"
,
data_file2
);
file
.
createHardLink
(
"last_checkpoint"
,
file
.
getGroup
(
"/checkpoint_2"
));
file
.
createHardLink
(
"resuming_checkpoint"
,
file
.
getGroup
(
"/checkpoint_0"
));
file
.
flush
();
parallel
::
barrier
();
REQUIRE
(
resumingDatafile
(
filename
)
==
data_file0
);
parallel
::
barrier
();
file
.
unlink
(
"resuming_checkpoint"
);
file
.
createHardLink
(
"resuming_checkpoint"
,
file
.
getGroup
(
"/checkpoint_1"
));
file
.
flush
();
parallel
::
barrier
();
REQUIRE
(
resumingDatafile
(
filename
)
==
data_file1
);
parallel
::
barrier
();
file
.
unlink
(
"resuming_checkpoint"
);
file
.
createHardLink
(
"resuming_checkpoint"
,
file
.
getGroup
(
"/checkpoint_2"
));
file
.
flush
();
parallel
::
barrier
();
REQUIRE
(
resumingDatafile
(
filename
)
==
data_file2
);
}
parallel
::
barrier
();
if
(
parallel
::
rank
()
==
0
)
{
std
::
filesystem
::
remove_all
(
std
::
filesystem
::
path
{
tmp_dirname
});
}
#else // PUGS_HAS_HDF5
REQUIRE_THROWS_WITH
(
resumingDatafile
(
"foo.h5"
),
"error: Resuming requires HDF5"
);
#endif // PUGS_HAS_HDF5
}
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