Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
0f95798e
There was an error fetching the commit references. Please try again later.
Commit
0f95798e
authored
4 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Added parameter --redirect-mpi-output-dir to MpiCommunicator
parent
7734ee3c
No related branches found
No related tags found
1 merge request
!82
MPI refactoring
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/Communicators/MpiCommunicator.h
+6
-4
6 additions, 4 deletions
src/TNL/Communicators/MpiCommunicator.h
with
6 additions
and
4 deletions
src/TNL/Communicators/MpiCommunicator.h
+
6
−
4
View file @
0f95798e
...
...
@@ -73,6 +73,7 @@ class MpiCommunicator
{
#ifdef HAVE_MPI
config
.
addEntry
<
bool
>
(
"redirect-mpi-output"
,
"Only process with rank 0 prints to console. Other processes are redirected to files."
,
true
);
config
.
addEntry
<
String
>
(
"redirect-mpi-output-dir"
,
"Directory where ranks will store the files if their output is redirected."
,
"."
);
config
.
addEntry
<
bool
>
(
"mpi-gdb-debug"
,
"Wait for GDB to attach the master MPI process."
,
false
);
config
.
addEntry
<
int
>
(
"mpi-process-to-attach"
,
"Number of the MPI process to be attached by GDB. Set -1 for all processes."
,
0
);
#endif
...
...
@@ -85,8 +86,9 @@ class MpiCommunicator
if
(
IsInitialized
())
//i.e. - isUsed
{
const
bool
redirect
=
parameters
.
getParameter
<
bool
>
(
"redirect-mpi-output"
);
const
String
outputDirectory
=
parameters
.
getParameter
<
String
>
(
"redirect-mpi-output-dir"
);
if
(
redirect
)
setupRedirection
();
setupRedirection
(
outputDirectory
);
#ifdef HAVE_CUDA
int
size
;
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
size
);
...
...
@@ -152,15 +154,15 @@ class MpiCommunicator
(
void
)
NullRequest
;
}
static
void
setupRedirection
()
static
void
setupRedirection
(
std
::
string
outputDirectory
)
{
#ifdef HAVE_MPI
if
(
isDistributed
()
)
{
if
(
GetRank
(
AllGroup
)
!=
0
)
{
const
std
::
string
stdoutFile
=
std
::
string
(
".
/stdout_"
)
+
std
::
to_string
(
GetRank
(
AllGroup
))
+
".txt"
;
const
std
::
string
stderrFile
=
std
::
string
(
".
/stderr_"
)
+
std
::
to_string
(
GetRank
(
AllGroup
))
+
".txt"
;
const
std
::
string
stdoutFile
=
outputDirectory
+
"
/stdout_"
+
std
::
to_string
(
GetRank
(
AllGroup
))
+
".txt"
;
const
std
::
string
stderrFile
=
outputDirectory
+
"
/stderr_"
+
std
::
to_string
(
GetRank
(
AllGroup
))
+
".txt"
;
std
::
cout
<<
GetRank
(
AllGroup
)
<<
": Redirecting stdout and stderr to files "
<<
stdoutFile
<<
" and "
<<
stderrFile
<<
std
::
endl
;
Debugging
::
redirect_stdout_stderr
(
stdoutFile
,
stderrFile
);
}
...
...
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