Commit b264e2e7 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

OpenCL bug-fix: memory leaks.

parent 376f75c4
...@@ -107,6 +107,7 @@ public class CLConvolution { ...@@ -107,6 +107,7 @@ public class CLConvolution {
initCL(); initCL();
buildProgram(); buildProgram();
hostGaussKernel = CLUtils.toFloatBuffer(kernel);
hostScenario = MemoryUtil.memAllocFloat(matrixWidth * matrixHeight); hostScenario = MemoryUtil.memAllocFloat(matrixWidth * matrixHeight);
output = MemoryUtil.memAllocFloat(matrixWidth * matrixHeight); output = MemoryUtil.memAllocFloat(matrixWidth * matrixHeight);
......
...@@ -48,7 +48,7 @@ public class TestConvolution { ...@@ -48,7 +48,7 @@ public class TestConvolution {
float[] input = Convolution.generdateInputMatrix(inputWidth * inputHeight); float[] input = Convolution.generdateInputMatrix(inputWidth * inputHeight);
float[] javaOutput = Convolution.convolve(input, kernel, inputWidth, inputHeight, kernelWidth); float[] javaOutput = Convolution.convolve(input, kernel, inputWidth, inputHeight, kernelWidth);
CLConvolution clConvolution = new CLConvolution(inputWidth, inputHeight, kernelWidth, kernel); CLConvolution clConvolution = new CLConvolution(CLConvolution.KernelType.NonSeparate, inputWidth, inputHeight, kernelWidth, kernel);
float[] clOutput = clConvolution.convolve(input); float[] clOutput = clConvolution.convolve(input);
clConvolution.clearCL(); clConvolution.clearCL();
equalsMatrixValues(javaOutput, clOutput, 0.00001f); equalsMatrixValues(javaOutput, clOutput, 0.00001f);
...@@ -66,7 +66,7 @@ public class TestConvolution { ...@@ -66,7 +66,7 @@ public class TestConvolution {
float[] output = Convolution.convolveCol(input, rowVector, inputWidth, inputHeight, kernelWidth); float[] output = Convolution.convolveCol(input, rowVector, inputWidth, inputHeight, kernelWidth);
CLConvolution clConvolution = new CLConvolution(inputWidth, inputHeight, kernelWidth, rowVector); CLConvolution clConvolution = new CLConvolution(CLConvolution.KernelType.Col, inputWidth, inputHeight, kernelWidth, rowVector);
float[] clOutput = clConvolution.convolve(input); float[] clOutput = clConvolution.convolve(input);
clConvolution.clearCL(); clConvolution.clearCL();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment