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
ed6ee96e
Commit
ed6ee96e
authored
2 years ago
by
Anna Wellmann
Browse files
Options
Downloads
Patches
Plain Diff
Add CudaKernelManager from OpenSource
parent
fa02603f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!113
Use kernel managers to call the kernels (LBM, AdvectionDiffusion, BoundaryConditions)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gpu/VirtualFluids_GPU/GPU/CudaKernelManager.cpp
+182
-0
182 additions, 0 deletions
src/gpu/VirtualFluids_GPU/GPU/CudaKernelManager.cpp
src/gpu/VirtualFluids_GPU/GPU/CudaKernelManager.h
+86
-0
86 additions, 0 deletions
src/gpu/VirtualFluids_GPU/GPU/CudaKernelManager.h
with
268 additions
and
0 deletions
src/gpu/VirtualFluids_GPU/GPU/CudaKernelManager.cpp
0 → 100644
+
182
−
0
View file @
ed6ee96e
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// This file is part of VirtualFluids. VirtualFluids is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file CudaKernelManager.cpp
//! \ingroup GPU
//! \author Martin Schoenherr
//=======================================================================================
#include
<cuda_runtime.h>
#include
<helper_cuda.h>
#include
"CudaKernelManager.h"
#include
"GPU_Interface.h"
#include
<Parameter/Parameter.h>
void
CudaKernelManager
::
runLBMKernel
(
SPtr
<
Parameter
>
para
)
{
if
(
para
->
getIsADcalculationOn
())
{
CumulantK17LBMDeviceKernelAD
(
para
->
getParD
()
->
numberofthreads
,
para
->
getParD
()
->
omega
,
para
->
getParD
()
->
typeOfGridNode
,
para
->
getParD
()
->
neighborX
,
para
->
getParD
()
->
neighborY
,
para
->
getParD
()
->
neighborZ
,
para
->
getParD
()
->
distributions
.
f
[
0
],
para
->
getParD
()
->
distributionsAD
.
f
[
0
],
para
->
getParD
()
->
numberOfNodes
,
para
->
getParD
()
->
forcing
,
para
->
getParD
()
->
isEvenTimestep
);
}
else
{
CumulantK17LBMDeviceKernel
(
para
->
getParD
()
->
numberofthreads
,
para
->
getParD
()
->
omega
,
para
->
getParD
()
->
typeOfGridNode
,
para
->
getParD
()
->
neighborX
,
para
->
getParD
()
->
neighborY
,
para
->
getParD
()
->
neighborZ
,
para
->
getParD
()
->
distributions
.
f
[
0
],
para
->
getParD
()
->
numberOfNodes
,
para
->
getParD
()
->
forcing
,
para
->
getParD
()
->
isEvenTimestep
);
}
}
void
CudaKernelManager
::
runVelocityBCKernel
(
SPtr
<
Parameter
>
para
)
{
if
(
para
->
getParD
()
->
numberOfVeloBCnodes
>
0
)
{
QVelDevicePlainBB27
(
para
->
getParD
()
->
numberofthreads
,
para
->
getParD
()
->
veloBC
.
Vx
,
para
->
getParD
()
->
veloBC
.
Vy
,
para
->
getParD
()
->
veloBC
.
Vz
,
para
->
getParD
()
->
distributions
.
f
[
0
],
para
->
getParD
()
->
veloBC
.
k
,
para
->
getParD
()
->
veloBC
.
q27
[
0
],
para
->
getParD
()
->
numberOfVeloBCnodes
,
para
->
getParD
()
->
veloBC
.
kArray
,
para
->
getParD
()
->
neighborX
,
para
->
getParD
()
->
neighborY
,
para
->
getParD
()
->
neighborZ
,
para
->
getParD
()
->
numberOfNodes
,
para
->
getParD
()
->
isEvenTimestep
);
}
}
void
CudaKernelManager
::
runGeoBCKernel
(
SPtr
<
Parameter
>
para
)
{
if
(
para
->
getParD
()
->
numberOfGeoBCnodes
>
0
)
{
// ...
}
}
void
runSlipBCKernel
(
SPtr
<
Parameter
>
para
){
if
(
para
->
getParD
()
->
numberOfSlipBCnodes
>
0
)
{
// ...
}
}
void
runNoSlipBCKernel
(
SPtr
<
Parameter
>
para
){
if
(
para
->
getParD
()
->
numberOfNoSlipBCnodes
>
0
)
{
// ...
}
}
void
runPressureBCKernel
(
SPtr
<
Parameter
>
para
){
if
(
para
->
getParD
()
->
numberOfPressureBCnodes
>
0
)
{
// ...
}
}
void
CudaKernelManager
::
calculateMacroscopicValues
(
SPtr
<
Parameter
>
para
)
{
if
(
para
->
getIsADcalculationOn
())
{
CalcMacADCompSP27
(
para
->
getParD
()
->
velocityX
,
para
->
getParD
()
->
velocityY
,
para
->
getParD
()
->
velocityZ
,
para
->
getParD
()
->
rho
,
para
->
getParD
()
->
pressure
,
para
->
getParD
()
->
typeOfGridNode
,
para
->
getParD
()
->
neighborX
,
para
->
getParD
()
->
neighborY
,
para
->
getParD
()
->
neighborZ
,
para
->
getParD
()
->
numberOfNodes
,
para
->
getParD
()
->
numberofthreads
,
para
->
getParD
()
->
distributions
.
f
[
0
],
para
->
getParD
()
->
distributionsAD
.
f
[
0
],
para
->
getParD
()
->
forcing
,
para
->
getParD
()
->
isEvenTimestep
);
}
else
{
CalcMacCompSP27
(
para
->
getParD
()
->
velocityX
,
para
->
getParD
()
->
velocityY
,
para
->
getParD
()
->
velocityZ
,
para
->
getParD
()
->
rho
,
para
->
getParD
()
->
pressure
,
para
->
getParD
()
->
typeOfGridNode
,
para
->
getParD
()
->
neighborX
,
para
->
getParD
()
->
neighborY
,
para
->
getParD
()
->
neighborZ
,
para
->
getParD
()
->
numberOfNodes
,
para
->
getParD
()
->
numberofthreads
,
para
->
getParD
()
->
distributions
.
f
[
0
],
para
->
getParD
()
->
isEvenTimestep
);
}
}
SPtr
<
CudaKernelManager
>
CudaKernelManager
::
make
(
SPtr
<
Parameter
>
parameter
)
{
return
SPtr
<
CudaKernelManager
>
(
new
CudaKernelManager
(
parameter
));
}
CudaKernelManager
::
CudaKernelManager
(
SPtr
<
Parameter
>
parameter
)
{
this
->
parameter
=
parameter
;
}
CudaKernelManager
::
CudaKernelManager
(
const
CudaKernelManager
&
)
{
}
This diff is collapsed.
Click to expand it.
src/gpu/VirtualFluids_GPU/GPU/CudaKernelManager.h
0 → 100644
+
86
−
0
View file @
ed6ee96e
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// This file is part of VirtualFluids. VirtualFluids is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file CudaKernelManager.h
//! \ingroup GPU
//! \author Martin Schoenherr
//=======================================================================================
#ifndef CudaKernelManager_H
#define CudaKernelManager_H
#include
<memory>
#include
"PointerDefinitions.h"
#include
"VirtualFluids_GPU_export.h"
//! \brief Class forwarding for Parameter
class
Parameter
;
//! \class CudaKernelManager
//! \brief manage the cuda kernel calls
class
VIRTUALFLUIDS_GPU_EXPORT
CudaKernelManager
{
public:
//! \brief makes an object of CudaKernelManager
//! \param para shared pointer to instance of class Parameter
static
SPtr
<
CudaKernelManager
>
make
(
std
::
shared_ptr
<
Parameter
>
parameter
);
//! \brief calls the device function of the lattice Boltzmann kernel
void
runLBMKernel
(
SPtr
<
Parameter
>
para
);
//! \brief calls the device function of the velocity boundary condition
void
runVelocityBCKernel
(
SPtr
<
Parameter
>
para
);
//! \brief calls the device function of the geometry boundary condition
void
runGeoBCKernel
(
SPtr
<
Parameter
>
para
);
//! \brief calls the device function of the slip boundary condition
void
runSlipBCKernel
(
SPtr
<
Parameter
>
para
);
//! \brief calls the device function of the no-slip boundary condition
void
runNoSlipBCKernel
(
SPtr
<
Parameter
>
para
);
//! \brief calls the device function of the pressure boundary condition
void
runPressureBCKernel
(
SPtr
<
Parameter
>
para
);
//! \brief calls the device function that calculates the macroscopic values
void
calculateMacroscopicValues
(
SPtr
<
Parameter
>
para
);
private:
//! Class constructor
//! \param parameter shared pointer to instance of class Parameter
CudaKernelManager
(
SPtr
<
Parameter
>
parameter
);
//! Class copy constructor
//! \param CudaKernelManager is a reference to CudaKernelManager object
CudaKernelManager
(
const
CudaKernelManager
&
);
//! \property para is a shared pointer to an object of Parameter
SPtr
<
Parameter
>
parameter
;
};
#endif
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