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
62d046af
Commit
62d046af
authored
2 years ago
by
Anna Wellmann
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/tests/copyEdgeNodes' into developAnna
parents
bd36b076
cd4568fc
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
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp
+1
-1
1 addition, 1 deletion
src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp
src/gpu/VirtualFluids_GPU/Communication/ExchangeData27Test.cpp
+91
-70
91 additions, 70 deletions
...pu/VirtualFluids_GPU/Communication/ExchangeData27Test.cpp
with
92 additions
and
71 deletions
src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp
+
1
−
1
View file @
62d046af
...
@@ -252,7 +252,7 @@ void exchangeCollDataYGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMe
...
@@ -252,7 +252,7 @@ void exchangeCollDataYGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMe
if
(
para
->
getUseStreams
()
&&
para
->
getNumberOfProcessNeighborsX
(
level
,
"recv"
)
>
0
&&
para
->
getParH
(
level
)
->
sendProcessNeighborY
.
size
()
!=
0
)
{
if
(
para
->
getUseStreams
()
&&
para
->
getNumberOfProcessNeighborsX
(
level
,
"recv"
)
>
0
&&
para
->
getParH
(
level
)
->
sendProcessNeighborY
.
size
()
!=
0
)
{
if
(
para
->
getParH
(
level
)
->
sendProcessNeighborY
[
0
].
numberOfNodes
==
(
*
sendProcessNeighborHost
)[
0
].
numberOfNodes
){
if
(
para
->
getParH
(
level
)
->
sendProcessNeighborY
[
0
].
numberOfNodes
==
(
*
sendProcessNeighborHost
)[
0
].
numberOfNodes
){
// check if in communication of all nodes (as opposed to reduced communication after fine to coarse)
// check if in communication of all nodes (as opposed to reduced communication after fine to coarse)
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoY
,
para
->
getParH
(
level
)
->
recvProcessNeighborX
,
*
sendProcessNeighborHost
);
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoY
,
para
->
getParH
(
level
)
->
recvProcessNeighborX
,
*
sendProcessNeighborHost
);
}
else
{
}
else
{
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoY
,
para
->
getParH
(
level
)
->
recvProcessNeighborsAfterFtoCX
,
*
sendProcessNeighborHost
);
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoY
,
para
->
getParH
(
level
)
->
recvProcessNeighborsAfterFtoCX
,
*
sendProcessNeighborHost
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/gpu/VirtualFluids_GPU/Communication/ExchangeData27Test.cpp
+
91
−
70
View file @
62d046af
...
@@ -3,19 +3,11 @@
...
@@ -3,19 +3,11 @@
#include
<filesystem>
#include
<filesystem>
#include
"ExchangeData27.h"
#include
"ExchangeData27.h"
#include
"gpu/VirtualFluids_GPU/LBM/LB.h"
#include
<basics/config/ConfigurationFile.h>
#include
<basics/config/ConfigurationFile.h>
auto
RealEq
=
[](
auto
value
)
{
SPtr
<
Parameter
>
initParameterClass
()
#ifdef VF_DOUBLE_ACCURACY
return
testing
::
DoubleEq
(
value
);
#else
return
testing
::
FloatEq
(
value
);
#endif
};
SPtr
<
Parameter
>
initParameterClass
(
std
::
shared_ptr
<
Parameter
>
&
para
)
{
{
std
::
filesystem
::
path
filePath
=
__FILE__
;
// assuming that the config file is stored parallel to this file.
std
::
filesystem
::
path
filePath
=
__FILE__
;
// assuming that the config file is stored parallel to this file.
filePath
.
replace_filename
(
"ExchangeData27Test.cfg"
);
filePath
.
replace_filename
(
"ExchangeData27Test.cfg"
);
...
@@ -24,84 +16,116 @@ SPtr<Parameter> initParameterClass(std::shared_ptr<Parameter> ¶)
...
@@ -24,84 +16,116 @@ SPtr<Parameter> initParameterClass(std::shared_ptr<Parameter> ¶)
return
std
::
make_shared
<
Parameter
>
(
config
,
1
,
0
);
return
std
::
make_shared
<
Parameter
>
(
config
,
1
,
0
);
}
}
TEST
(
ExchangeData27Test
,
copyEdgeNodes_XZ_CommunicationAfterFtoC
)
void
setUpFsByCopyingF0
(
std
::
vector
<
real
>
&
distributionVector
,
int
numberOfNodes
)
{
{
int
level
=
0
;
for
(
uint
direction
=
0
;
direction
<
dirEND
;
direction
++
)
{
SPtr
<
Parameter
>
para
=
initParameterClass
(
para
);
distributionVector
.
insert
(
distributionVector
.
end
(),
distributionVector
.
begin
(),
para
->
setMaxLevel
(
level
+
1
);
// setMaxLevel resizes parH
distributionVector
.
begin
()
+
numberOfNodes
);
para
->
initLBMSimulationParameter
();
// init parH
}
}
// indexInSend < 5 --> in AfterFToC
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
);
class
ExchangeData27Test_CopyEdgeNodesXZTest
:
public
testing
::
Test
{
protected:
SPtr
<
Parameter
>
para
;
int
level
=
0
;
int
numNodes
=
10
;
int
numNodes
=
10
;
int
numNodesAfterFtoC
=
5
;
std
::
vector
<
real
>
recvFs
;
std
::
vector
<
real
>
sendFs
;
std
::
vector
<
ProcessNeighbor27
>
sendProcessNeighborHost
;
std
::
vector
<
ProcessNeighbor27
>
recvProcessNeighborHost
(
1
);
std
::
vector
<
ProcessNeighbor27
>
recvProcessNeighborHost
;
std
::
vector
<
real
>
recvFs
(
numNodes
,
0.5
);
for
(
LBMSimulationParameter
::
EdgeNodePositions
edgeNode
:
para
->
getParH
(
level
)
->
edgeNodesXtoZ
){
void
SetUp
()
override
recvFs
[
edgeNode
.
indexInRecvBuffer
]
=
0.1
;
{
para
=
initParameterClass
();
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
);
}
}
for
(
uint
direction
=
0
;
direction
<=
dirEND
;
direction
++
){
recvFs
.
insert
(
recvFs
.
end
(),
recvFs
.
begin
(),
recvFs
.
begin
()
+
10
);
void
setUpRecvProcessNeighbors
(
int
numberOfNodesInRecv
)
{
recvFs
.
resize
(
numberOfNodesInRecv
);
std
::
fill
(
recvFs
.
begin
(),
recvFs
.
end
(),
0.5
);
// 0.5s should not be copied
for
(
LBMSimulationParameter
::
EdgeNodePositions
edgeNode
:
para
->
getParH
(
level
)
->
edgeNodesXtoZ
)
{
if
(
edgeNode
.
indexInRecvBuffer
>
numberOfNodesInRecv
){
continue
;
}
recvFs
[
edgeNode
.
indexInRecvBuffer
]
=
0.1
;
// 0.1s should be copied
}
setUpFsByCopyingF0
(
recvFs
,
numberOfNodesInRecv
);
recvProcessNeighborHost
.
resize
(
1
);
recvProcessNeighborHost
[
0
].
f
[
0
]
=
recvFs
.
data
();
recvProcessNeighborHost
[
0
].
numberOfNodes
=
numberOfNodesInRecv
;
}
}
recvProcessNeighborHost
[
0
].
f
[
0
]
=
recvFs
.
data
();
recvProcessNeighborHost
[
0
].
numberOfNodes
=
numNodes
;
void
setUpSendProcessNeighbors
(
int
numberOfNodesInSend
)
{
sendFs
.
resize
(
27
*
numberOfNodesInSend
);
std
::
fill
(
sendFs
.
begin
(),
sendFs
.
end
(),
0.0
);
sendProcessNeighborHost
.
resize
(
1
);
std
::
vector
<
ProcessNeighbor27
>
sendProcessNeighborHost
(
1
);
sendProcessNeighborHost
[
0
].
f
[
0
]
=
sendFs
.
data
();
std
::
vector
<
real
>
sendFs
(
27
*
numNodesAfterFtoC
,
0.0
);
sendProcessNeighborHost
[
0
].
numberOfNodes
=
numberOfNodesInSend
;
sendProcessNeighborHost
[
0
].
f
[
0
]
=
sendFs
.
data
();
}
sendProcessNeighborHost
[
0
].
numberOfNodes
=
numNodesAfterFtoC
;
};
TEST_F
(
ExchangeData27Test_CopyEdgeNodesXZTest
,
copyEdgeNodes_XZ_CommunicationAfterFtoC_recvVectorFullSize
)
{
int
numNodesAfterFtoC
=
5
;
// indexInSend < 5 --> mode is in AfterFToC
setUpRecvProcessNeighbors
(
numNodes
);
setUpSendProcessNeighbors
(
numNodesAfterFtoC
);
// expected
// expected
std
::
vector
<
real
>
expectedFs
(
numNodesAfterFtoC
,
0.0
);
std
::
vector
<
real
>
expectedFs
(
numNodesAfterFtoC
,
0.0
);
expectedFs
[
1
]
=
0.1
;
expectedFs
[
1
]
=
0.1
;
expectedFs
[
3
]
=
0.1
;
expectedFs
[
3
]
=
0.1
;
std
::
vector
<
real
>
expectedFsAllDirections
;
setUpFsByCopyingF0
(
expectedFs
,
numNodesAfterFtoC
);
for
(
uint
direction
=
0
;
direction
<=
dirEND
;
direction
++
){
expectedFsAllDirections
.
insert
(
expectedFsAllDirections
.
end
(),
expectedFs
.
begin
(),
expectedFs
.
end
());
}
// act
// act
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoZ
,
recvProcessNeighborHost
,
sendProcessNeighborHost
);
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoZ
,
recvProcessNeighborHost
,
sendProcessNeighborHost
);
// convert result to std::vector
// convert result to std::vector
std
::
vector
<
real
>
result
;
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
AllDirections
));
EXPECT_THAT
(
result
,
testing
::
Eq
(
expectedFs
));
}
}
TEST
(
ExchangeData27Test
,
copyEdgeNodes_XZ_Communicat
eAll
)
TEST
_F
(
ExchangeData27Test
_CopyEdgeNodesXZTest
,
copyEdgeNodes_XZ_Communicat
ionAfterFtoC_recvVectorShort
)
{
{
int
level
=
0
;
int
numNodesAfterFtoC
=
5
;
// indexInSend < 5 --> mode is in AfterFToC
SPtr
<
Parameter
>
para
=
initParameterClass
(
para
);
setUpRecvProcessNeighbors
(
numNodesAfterFtoC
);
para
->
setMaxLevel
(
level
+
1
);
// setMaxLevel resizes parH
setUpSendProcessNeighbors
(
numNodesAfterFtoC
);
para
->
initLBMSimulationParameter
();
// init parH
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
1
,
0
,
1
);
// expected
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
6
,
0
,
6
);
std
::
vector
<
real
>
expectedFs
(
numNodesAfterFtoC
,
0.0
);
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
2
,
0
,
3
);
expectedFs
[
1
]
=
0.1
;
para
->
getParH
(
level
)
->
edgeNodesXtoZ
.
emplace_back
(
0
,
7
,
0
,
8
);
expectedFs
[
3
]
=
0.1
;
setUpFsByCopyingF0
(
expectedFs
,
numNodesAfterFtoC
);
int
numNodes
=
10
;
// act
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoZ
,
recvProcessNeighborHost
,
sendProcessNeighborHost
);
std
::
vector
<
ProcessNeighbor27
>
recvProcessNeighborHost
(
1
);
// convert result to std::vector
std
::
vector
<
real
>
recvFs
(
27
*
numNodes
,
0.1
);
std
::
vector
<
real
>
result
;
recvProcessNeighborHost
[
0
].
f
[
0
]
=
recvFs
.
data
();
result
.
assign
(
sendProcessNeighborHost
[
0
].
f
[
0
],
sendProcessNeighborHost
[
0
].
f
[
0
]
+
27
*
numNodesAfterFtoC
);
recvProcessNeighborHost
[
0
].
numberOfNodes
=
numNodes
;
std
::
vector
<
ProcessNeighbor27
>
sendProcessNeighborHost
(
1
);
std
::
vector
<
real
>
sendFs
(
27
*
numNodes
,
0.0
);
sendProcessNeighborHost
[
0
].
f
[
0
]
=
sendFs
.
data
();
sendProcessNeighborHost
[
0
].
numberOfNodes
=
numNodes
;
EXPECT_THAT
(
result
,
testing
::
Eq
(
expectedFs
));
}
TEST_F
(
ExchangeData27Test_CopyEdgeNodesXZTest
,
copyEdgeNodes_XZ_CommunicateAll
)
{
setUpRecvProcessNeighbors
(
numNodes
);
setUpSendProcessNeighbors
(
numNodes
);
// expected
// expected
std
::
vector
<
real
>
expectedFs
(
numNodes
,
0.0
);
std
::
vector
<
real
>
expectedFs
(
numNodes
,
0.0
);
...
@@ -109,17 +133,14 @@ TEST(ExchangeData27Test, copyEdgeNodes_XZ_CommunicateAll)
...
@@ -109,17 +133,14 @@ TEST(ExchangeData27Test, copyEdgeNodes_XZ_CommunicateAll)
expectedFs
[
3
]
=
0.1
;
expectedFs
[
3
]
=
0.1
;
expectedFs
[
6
]
=
0.1
;
expectedFs
[
6
]
=
0.1
;
expectedFs
[
8
]
=
0.1
;
expectedFs
[
8
]
=
0.1
;
std
::
vector
<
real
>
expectedFsAllDirections
;
setUpFsByCopyingF0
(
expectedFs
,
numNodes
);
for
(
uint
direction
=
0
;
direction
<=
dirEND
;
direction
++
){
expectedFsAllDirections
.
insert
(
expectedFsAllDirections
.
end
(),
expectedFs
.
begin
(),
expectedFs
.
end
());
}
// act
// act
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoZ
,
recvProcessNeighborHost
,
sendProcessNeighborHost
);
copyEdgeNodes
(
para
->
getParH
(
level
)
->
edgeNodesXtoZ
,
recvProcessNeighborHost
,
sendProcessNeighborHost
);
// convert result to std::vector
// convert result to std::vector
std
::
vector
<
real
>
result
;
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