Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ADIOS2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
Podhorszki, Norbert
ADIOS2
Commits
44be559e
Commit
44be559e
authored
7 years ago
by
Haocheng Liu
Browse files
Options
Downloads
Patches
Plain Diff
Testing: Make BPWriteProfilingJSON able to run in parllel
parent
c1703977
No related branches found
No related tags found
1 merge request
!252
Make all Bp engine tests able to run in parallel
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
testing/adios2/engine/bp/CMakeLists.txt
+31
-29
31 additions, 29 deletions
testing/adios2/engine/bp/CMakeLists.txt
testing/adios2/engine/bp/TestBPWriteProfilingJSON.cpp
+93
-34
93 additions, 34 deletions
testing/adios2/engine/bp/TestBPWriteProfilingJSON.cpp
with
124 additions
and
63 deletions
testing/adios2/engine/bp/CMakeLists.txt
+
31
−
29
View file @
44be559e
...
...
@@ -4,38 +4,19 @@
#------------------------------------------------------------------------------#
# MPI versions of the test are not properly implemented at the moment
if
(
NOT ADIOS2_HAVE_MPI
)
if
(
ADIOS2_HAVE_ADIOS1
)
add_executable
(
TestBPWriteRead TestBPWriteRead.cpp
)
target_link_libraries
(
TestBPWriteRead adios2 gtest adios1::adios
)
add_executable
(
TestBPWriteReadAttributes TestBPWriteReadAttributes.cpp
)
target_link_libraries
(
TestBPWriteReadAttributes adios2 gtest adios1::adios
)
add_executable
(
TestBPWriteReadstdio TestBPWriteReadstdio.cpp
)
target_link_libraries
(
TestBPWriteReadstdio adios2 gtest adios1::adios
)
add_executable
(
TestBPWriteReadfstream TestBPWriteReadfstream.cpp
)
target_link_libraries
(
TestBPWriteReadfstream adios2 gtest adios1::adios
)
gtest_add_tests
(
TARGET TestBPWriteRead
)
gtest_add_tests
(
TARGET TestBPWriteReadAttributes
)
gtest_add_tests
(
TARGET TestBPWriteReadstdio
)
gtest_add_tests
(
TARGET TestBPWriteReadfstream
)
endif
()
add_executable
(
TestBPWriteProfilingJSON TestBPWriteProfilingJSON.cpp
)
target_link_libraries
(
TestBPWriteProfilingJSON
adios2 gtest gtest_main NLohmannJson
)
gtest_add_tests
(
TARGET TestBPWriteProfilingJSON
)
endif
()
# Testing CMake code
add_executable
(
TestBPWriteRead TestBPWriteRead.cpp
)
target_link_libraries
(
TestBPWriteRead adios2 gtest adios1::adios
)
#add_executable(TestBPWriteReadAttributes TestBPWriteReadAttributes.cpp)
#target_link_libraries(TestBPWriteReadAttributes adios2 gtest adios1::adios)
#add_executable(TestBPWriteReadstdio TestBPWriteReadstdio.cpp)
#target_link_libraries(TestBPWriteReadstdio adios2 gtest adios1::adios)
#add_executable(TestBPWriteReadfstream TestBPWriteReadfstream.cpp)
#target_link_libraries(TestBPWriteReadfstream adios2 gtest adios1::adios)
if
(
ADIOS2_HAVE_MPI
)
target_include_directories
(
TestBPWriteRead PRIVATE
${
MPI_C_INCLUDE_PATH
}
)
target_link_libraries
(
TestBPWriteRead
${
MPI_C_LIBRARIES
}
)
...
...
@@ -46,3 +27,24 @@ if(ADIOS2_HAVE_MPI)
endif
()
gtest_add_tests
(
TARGET TestBPWriteRead
${
extra_test_args
}
)
#gtest_add_tests(TARGET TestBPWriteReadAttributes)
#gtest_add_tests(TARGET TestBPWriteReadstdio)
#gtest_add_tests(TARGET TestBPWriteReadfstream)
add_executable
(
TestBPWriteProfilingJSON TestBPWriteProfilingJSON.cpp
)
target_link_libraries
(
TestBPWriteProfilingJSON
adios2 gtest gtest_main NLohmannJson
)
if
(
ADIOS2_HAVE_MPI
)
target_include_directories
(
TestBPWriteProfilingJSON PRIVATE
${
MPI_C_INCLUDE_PATH
}
)
target_link_libraries
(
TestBPWriteProfilingJSON
${
MPI_C_LIBRARIES
}
)
set
(
extra_test_argsJSON
EXEC_WRAPPER
${
MPIEXEC
}
${
MPIEXEC_NUMPROC_FLAG
}
${
MPIEXEC_MAX_NUMPROCS
}
)
endif
()
gtest_add_tests
(
TARGET TestBPWriteProfilingJSON
${
extra_test_argsJSON
}
)
This diff is collapsed.
Click to expand it.
testing/adios2/engine/bp/TestBPWriteProfilingJSON.cpp
+
93
−
34
View file @
44be559e
...
...
@@ -40,47 +40,73 @@ public:
// ADIOS2 write, native ADIOS1 read
TEST_F
(
BPWriteProfilingJSONTest
,
ADIOS2BPWriteProfilingJSON
)
{
std
::
string
fname
=
"ADIOS2BPWriteProfilingJSON.bp"
;
// Use a relative path + file name to test path in file name capability
std
::
string
fname
=
"foo/ADIOS2BPWriteProfilingJSON.bp"
;
int
mpiRank
=
0
,
mpiSize
=
1
;
// Number of rows
const
std
::
size_t
Nx
=
8
;
// Number of steps
const
std
::
size_t
NSteps
=
3
;
#ifdef ADIOS2_HAVE_MPI
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
mpiRank
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
mpiSize
);
#endif
// Write test data and profiling.json using ADIOS2
{
#ifdef ADIOS2_HAVE_MPI
adios2
::
ADIOS
adios
(
MPI_COMM_WORLD
,
adios2
::
DebugON
);
#else
adios2
::
ADIOS
adios
(
true
);
#endif
adios2
::
IO
&
io
=
adios
.
DeclareIO
(
"TestIO"
);
// Declare 1D variables
// Declare 1D variables (NumOfProcesses * Nx)
// The local process' part (start, count) can be defined now or later
// before Write().
{
auto
&
var_i8
=
io
.
DefineVariable
<
int8_t
>
(
"i8"
,
{},
{},
adios2
::
Dims
{
8
});
adios2
::
Dims
shape
{
static_cast
<
unsigned
int
>
(
Nx
*
mpiSize
)};
adios2
::
Dims
start
{
static_cast
<
unsigned
int
>
(
Nx
*
mpiRank
)};
adios2
::
Dims
count
{
static_cast
<
unsigned
int
>
(
Nx
)};
auto
&
var_i8
=
io
.
DefineVariable
<
int8_t
>
(
"i8"
,
shape
,
start
,
count
);
auto
&
var_i16
=
io
.
DefineVariable
<
int16_t
>
(
"i16"
,
{},
{},
adios2
::
Dims
{
8
}
);
io
.
DefineVariable
<
int16_t
>
(
"i16"
,
shape
,
start
,
count
);
auto
&
var_i32
=
io
.
DefineVariable
<
int32_t
>
(
"i32"
,
{},
{},
adios2
::
Dims
{
8
}
);
io
.
DefineVariable
<
int32_t
>
(
"i32"
,
shape
,
start
,
count
);
auto
&
var_i64
=
io
.
DefineVariable
<
int64_t
>
(
"i64"
,
{},
{},
adios2
::
Dims
{
8
}
);
io
.
DefineVariable
<
int64_t
>
(
"i64"
,
shape
,
start
,
count
);
auto
&
var_u8
=
io
.
DefineVariable
<
uint8_t
>
(
"u8"
,
{},
{},
adios2
::
Dims
{
8
}
);
io
.
DefineVariable
<
uint8_t
>
(
"u8"
,
shape
,
start
,
count
);
auto
&
var_u16
=
io
.
DefineVariable
<
uint16_t
>
(
"u16"
,
{},
{},
adios2
::
Dims
{
8
}
);
io
.
DefineVariable
<
uint16_t
>
(
"u16"
,
shape
,
start
,
count
);
auto
&
var_u32
=
io
.
DefineVariable
<
uint32_t
>
(
"u32"
,
{},
{},
adios2
::
Dims
{
8
}
);
io
.
DefineVariable
<
uint32_t
>
(
"u32"
,
shape
,
start
,
count
);
auto
&
var_u64
=
io
.
DefineVariable
<
uint64_t
>
(
"u64"
,
{},
{},
adios2
::
Dims
{
8
}
);
io
.
DefineVariable
<
uint64_t
>
(
"u64"
,
shape
,
start
,
count
);
auto
&
var_r32
=
io
.
DefineVariable
<
float
>
(
"r32"
,
{},
{},
adios2
::
Dims
{
8
}
);
io
.
DefineVariable
<
float
>
(
"r32"
,
shape
,
start
,
count
);
auto
&
var_r64
=
io
.
DefineVariable
<
double
>
(
"r64"
,
{},
{},
adios2
::
Dims
{
8
}
);
io
.
DefineVariable
<
double
>
(
"r64"
,
shape
,
start
,
count
);
}
// Create the BP Engine
io
.
SetEngine
(
"BPFileWriter"
);
// Using MPI Rank here?
io
.
SetParameters
({{
"Threads"
,
"2"
}});
io
.
AddTransport
(
"File"
,
{{
"Library"
,
"POSIX"
}});
auto
engine
=
io
.
Open
(
fname
,
adios2
::
OpenMode
::
Write
);
ASSERT_NE
(
engine
.
get
(),
nullptr
);
for
(
size_t
step
=
0
;
step
<
3
;
++
step
)
for
(
size_t
step
=
0
;
step
<
NSteps
;
++
step
)
{
// Generate test data for each process uniquely
SmallTestData
currentTestData
=
generateNewSmallTestData
(
m_TestData
,
step
,
mpiRank
,
mpiSize
);
// Retrieve the variables that previously went out of scope
auto
&
var_i8
=
io
.
GetVariable
<
int8_t
>
(
"i8"
);
auto
&
var_i16
=
io
.
GetVariable
<
int16_t
>
(
"i16"
);
...
...
@@ -93,22 +119,37 @@ TEST_F(BPWriteProfilingJSONTest, ADIOS2BPWriteProfilingJSON)
auto
&
var_r32
=
io
.
GetVariable
<
float
>
(
"r32"
);
auto
&
var_r64
=
io
.
GetVariable
<
double
>
(
"r64"
);
// Make a 1D selection to describe the local dimensions of the
// variable we write and its offsets in the global spaces
adios2
::
SelectionBoundingBox
sel
({
mpiRank
*
Nx
},
{
Nx
});
var_i8
.
SetSelection
(
sel
);
var_i16
.
SetSelection
(
sel
);
var_i32
.
SetSelection
(
sel
);
var_i64
.
SetSelection
(
sel
);
var_u8
.
SetSelection
(
sel
);
var_u16
.
SetSelection
(
sel
);
var_u32
.
SetSelection
(
sel
);
var_u64
.
SetSelection
(
sel
);
var_r32
.
SetSelection
(
sel
);
var_r64
.
SetSelection
(
sel
);
// Write each one
engine
->
Write
(
var_i8
,
m_TestData
.
I8
.
data
()
+
step
);
engine
->
Write
(
var_i16
,
m_TestData
.
I16
.
data
()
+
step
);
engine
->
Write
(
var_i32
,
m_TestData
.
I32
.
data
()
+
step
);
engine
->
Write
(
var_i64
,
m_TestData
.
I64
.
data
()
+
step
);
engine
->
Write
(
var_u8
,
m_TestData
.
U8
.
data
()
+
step
);
engine
->
Write
(
var_u16
,
m_TestData
.
U16
.
data
()
+
step
);
engine
->
Write
(
var_u32
,
m_TestData
.
U32
.
data
()
+
step
);
engine
->
Write
(
var_u64
,
m_TestData
.
U64
.
data
()
+
step
);
engine
->
Write
(
var_r32
,
m_TestData
.
R32
.
data
()
+
step
);
engine
->
Write
(
var_r64
,
m_TestData
.
R64
.
data
()
+
step
);
// fill in the variable with values from starting index to
// starting index + count
engine
->
Write
(
var_i8
,
currentTestData
.
I8
.
data
());
engine
->
Write
(
var_i16
,
currentTestData
.
I16
.
data
());
engine
->
Write
(
var_i32
,
currentTestData
.
I32
.
data
());
engine
->
Write
(
var_i64
,
currentTestData
.
I64
.
data
());
engine
->
Write
(
var_u8
,
currentTestData
.
U8
.
data
());
engine
->
Write
(
var_u16
,
currentTestData
.
U16
.
data
());
engine
->
Write
(
var_u32
,
currentTestData
.
U32
.
data
());
engine
->
Write
(
var_u64
,
currentTestData
.
U64
.
data
());
engine
->
Write
(
var_r32
,
currentTestData
.
R32
.
data
());
engine
->
Write
(
var_r64
,
currentTestData
.
R64
.
data
());
// Advance to the next time step
engine
->
Advance
();
}
// Close the file
engine
->
Close
();
}
...
...
@@ -116,25 +157,43 @@ TEST_F(BPWriteProfilingJSONTest, ADIOS2BPWriteProfilingJSON)
// open json file, parse it to a json structure, and verify a few things
{
std
::
ifstream
profilingJSONFile
(
fname
+
".dir/profiling.json"
);
std
::
stringstream
buffer
;
buffer
<<
profilingJSONFile
.
rdbuf
();
const
json
profilingJSON
=
json
::
parse
(
buffer
);
const
json
profilingJSON
=
json
::
parse
(
profilingJSONFile
);
// check rank is zero
const
int
rank
=
profilingJSON
[
0
].
value
(
"rank"
,
-
1
);
ASSERT_EQ
(
rank
,
0
);
const
int
rank
=
profilingJSON
[
mpiRank
].
value
(
"rank"
,
-
1
);
ASSERT_EQ
(
rank
,
mpiRank
);
// check threads
const
int
threads
=
profilingJSON
[
0
].
value
(
"threads"
,
0
);
const
int
threads
=
profilingJSON
[
mpiRank
].
value
(
"threads"
,
0
);
ASSERT_EQ
(
threads
,
2
);
// check bytes
const
unsigned
long
int
bytes
=
profilingJSON
[
0
].
value
(
"bytes"
,
0UL
);
const
unsigned
long
int
bytes
=
profilingJSON
[
mpiRank
].
value
(
"bytes"
,
0UL
);
ASSERT_EQ
(
bytes
,
6536
);
const
auto
transportType
=
profilingJSON
[
0
][
"transport_0"
].
value
(
"type"
,
"0"
);
profilingJSON
[
mpiRank
][
"transport_0"
].
value
(
"type"
,
"0"
);
ASSERT_EQ
(
transportType
,
"File_POSIX"
);
}
}
//******************************************************************************
// main
//******************************************************************************
int
main
(
int
argc
,
char
**
argv
)
{
#ifdef ADIOS2_HAVE_MPI
MPI_Init
(
nullptr
,
nullptr
);
#endif
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
int
result
=
RUN_ALL_TESTS
();
#ifdef ADIOS2_HAVE_MPI
MPI_Finalize
();
#endif
return
result
;
}
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