Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Özgür Ozan Sen
ogs
Commits
7cf0b9e7
Commit
7cf0b9e7
authored
10 years ago
by
Norihiro Watanabe
Browse files
Options
Downloads
Patches
Plain Diff
extend LogogCustomCout to support level dependent output
parent
4e609ea7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BaseLib/LogogCustomCout.h
+27
-7
27 additions, 7 deletions
BaseLib/LogogCustomCout.h
Tests/testrunner.cpp
+1
-3
1 addition, 3 deletions
Tests/testrunner.cpp
with
28 additions
and
10 deletions
BaseLib/LogogCustomCout.h
+
27
−
7
View file @
7cf0b9e7
...
...
@@ -24,23 +24,43 @@ class LogogCustomCout : public logog::Target
{
public:
#ifdef USE_MPI
LogogCustomCout
(
MPI_Comm
mpi_comm
)
{
MPI_Comm_rank
(
mpi_comm
,
&
_mpi_rank
);
}
/**
* Constructor when MPI is involved
*
* @param all_rank_output_level Minimum level to output messages from all MPI processes
* @param mpi_comm MPI communicator
*/
LogogCustomCout
(
LOGOG_LEVEL_TYPE
all_rank_output_level
=
LOGOG_LEVEL_INFO
,
MPI_Comm
mpi_comm
=
MPI_COMM_WORLD
)
:
_all_rank_output_level
(
all_rank_output_level
),
_is_rank0
(
getRank
(
mpi_comm
)
==
0
)
{}
#endif
virtual
int
Output
(
const
LOGOG_STRING
&
data
)
virtual
int
Receive
(
const
logog
::
Topic
&
topic
)
{
#ifdef USE_MPI
if
(
_mpi_rank
==
0
)
if
(
topic
.
Level
()
>
_all_rank_output_level
&&
!
_is_rank0
)
return
0
;
#endif
return
logog
::
Target
::
Receive
(
topic
);
}
virtual
int
Output
(
const
LOGOG_STRING
&
data
)
{
LOGOG_COUT
<<
(
const
LOGOG_CHAR
*
)
data
;
return
0
;
}
private
:
#ifdef USE_MPI
int
_mpi_rank
;
int
getRank
(
MPI_Comm
mpi_comm
)
const
{
int
rank
=
0
;
MPI_Comm_rank
(
mpi_comm
,
&
rank
);
return
rank
;
}
const
LOGOG_LEVEL_TYPE
_all_rank_output_level
;
const
bool
_is_rank0
;
#endif
};
...
...
This diff is collapsed.
Click to expand it.
Tests/testrunner.cpp
+
1
−
3
View file @
7cf0b9e7
...
...
@@ -45,10 +45,8 @@ int main(int argc, char* argv[])
{
#ifdef USE_MPI
MPI_Init
(
&
argc
,
&
argv
);
BaseLib
::
LogogCustomCout
out
(
MPI_COMM_WORLD
);
#else
BaseLib
::
LogogCustomCout
out
;
#endif
BaseLib
::
LogogCustomCout
out
;
BaseLib
::
TemplateLogogFormatterSuppressedGCC
<
TOPIC_LEVEL_FLAG
|
TOPIC_FILE_NAME_FLAG
|
TOPIC_LINE_NUMBER_FLAG
>
custom_format
;
out
.
SetFormatter
(
custom_format
);
...
...
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