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
7cd7159f
Commit
7cd7159f
authored
2 years ago
by
Anna Wellmann
Browse files
Options
Downloads
Patches
Plain Diff
Add move copying of fs into function
parent
5494db4b
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/Communication/ExchangeData27Test.cpp
+46
-52
46 additions, 52 deletions
...pu/VirtualFluids_GPU/Communication/ExchangeData27Test.cpp
with
46 additions
and
52 deletions
src/gpu/VirtualFluids_GPU/Communication/ExchangeData27Test.cpp
+
46
−
52
View file @
7cd7159f
...
...
@@ -6,15 +6,6 @@
#include
<basics/config/ConfigurationFile.h>
auto
RealEq
=
[](
auto
value
)
{
#ifdef VF_DOUBLE_ACCURACY
return
testing
::
DoubleEq
(
value
);
#else
return
testing
::
FloatEq
(
value
);
#endif
};
SPtr
<
Parameter
>
initParameterClass
()
{
std
::
filesystem
::
path
filePath
=
__FILE__
;
// assuming that the config file is stored parallel to this file.
...
...
@@ -24,65 +15,68 @@ SPtr<Parameter> initParameterClass()
return
std
::
make_shared
<
Parameter
>
(
config
,
1
,
0
);
}
class
ExchangeData27Test_CopyEdgeNodesXZTest
:
public
testing
::
Test
{
protected:
SPtr
<
Parameter
>
para
;
int
level
=
0
;
int
numNodes
=
10
;
void
setUpFsByCopyingF0
(
std
::
vector
<
real
>
&
distributionVector
,
int
numberOfNodes
)
{
for
(
uint
direction
=
0
;
direction
<
dirEND
;
direction
++
)
{
distributionVector
.
insert
(
distributionVector
.
end
(),
distributionVector
.
begin
(),
distributionVector
.
begin
()
+
numberOfNodes
);
}
}
class
ExchangeData27Test_CopyEdgeNodesXZTest
:
public
testing
::
Test
{
protected:
SPtr
<
Parameter
>
para
;
int
level
=
0
;
int
numNodes
=
10
;
void
SetUp
()
override
{
void
SetUp
()
override
{
para
=
initParameterClass
();
para
->
setMaxLevel
(
level
+
1
);
// setMaxLevel resizes parH
para
->
setMaxLevel
(
level
+
1
);
// setMaxLevel resizes parH
para
->
initLBMSimulationParameter
();
// init parH
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
1
,
0
,
1
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
6
,
0
,
6
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
2
,
0
,
3
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
7
,
0
,
8
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
7
,
0
,
8
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
7
,
0
,
8
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
1
,
0
,
1
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
6
,
0
,
6
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
2
,
0
,
3
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
7
,
0
,
8
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
7
,
0
,
8
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
7
,
0
,
8
);
}
};
TEST_F
(
ExchangeData27Test_CopyEdgeNodesXZTest
,
copyEdgeNodes_XZ_CommunicationAfterFtoC_recvVectorFullSize
)
{
{
int
numNodesAfterFtoC
=
5
;
// indexInSend < 5 --> in AfterFToC
// recvProcessNeighborHost
std
::
vector
<
ProcessNeighbor27
>
recvProcessNeighborHost
(
1
);
std
::
vector
<
real
>
recvFs
(
numNodes
,
0.5
);
for
(
LBMSimulationParameter
::
EdgeNodePositions
edgeNode
:
para
->
getParH
(
level
)
->
edgeNodesXtoZ
){
recvFs
[
edgeNode
.
indexInRecvBuffer
]
=
0.1
;
std
::
vector
<
real
>
recvFs
(
numNodes
,
0.5
);
// 0.5s should not be copied
for
(
LBMSimulationParameter
::
EdgeNodePositions
edgeNode
:
para
->
getParH
(
level
)
->
edgeNodesXtoZ
)
{
recvFs
[
edgeNode
.
indexInRecvBuffer
]
=
0.1
;
// 0.1s should be copied
}
for
(
uint
direction
=
0
;
direction
<
dirEND
;
direction
++
){
recvFs
.
insert
(
recvFs
.
end
(),
recvFs
.
begin
(),
recvFs
.
begin
()
+
numNodes
);
}
recvProcessNeighborHost
[
0
].
f
[
0
]
=
recvFs
.
data
();
setUpFsByCopyingF0
(
recvFs
,
numNodes
);
recvProcessNeighborHost
[
0
].
f
[
0
]
=
recvFs
.
data
();
recvProcessNeighborHost
[
0
].
numberOfNodes
=
numNodes
;
// sendProcessNeighborHost
std
::
vector
<
ProcessNeighbor27
>
sendProcessNeighborHost
(
1
);
std
::
vector
<
real
>
sendFs
(
27
*
numNodesAfterFtoC
,
0.0
);
sendProcessNeighborHost
[
0
].
f
[
0
]
=
sendFs
.
data
();
std
::
vector
<
real
>
sendFs
(
27
*
numNodesAfterFtoC
,
0.0
);
sendProcessNeighborHost
[
0
].
f
[
0
]
=
sendFs
.
data
();
sendProcessNeighborHost
[
0
].
numberOfNodes
=
numNodesAfterFtoC
;
// expected
std
::
vector
<
real
>
expectedFs
(
numNodesAfterFtoC
,
0.0
);
expectedFs
[
1
]
=
0.1
;
expectedFs
[
3
]
=
0.1
;
// std::vector<real> expectedFs;
for
(
uint
direction
=
0
;
direction
<
dirEND
;
direction
++
){
expectedFs
.
insert
(
expectedFs
.
end
(),
expectedFs
.
begin
(),
expectedFs
.
begin
()
+
numNodesAfterFtoC
);
}
setUpFsByCopyingF0
(
expectedFs
,
numNodesAfterFtoC
);
// act
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoZ
,
recvProcessNeighborHost
,
sendProcessNeighborHost
);
// convert result to std::vector
std
::
vector
<
real
>
result
;
result
.
assign
(
sendProcessNeighborHost
[
0
].
f
[
0
],
sendProcessNeighborHost
[
0
].
f
[
0
]
+
27
*
numNodesAfterFtoC
);
result
.
assign
(
sendProcessNeighborHost
[
0
].
f
[
0
],
sendProcessNeighborHost
[
0
].
f
[
0
]
+
27
*
numNodesAfterFtoC
);
EXPECT_THAT
(
result
,
testing
::
Eq
(
expectedFs
));
}
...
...
@@ -93,34 +87,34 @@ TEST_F(ExchangeData27Test_CopyEdgeNodesXZTest, copyEdgeNodes_XZ_CommunicateAll)
// recvProcessNeighborHost
std
::
vector
<
ProcessNeighbor27
>
recvProcessNeighborHost
(
1
);
std
::
vector
<
real
>
recvFs
(
27
*
numNodes
,
0.1
);
recvProcessNeighborHost
[
0
].
f
[
0
]
=
recvFs
.
data
();
std
::
vector
<
real
>
recvFs
(
numNodes
,
0.5
);
// 0.5s should not be copied
for
(
LBMSimulationParameter
::
EdgeNodePositions
edgeNode
:
para
->
getParH
(
level
)
->
edgeNodesXtoZ
)
{
recvFs
[
edgeNode
.
indexInRecvBuffer
]
=
0.1
;
// 0.1s should be copied
}
setUpFsByCopyingF0
(
recvFs
,
numNodes
);
recvProcessNeighborHost
[
0
].
f
[
0
]
=
recvFs
.
data
();
recvProcessNeighborHost
[
0
].
numberOfNodes
=
numNodes
;
// sendProcessNeighborHost
std
::
vector
<
ProcessNeighbor27
>
sendProcessNeighborHost
(
1
);
std
::
vector
<
real
>
sendFs
(
27
*
numNodes
,
0.0
);
sendProcessNeighborHost
[
0
].
f
[
0
]
=
sendFs
.
data
();
std
::
vector
<
real
>
sendFs
(
27
*
numNodes
,
0.0
);
sendProcessNeighborHost
[
0
].
f
[
0
]
=
sendFs
.
data
();
sendProcessNeighborHost
[
0
].
numberOfNodes
=
numNodes
;
// expected
std
::
vector
<
real
>
expectedFs
(
numNodes
,
0.0
);
expectedFs
[
1
]
=
0.1
;
expectedFs
[
3
]
=
0.1
;
expectedFs
[
6
]
=
0.1
;
expectedFs
[
8
]
=
0.1
;
std
::
vector
<
real
>
expectedFsAllDirections
;
for
(
uint
direction
=
0
;
direction
<=
dirEND
;
direction
++
){
expectedFsAllDirections
.
insert
(
expectedFsAllDirections
.
end
(),
expectedFs
.
begin
(),
expectedFs
.
end
());
}
setUpFsByCopyingF0
(
expectedFs
,
numNodes
);
// act
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoZ
,
recvProcessNeighborHost
,
sendProcessNeighborHost
);
// convert result to std::vector
std
::
vector
<
real
>
result
;
result
.
assign
(
sendProcessNeighborHost
[
0
].
f
[
0
],
sendProcessNeighborHost
[
0
].
f
[
0
]
+
27
*
numNodes
);
result
.
assign
(
sendProcessNeighborHost
[
0
].
f
[
0
],
sendProcessNeighborHost
[
0
].
f
[
0
]
+
27
*
numNodes
);
EXPECT_THAT
(
result
,
testing
::
Eq
(
expectedFs
AllDirections
));
EXPECT_THAT
(
result
,
testing
::
Eq
(
expectedFs
));
}
\ 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