Skip to content
Snippets Groups Projects
Commit 10049625 authored by peters's avatar peters
Browse files

Fix memory leak in gpu kernel modifications

parent 12d08af0
No related branches found
No related tags found
1 merge request!55Fix memory issue.
...@@ -42,14 +42,18 @@ extern "C" __global__ void LBCalcMac27( real* vxD, ...@@ -42,14 +42,18 @@ extern "C" __global__ void LBCalcMac27( real* vxD,
const unsigned int k = nx*(ny*z + y) + x; // Zugriff auf arrays im device const unsigned int k = nx*(ny*z + y) + x; // Zugriff auf arrays im device
if(k >= size_Mat)
return;
if(!vf::gpu::isValidFluidNode(geoD[k]))
return;
rhoD[k] = c0o1; rhoD[k] = c0o1;
vxD[k] = c0o1; vxD[k] = c0o1;
vyD[k] = c0o1; vyD[k] = c0o1;
vzD[k] = c0o1; vzD[k] = c0o1;
if(!vf::gpu::isValidFluidNode(k, size_Mat, geoD[k]))
return;
vf::gpu::DistributionWrapper distr_wrapper(distributions, size_Mat, isEvenTimestep, k, neighborX, neighborY, neighborZ); vf::gpu::DistributionWrapper distr_wrapper(distributions, size_Mat, isEvenTimestep, k, neighborX, neighborY, neighborZ);
const auto& distribution = distr_wrapper.distribution; const auto& distribution = distr_wrapper.distribution;
...@@ -266,15 +270,18 @@ extern "C" __global__ void LBCalcMacCompSP27(real *vxD, real *vyD, real *vzD, re ...@@ -266,15 +270,18 @@ extern "C" __global__ void LBCalcMacCompSP27(real *vxD, real *vyD, real *vzD, re
{ {
const unsigned k = vf::gpu::getNodeIndex(); const unsigned k = vf::gpu::getNodeIndex();
if(k >= size_Mat)
return;
if (!vf::gpu::isValidFluidNode(geoD[k]))
return;
pressD[k] = c0o1; pressD[k] = c0o1;
rhoD[k] = c0o1; rhoD[k] = c0o1;
vxD[k] = c0o1; vxD[k] = c0o1;
vyD[k] = c0o1; vyD[k] = c0o1;
vzD[k] = c0o1; vzD[k] = c0o1;
if (!vf::gpu::isValidFluidNode(k, size_Mat, geoD[k]))
return;
vf::gpu::DistributionWrapper distr_wrapper(distributions, size_Mat, isEvenTimestep, k, neighborX, neighborY, vf::gpu::DistributionWrapper distr_wrapper(distributions, size_Mat, isEvenTimestep, k, neighborX, neighborY,
neighborZ); neighborZ);
const auto &distribution = distr_wrapper.distribution; const auto &distribution = distr_wrapper.distribution;
......
...@@ -32,9 +32,11 @@ template<typename KernelFunctor> ...@@ -32,9 +32,11 @@ template<typename KernelFunctor>
__global__ void runKernel(KernelFunctor kernel, GPUKernelParameter kernelParameter) __global__ void runKernel(KernelFunctor kernel, GPUKernelParameter kernelParameter)
{ {
const uint k = getNodeIndex(); const uint k = getNodeIndex();
const uint nodeType = kernelParameter.typeOfGridNode[k];
if (!isValidFluidNode(k, kernelParameter.size_Mat, nodeType)) if(k >= kernelParameter.size_Mat)
return;
if (!isValidFluidNode(kernelParameter.typeOfGridNode[k]))
return; return;
DistributionWrapper distributionWrapper { DistributionWrapper distributionWrapper {
......
...@@ -158,10 +158,9 @@ __device__ unsigned int getNodeIndex() ...@@ -158,10 +158,9 @@ __device__ unsigned int getNodeIndex()
return nx * (ny * z + y) + x; return nx * (ny * z + y) + x;
} }
__device__ bool isValidFluidNode(uint k, int size_Mat, uint nodeType) __device__ bool isValidFluidNode(uint nodeType)
{ {
return (k < size_Mat) && return (nodeType == GEO_FLUID || nodeType == GEO_PM_0 || nodeType == GEO_PM_1 || nodeType == GEO_PM_2);
(nodeType == GEO_FLUID || nodeType == GEO_PM_0 || nodeType == GEO_PM_1 || nodeType == GEO_PM_2);
} }
......
...@@ -90,7 +90,7 @@ struct DistributionWrapper ...@@ -90,7 +90,7 @@ struct DistributionWrapper
__device__ unsigned int getNodeIndex(); __device__ unsigned int getNodeIndex();
__device__ bool isValidFluidNode(uint k, int size_Mat, uint nodeType); __device__ bool isValidFluidNode(uint nodeType);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment