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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
b037330f
Commit
b037330f
authored
4 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Fix OMP_PLACES default value and add a few tests for PugsUtils
parent
cb1708c4
No related branches found
No related tags found
1 merge request
!66
Feature/reduced verbosity
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/utils/PugsUtils.cpp
+3
-1
3 additions, 1 deletion
src/utils/PugsUtils.cpp
src/utils/PugsUtils.hpp
+2
-0
2 additions, 0 deletions
src/utils/PugsUtils.hpp
tests/CMakeLists.txt
+2
-1
2 additions, 1 deletion
tests/CMakeLists.txt
tests/test_PugsUtils.cpp
+110
-0
110 additions, 0 deletions
tests/test_PugsUtils.cpp
with
117 additions
and
2 deletions
src/utils/PugsUtils.cpp
+
3
−
1
View file @
b037330f
...
...
@@ -30,11 +30,13 @@ pugsVersion()
os
<<
"HEAD: "
<<
rang
::
style
::
bold
<<
RevisionInfo
::
gitHead
()
<<
rang
::
style
::
reset
<<
'\n'
;
os
<<
"hash: "
<<
rang
::
style
::
bold
<<
RevisionInfo
::
gitHash
()
<<
rang
::
style
::
reset
<<
" ("
;
// LCOV_EXCL_START Cannot cover both situations at same time
if
(
RevisionInfo
::
gitIsClean
())
{
os
<<
rang
::
fgB
::
green
<<
"clean"
<<
rang
::
fg
::
reset
;
}
else
{
os
<<
rang
::
fgB
::
red
<<
"dirty"
<<
rang
::
fg
::
reset
;
}
// LCOV_EXCL_STOP
os
<<
")
\n
"
;
os
<<
"-------------------------------------------------------"
;
...
...
@@ -63,7 +65,7 @@ setDefaultOMPEnvironment()
{
if
constexpr
(
std
::
string_view
{
PUGS_BUILD_KOKKOS_DEVICES
}
==
std
::
string_view
{
"OpenMP"
})
{
setenv
(
"OMP_PROC_BIND"
,
"spread"
,
0
);
setenv
(
"OMP_PLACES"
,
"treads"
,
0
);
setenv
(
"OMP_PLACES"
,
"t
h
reads"
,
0
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/utils/PugsUtils.hpp
+
2
−
0
View file @
b037330f
...
...
@@ -21,6 +21,8 @@ parallel_reduce(size_t size, const ArrayType& array, ReturnType& value, const st
Kokkos
::
parallel_reduce
(
label
,
size
,
array
,
value
);
}
void
setDefaultOMPEnvironment
();
std
::
string
pugsBuildInfo
();
std
::
string
pugsVersion
();
...
...
This diff is collapsed.
Click to expand it.
tests/CMakeLists.txt
+
2
−
1
View file @
b037330f
...
...
@@ -80,8 +80,9 @@ add_executable (unit_tests
test_NameProcessor.cpp
test_OStreamProcessor.cpp
test_ParseError.cpp
test_PugsFunctionAdapter.cpp
test_PugsAssert.cpp
test_PugsFunctionAdapter.cpp
test_PugsUtils.cpp
test_RevisionInfo.cpp
test_SparseMatrixDescriptor.cpp
test_SymbolTable.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/test_PugsUtils.cpp
0 → 100644
+
110
−
0
View file @
b037330f
#include
<catch2/catch.hpp>
#include
<utils/BuildInfo.hpp>
#include
<utils/PugsUtils.hpp>
#include
<utils/RevisionInfo.hpp>
#include
<utils/pugs_build_info.hpp>
#include
<rang.hpp>
#include
<string>
// clazy:excludeall=non-pod-global-static
TEST_CASE
(
"PugsUtils"
,
"[utils]"
)
{
SECTION
(
"checking infos"
)
{
const
std
::
string
pugs_version
=
[]
{
std
::
stringstream
os
;
os
<<
"pugs version: "
<<
rang
::
style
::
bold
<<
RevisionInfo
::
version
()
<<
rang
::
style
::
reset
<<
'\n'
;
os
<<
"-------------------- "
<<
rang
::
fg
::
green
<<
"git info"
<<
rang
::
fg
::
reset
<<
" -------------------------"
<<
'\n'
;
os
<<
"tag: "
<<
rang
::
style
::
bold
<<
RevisionInfo
::
gitTag
()
<<
rang
::
style
::
reset
<<
'\n'
;
os
<<
"HEAD: "
<<
rang
::
style
::
bold
<<
RevisionInfo
::
gitHead
()
<<
rang
::
style
::
reset
<<
'\n'
;
os
<<
"hash: "
<<
rang
::
style
::
bold
<<
RevisionInfo
::
gitHash
()
<<
rang
::
style
::
reset
<<
" ("
;
if
(
RevisionInfo
::
gitIsClean
())
{
os
<<
rang
::
fgB
::
green
<<
"clean"
<<
rang
::
fg
::
reset
;
}
else
{
os
<<
rang
::
fgB
::
red
<<
"dirty"
<<
rang
::
fg
::
reset
;
}
os
<<
")
\n
"
;
os
<<
"-------------------------------------------------------"
;
return
os
.
str
();
}();
REQUIRE
(
pugsVersion
()
==
pugs_version
);
const
std
::
string
build_info
=
[]
{
std
::
ostringstream
os
;
os
<<
"-------------------- "
<<
rang
::
fg
::
green
<<
"build info"
<<
rang
::
fg
::
reset
<<
" -----------------------"
<<
'\n'
;
os
<<
"type: "
<<
rang
::
style
::
bold
<<
BuildInfo
::
type
()
<<
rang
::
style
::
reset
<<
'\n'
;
os
<<
"compiler: "
<<
rang
::
style
::
bold
<<
BuildInfo
::
compiler
()
<<
rang
::
style
::
reset
<<
'\n'
;
os
<<
"kokkos: "
<<
rang
::
style
::
bold
<<
BuildInfo
::
kokkosDevices
()
<<
rang
::
style
::
reset
<<
'\n'
;
os
<<
"MPI: "
<<
rang
::
style
::
bold
<<
BuildInfo
::
mpiLibrary
()
<<
rang
::
style
::
reset
<<
'\n'
;
os
<<
"PETSc: "
<<
rang
::
style
::
bold
<<
BuildInfo
::
petscLibrary
()
<<
rang
::
style
::
reset
<<
'\n'
;
os
<<
"-------------------------------------------------------"
;
return
os
.
str
();
}();
REQUIRE
(
pugsBuildInfo
()
==
build_info
);
}
SECTION
(
"checking OMP environment setting"
)
{
if
constexpr
(
std
::
string_view
{
PUGS_BUILD_KOKKOS_DEVICES
}
==
std
::
string_view
{
"OpenMP"
})
{
const
std
::
string
saved_omp_proc_bind
=
[]()
{
char
*
value
=
getenv
(
"OMP_PROC_BIND"
);
if
(
value
!=
nullptr
)
{
return
std
::
string
{
value
};
}
else
{
return
std
::
string
{};
}
}();
const
std
::
string
saved_omp_places
=
[]()
{
char
*
value
=
getenv
(
"OMP_PLACES"
);
if
(
value
!=
nullptr
)
{
return
std
::
string
{
value
};
}
else
{
return
std
::
string
{};
}
}();
unsetenv
(
"OMP_PROC_BIND"
);
unsetenv
(
"OMP_PLACES"
);
setDefaultOMPEnvironment
();
REQUIRE
(
std
::
string
{
getenv
(
"OMP_PROC_BIND"
)}
==
std
::
string
{
"spread"
});
REQUIRE
(
std
::
string
{
getenv
(
"OMP_PLACES"
)}
==
std
::
string
{
"threads"
});
unsetenv
(
"OMP_PROC_BIND"
);
unsetenv
(
"OMP_PLACES"
);
setenv
(
"OMP_PROC_BIND"
,
"foo"
,
1
);
setenv
(
"OMP_PLACES"
,
"bar"
,
1
);
setDefaultOMPEnvironment
();
REQUIRE
(
std
::
string
{
getenv
(
"OMP_PROC_BIND"
)}
==
std
::
string
{
"foo"
});
REQUIRE
(
std
::
string
{
getenv
(
"OMP_PLACES"
)}
==
std
::
string
{
"bar"
});
unsetenv
(
"OMP_PROC_BIND"
);
unsetenv
(
"OMP_PLACES"
);
if
(
saved_omp_proc_bind
.
size
()
!=
0
)
{
setenv
(
"OMP_PROC_BIND"
,
saved_omp_proc_bind
.
c_str
(),
1
);
}
if
(
saved_omp_places
.
size
()
!=
0
)
{
setenv
(
"OMP_PLACES"
,
saved_omp_places
.
c_str
(),
1
);
}
}
}
}
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