Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VirtualFluids
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
iRMB
VirtualFluids
Commits
440a31a2
Commit
440a31a2
authored
2 years ago
by
Anna Wellmann
Browse files
Options
Downloads
Patches
Plain Diff
Refactor the tests for findEdgeNodesCommMultiGPU
parent
a7bcd813
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!104
Add Communication Hiding to GPU version
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp
+68
-115
68 additions, 115 deletions
src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp
with
68 additions
and
115 deletions
src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp
+
68
−
115
View file @
440a31a2
...
...
@@ -160,13 +160,50 @@ static std::shared_ptr<Parameter> initParameterClass()
return
std
::
make_shared
<
Parameter
>
(
config
,
1
,
0
);
}
TEST
(
ParameterTest
,
findEdgeNodesXY_shouldReturnCorrectVector
)
static
bool
compareEdgeNodesRecv
(
std
::
vector
<
LBMSimulationParameter
::
EdgeNodePositions
>
&
actual
,
std
::
vector
<
std
::
pair
<
int
,
int
>>
&
expected
)
{
for
(
int
i
=
0
;
i
<
(
int
)
expected
.
size
();
i
++
)
{
if
(
actual
[
i
].
indexOfProcessNeighborRecv
!=
expected
[
i
].
first
)
{
return
false
;
}
if
(
actual
[
i
].
indexInRecvBuffer
!=
expected
[
i
].
second
)
{
return
false
;
}
}
return
true
;
}
auto
para
=
initParameterClass
();
para
->
initLBMSimulationParameter
();
static
bool
compareEdgeNodesSend
(
std
::
vector
<
LBMSimulationParameter
::
EdgeNodePositions
>
&
actual
,
std
::
vector
<
std
::
pair
<
int
,
int
>>
&
expected
)
{
for
(
int
i
=
0
;
i
<
(
int
)
expected
.
size
();
i
++
)
{
if
(
actual
[
i
].
indexOfProcessNeighborSend
!=
expected
[
i
].
first
)
{
return
false
;
}
if
(
actual
[
i
].
indexInSendBuffer
!=
expected
[
i
].
second
)
{
return
false
;
}
}
return
true
;
}
class
ParameterTest_findEdgeNodes
:
public
testing
::
Test
{
protected:
std
::
shared_ptr
<
Parameter
>
para
;
int
level
=
0
;
private:
void
SetUp
()
override
{
para
=
initParameterClass
();
para
->
initLBMSimulationParameter
();
}
};
TEST_F
(
ParameterTest_findEdgeNodes
,
shouldReturnCorrectVectorForXY
)
{
para
->
parH
[
level
]
->
recvProcessNeighborX
.
push_back
(
ProcessNeighbor27
());
para
->
parH
[
level
]
->
sendProcessNeighborY
.
push_back
(
ProcessNeighbor27
());
para
->
parH
[
level
]
->
sendProcessNeighborY
.
push_back
(
ProcessNeighbor27
());
...
...
@@ -174,15 +211,15 @@ TEST(ParameterTest, findEdgeNodesXY_shouldReturnCorrectVector)
int
numRecvNeighbor
=
(
int
)
para
->
parH
[
level
]
->
recvProcessNeighborX
.
size
()
-
1
;
int
numSendNeighbor
=
(
int
)
para
->
parH
[
level
]
->
sendProcessNeighborY
.
size
()
-
1
;
const
int
sizeRecv
=
6
;
const
int
sizeSend
=
10
;
const
int
sizeRecv
=
6
;
const
int
sizeSend
=
10
;
para
->
parH
[
level
]
->
recvProcessNeighborX
[
numRecvNeighbor
].
numberOfNodes
=
sizeRecv
;
para
->
parH
[
level
]
->
sendProcessNeighborY
[
numSendNeighbor
].
numberOfNodes
=
sizeSend
;
int
recvNeighbors
[
sizeRecv
]
=
{
1
,
2
,
3
,
4
,
5
,
6
};
int
recvNeighbors
[
sizeRecv
]
=
{
1
,
2
,
3
,
4
,
5
,
6
};
para
->
parH
[
level
]
->
recvProcessNeighborX
[
numRecvNeighbor
].
index
=
recvNeighbors
;
int
sendNeighbors
[
sizeSend
]
=
{
20
,
1
,
21
,
22
,
6
,
23
,
5
,
24
,
25
,
26
};
int
sendNeighbors
[
sizeSend
]
=
{
20
,
1
,
21
,
22
,
6
,
23
,
5
,
24
,
25
,
26
};
para
->
parH
[
level
]
->
sendProcessNeighborY
[
numSendNeighbor
].
index
=
sendNeighbors
;
para
->
findEdgeNodesCommMultiGPU
();
...
...
@@ -196,43 +233,14 @@ TEST(ParameterTest, findEdgeNodesXY_shouldReturnCorrectVector)
std
::
pair
(
numSendNeighbor
,
4
)
};
EXPECT_THAT
(
para
->
parH
[
level
]
->
edgeNodesXtoY
.
size
(),
testing
::
Eq
(
expectedEdgeNodesXtoYRecv
.
size
()));
bool
vectorsAreIdentical
=
true
;
for
(
int
i
=
0
;
i
<
(
int
)
expectedEdgeNodesXtoYRecv
.
size
();
i
++
)
{
if
(
para
->
parH
[
level
]
->
edgeNodesXtoY
[
i
].
indexOfProcessNeighborRecv
!=
expectedEdgeNodesXtoYRecv
[
i
].
first
)
{
vectorsAreIdentical
=
false
;
break
;
}
if
(
para
->
parH
[
level
]
->
edgeNodesXtoY
[
i
].
indexInRecvBuffer
!=
expectedEdgeNodesXtoYRecv
[
i
].
second
)
{
vectorsAreIdentical
=
false
;
break
;
}
}
EXPECT_TRUE
(
vectorsAreIdentical
);
vectorsAreIdentical
=
true
;
for
(
int
i
=
0
;
i
<
(
int
)
expectedEdgeNodesXtoYSend
.
size
();
i
++
)
{
if
(
para
->
parH
[
level
]
->
edgeNodesXtoY
[
i
].
indexOfProcessNeighborSend
!=
expectedEdgeNodesXtoYSend
[
i
].
first
)
{
vectorsAreIdentical
=
false
;
break
;
}
if
(
para
->
parH
[
level
]
->
edgeNodesXtoY
[
i
].
indexInSendBuffer
!=
expectedEdgeNodesXtoYSend
[
i
].
second
)
{
vectorsAreIdentical
=
false
;
break
;
}
}
EXPECT_TRUE
(
vectorsAreIdentical
);
EXPECT_TRUE
(
compareEdgeNodesRecv
(
para
->
parH
[
level
]
->
edgeNodesXtoY
,
expectedEdgeNodesXtoYRecv
))
<<
"the edgeNodesXtoY for the receive process do not match the expected nodes"
;
EXPECT_TRUE
(
compareEdgeNodesSend
(
para
->
parH
[
level
]
->
edgeNodesXtoY
,
expectedEdgeNodesXtoYSend
))
<<
"the edgeNodesXtoY for the send process do not match the expected nodes"
;
}
TEST
(
ParameterTest
,
findEdgeNodes
XZ_
shouldReturnCorrectVector
)
TEST
_F
(
ParameterTest
_
findEdgeNodes
,
shouldReturnCorrectVector
ForXZ
)
{
auto
para
=
initParameterClass
();
para
->
initLBMSimulationParameter
();
int
level
=
0
;
para
->
parH
[
level
]
->
recvProcessNeighborX
.
push_back
(
ProcessNeighbor27
());
para
->
parH
[
level
]
->
sendProcessNeighborZ
.
push_back
(
ProcessNeighbor27
());
para
->
parH
[
level
]
->
sendProcessNeighborZ
.
push_back
(
ProcessNeighbor27
());
...
...
@@ -240,16 +248,15 @@ TEST(ParameterTest, findEdgeNodesXZ_shouldReturnCorrectVector)
int
numRecvNeighbor
=
(
int
)
para
->
parH
[
level
]
->
recvProcessNeighborX
.
size
()
-
1
;
int
numSendNeighbor
=
(
int
)
para
->
parH
[
level
]
->
sendProcessNeighborZ
.
size
()
-
1
;
const
int
sizeRecv
=
10
;
const
int
sizeSend
=
6
;
const
int
sizeRecv
=
10
;
const
int
sizeSend
=
6
;
para
->
parH
[
level
]
->
recvProcessNeighborX
[
numRecvNeighbor
].
numberOfNodes
=
sizeRecv
;
para
->
parH
[
level
]
->
sendProcessNeighborZ
[
numSendNeighbor
].
numberOfNodes
=
sizeSend
;
int
recvNeighbors
[
sizeRecv
]
=
{
20
,
1
,
21
,
22
,
6
,
23
,
5
,
24
,
25
,
26
};
int
recvNeighbors
[
sizeRecv
]
=
{
20
,
1
,
21
,
22
,
6
,
23
,
5
,
24
,
25
,
26
};
para
->
parH
[
level
]
->
recvProcessNeighborX
[
numRecvNeighbor
].
index
=
recvNeighbors
;
int
sendNeighbors
[
sizeSend
]
=
{
1
,
2
,
3
,
4
,
5
,
6
};
int
sendNeighbors
[
sizeSend
]
=
{
1
,
2
,
3
,
4
,
5
,
6
};
para
->
parH
[
level
]
->
sendProcessNeighborZ
[
numSendNeighbor
].
index
=
sendNeighbors
;
para
->
findEdgeNodesCommMultiGPU
();
...
...
@@ -262,44 +269,14 @@ TEST(ParameterTest, findEdgeNodesXZ_shouldReturnCorrectVector)
std
::
pair
(
numSendNeighbor
,
4
)
};
EXPECT_THAT
(
para
->
parH
[
level
]
->
edgeNodesXtoZ
.
size
(),
testing
::
Eq
(
expectedEdgeNodesXtoZRecv
.
size
()));
bool
vectorsAreIdentical
=
true
;
for
(
int
i
=
0
;
i
<
(
int
)
expectedEdgeNodesXtoZRecv
.
size
();
i
++
)
{
if
(
para
->
parH
[
level
]
->
edgeNodesXtoZ
[
i
].
indexOfProcessNeighborRecv
!=
expectedEdgeNodesXtoZRecv
[
i
].
first
)
{
vectorsAreIdentical
=
false
;
break
;
}
if
(
para
->
parH
[
level
]
->
edgeNodesXtoZ
[
i
].
indexInRecvBuffer
!=
expectedEdgeNodesXtoZRecv
[
i
].
second
)
{
vectorsAreIdentical
=
false
;
break
;
}
}
EXPECT_TRUE
(
vectorsAreIdentical
);
vectorsAreIdentical
=
true
;
for
(
int
i
=
0
;
i
<
(
int
)
expectedEdgeNodesXtoZRecv
.
size
();
i
++
)
{
if
(
para
->
parH
[
level
]
->
edgeNodesXtoZ
[
i
].
indexOfProcessNeighborSend
!=
expectedEdgeNodesXtoZSend
[
i
].
first
)
{
vectorsAreIdentical
=
false
;
break
;
}
if
(
para
->
parH
[
level
]
->
edgeNodesXtoZ
[
i
].
indexInSendBuffer
!=
expectedEdgeNodesXtoZSend
[
i
].
second
)
{
vectorsAreIdentical
=
false
;
break
;
}
}
EXPECT_TRUE
(
vectorsAreIdentical
);
EXPECT_TRUE
(
compareEdgeNodesRecv
(
para
->
parH
[
level
]
->
edgeNodesXtoZ
,
expectedEdgeNodesXtoZRecv
))
<<
"the edgeNodesXtoZ for the receive process do not match the expected nodes"
;
EXPECT_TRUE
(
compareEdgeNodesSend
(
para
->
parH
[
level
]
->
edgeNodesXtoZ
,
expectedEdgeNodesXtoZSend
))
<<
"the edgeNodesXtoZ for the send process do not match the expected nodes"
;
}
TEST
(
ParameterTest
,
findEdgeNodes
YZ_
shouldReturnCorrectVector
)
TEST
_F
(
ParameterTest
_
findEdgeNodes
,
shouldReturnCorrectVector
ForYZ
)
{
auto
para
=
initParameterClass
();
para
->
initLBMSimulationParameter
();
int
level
=
0
;
para
->
parH
[
level
]
->
recvProcessNeighborY
.
push_back
(
ProcessNeighbor27
());
para
->
parH
[
level
]
->
sendProcessNeighborZ
.
push_back
(
ProcessNeighbor27
());
para
->
parH
[
level
]
->
sendProcessNeighborZ
.
push_back
(
ProcessNeighbor27
());
...
...
@@ -312,48 +289,24 @@ TEST(ParameterTest, findEdgeNodesYZ_shouldReturnCorrectVector)
para
->
parH
[
level
]
->
sendProcessNeighborZ
[
0
].
numberOfNodes
=
sizeSend1
;
para
->
parH
[
level
]
->
sendProcessNeighborZ
[
1
].
numberOfNodes
=
sizeSend2
;
int
recvNeighbors
[
sizeRecv
]
=
{
20
,
1
,
9
,
22
,
6
,
23
,
5
,
24
,
11
,
26
};
int
recvNeighbors
[
sizeRecv
]
=
{
20
,
1
,
9
,
22
,
6
,
23
,
5
,
24
,
11
,
26
};
para
->
parH
[
level
]
->
recvProcessNeighborY
[
0
].
index
=
recvNeighbors
;
int
sendNeighbors1
[
sizeSend1
]
=
{
1
,
2
,
3
,
4
,
5
,
6
};
int
sendNeighbors2
[
sizeSend2
]
=
{
7
,
8
,
9
,
10
,
11
};
int
sendNeighbors1
[
sizeSend1
]
=
{
1
,
2
,
3
,
4
,
5
,
6
};
int
sendNeighbors2
[
sizeSend2
]
=
{
7
,
8
,
9
,
10
,
11
};
para
->
parH
[
level
]
->
sendProcessNeighborZ
[
0
].
index
=
sendNeighbors1
;
para
->
parH
[
level
]
->
sendProcessNeighborZ
[
1
].
index
=
sendNeighbors2
;
para
->
findEdgeNodesCommMultiGPU
();
std
::
vector
<
std
::
pair
<
int
,
int
>>
expectedEdgeNodes
X
toZRecv
=
{
std
::
pair
(
0
,
1
),
std
::
pair
(
0
,
2
),
std
::
pair
(
0
,
4
),
std
::
vector
<
std
::
pair
<
int
,
int
>>
expectedEdgeNodes
Y
toZRecv
=
{
std
::
pair
(
0
,
1
),
std
::
pair
(
0
,
2
),
std
::
pair
(
0
,
4
),
std
::
pair
(
0
,
6
),
std
::
pair
(
0
,
8
)
};
std
::
vector
<
std
::
pair
<
int
,
int
>>
expectedEdgeNodes
X
toZSend
=
{
std
::
pair
(
0
,
0
),
std
::
pair
(
1
,
2
),
std
::
pair
(
0
,
5
),
std
::
vector
<
std
::
pair
<
int
,
int
>>
expectedEdgeNodes
Y
toZSend
=
{
std
::
pair
(
0
,
0
),
std
::
pair
(
1
,
2
),
std
::
pair
(
0
,
5
),
std
::
pair
(
0
,
4
),
std
::
pair
(
1
,
4
)
};
EXPECT_THAT
(
para
->
parH
[
level
]
->
edgeNodesYtoZ
.
size
(),
testing
::
Eq
(
expectedEdgeNodesXtoZRecv
.
size
()));
bool
vectorsAreIdentical
=
true
;
for
(
int
i
=
0
;
i
<
(
int
)
expectedEdgeNodesXtoZRecv
.
size
();
i
++
)
{
if
(
para
->
parH
[
level
]
->
edgeNodesYtoZ
[
i
].
indexOfProcessNeighborRecv
!=
expectedEdgeNodesXtoZRecv
[
i
].
first
)
{
vectorsAreIdentical
=
false
;
break
;
}
if
(
para
->
parH
[
level
]
->
edgeNodesYtoZ
[
i
].
indexInRecvBuffer
!=
expectedEdgeNodesXtoZRecv
[
i
].
second
)
{
vectorsAreIdentical
=
false
;
break
;
}
}
EXPECT_TRUE
(
vectorsAreIdentical
);
vectorsAreIdentical
=
true
;
for
(
int
i
=
0
;
i
<
(
int
)
expectedEdgeNodesXtoZRecv
.
size
();
i
++
)
{
if
(
para
->
parH
[
level
]
->
edgeNodesYtoZ
[
i
].
indexOfProcessNeighborSend
!=
expectedEdgeNodesXtoZSend
[
i
].
first
)
{
vectorsAreIdentical
=
false
;
break
;
}
if
(
para
->
parH
[
level
]
->
edgeNodesYtoZ
[
i
].
indexInSendBuffer
!=
expectedEdgeNodesXtoZSend
[
i
].
second
)
{
vectorsAreIdentical
=
false
;
break
;
}
}
EXPECT_TRUE
(
vectorsAreIdentical
);
EXPECT_THAT
(
para
->
parH
[
level
]
->
edgeNodesYtoZ
.
size
(),
testing
::
Eq
(
expectedEdgeNodesYtoZRecv
.
size
()));
EXPECT_TRUE
(
compareEdgeNodesRecv
(
para
->
parH
[
level
]
->
edgeNodesYtoZ
,
expectedEdgeNodesYtoZRecv
))
<<
"the edgeNodesYtoZ for the receive process do not match the expected nodes"
;
EXPECT_TRUE
(
compareEdgeNodesSend
(
para
->
parH
[
level
]
->
edgeNodesYtoZ
,
expectedEdgeNodesYtoZSend
))
<<
"the edgeNodesYtoZ for the send process do not match the expected nodes"
;
}
\ No newline at end of file
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