Commit 9587ac67 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

add simple javaCL test, which fails on os x and windows 10

parent 4892ea13
...@@ -8,7 +8,6 @@ import java.util.function.BiFunction; ...@@ -8,7 +8,6 @@ import java.util.function.BiFunction;
import org.vadere.simulator.models.potential.timeCostFunction.loading.IPedestrianLoadingStrategy; import org.vadere.simulator.models.potential.timeCostFunction.loading.IPedestrianLoadingStrategy;
import org.vadere.state.attributes.scenario.AttributesAgent; import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.scenario.Agent; import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
/** /**
......
...@@ -14,6 +14,6 @@ public class JGaussianFilter extends GaussianFilter { ...@@ -14,6 +14,6 @@ public class JGaussianFilter extends GaussianFilter {
@Override @Override
public void filterImage() { public void filterImage() {
outputMatrix = Convolution.convolve(inputMatrix, kernel, matrixWidth, matrixHeight, kernelWidth); outputMatrix = Convolution.convolveSeperate(inputMatrix, kernel, kernel, matrixWidth, matrixHeight, kernelWidth);
} }
} }
...@@ -2,6 +2,7 @@ package org.vadere.simulator.projects.dataprocessing.processor; ...@@ -2,6 +2,7 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager; import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.state.attributes.processor.AttributesPedestrianDensityGaussianProcessor; import org.vadere.state.attributes.processor.AttributesPedestrianDensityGaussianProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
/** /**
* @author Mario Teixeira Parente * @author Mario Teixeira Parente
...@@ -19,4 +20,13 @@ public class PedestrianDensityGaussianProcessor extends PedestrianDensityProcess ...@@ -19,4 +20,13 @@ public class PedestrianDensityGaussianProcessor extends PedestrianDensityProcess
super.init(manager); super.init(manager);
} }
@Override
public AttributesProcessor getAttributes() {
if(super.getAttributes() == null) {
setAttributes(new AttributesPedestrianDensityGaussianProcessor());
}
return super.getAttributes();
}
} }
...@@ -2,6 +2,8 @@ package org.vadere.simulator.projects.dataprocessing.processor; ...@@ -2,6 +2,8 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.simulator.control.SimulationState; import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.models.density.IGaussianFilter; import org.vadere.simulator.models.density.IGaussianFilter;
import org.vadere.simulator.models.potential.timeCostFunction.loading.IPedestrianLoadingStrategy;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
/** /**
...@@ -35,37 +37,35 @@ public class PointDensityGaussianAlgorithm extends PointDensityAlgorithm { ...@@ -35,37 +37,35 @@ public class PointDensityGaussianAlgorithm extends PointDensityAlgorithm {
@Override @Override
public double getDensity(final VPoint pos, final SimulationState state) { public double getDensity(final VPoint pos, final SimulationState state) {
// if (state.getStep() > this.lastStep) { if (state.getStep() > this.lastStep) {
// // obstacle will not change so we do it once. // obstacle will not change so we do it once.
// if (!this.filteredObstacles && this.isObstacleDensity) { if (!this.filteredObstacles && this.isObstacleDensity) {
// this.obstacleFilter = IGaussianFilter.create( this.obstacleFilter = IGaussianFilter.create(
// state.getTopography(), state.getTopography(),
// this.scale, this.scale,
// this.standDev); this.standDev);
// this.obstacleFilter.filterImage(); this.obstacleFilter.filterImage();
// this.filteredObstacles = true; this.filteredObstacles = true;
// } }
//
// this.pedestrianFilter = IGaussianFilter.create( this.pedestrianFilter = IGaussianFilter.create(
// state.getTopography().getBounds(), state.getTopography().getBounds(),
// state.getTopography().getElements(Pedestrian.class), state.getTopography().getElements(Pedestrian.class),
// this.scale, this.scale,
// this.standDev, this.standDev,
// state.getTopography().getAttributesPedestrian(), state.getTopography().getAttributesPedestrian(),
// IPedestrianLoadingStrategy.create()); IPedestrianLoadingStrategy.create());
// this.pedestrianFilter.filterImage(); this.pedestrianFilter.filterImage();
//
// this.lastStep = state.getStep(); this.lastStep = state.getStep();
// } }
//
// double density = 0.0; double density = 0.0;
// if (this.isObstacleDensity) if (this.isObstacleDensity)
// density = this.obstacleFilter.getFilteredValue(pos.x, pos.y); density = this.obstacleFilter.getFilteredValue(pos.x, pos.y);
//
// density += this.pedestrianFilter.getFilteredValue(pos.x, pos.y); density += this.pedestrianFilter.getFilteredValue(pos.x, pos.y);
//
// return density; return density;
return 0.0; // TODO: uncomment above but wait until Bene fixed the OpenCL bug
} }
} }
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<repositories> <repositories>
<repository> <repository>
<id>nativelibs4java</id> <id>nativelibs4java-repo</id>
<name>nativelibs4java Maven2 Repository</name> <name>nativelibs4java Maven2 Repository</name>
<url>http://nativelibs4java.sourceforge.net/maven</url> <url>http://nativelibs4java.sourceforge.net/maven</url>
</repository> </repository>
...@@ -101,13 +101,15 @@ ...@@ -101,13 +101,15 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.nativelibs4java</groupId> <groupId>com.nativelibs4java</groupId>
<artifactId>libcl-bridj</artifactId> <artifactId>bridj</artifactId>
<version>1.0-SNAPSHOT</version> <version>0.7.0</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.nativelibs4java</groupId> <groupId>com.nativelibs4java</groupId>
<artifactId>javacl</artifactId> <artifactId>javacl</artifactId>
<version>1.0.0-RC4</version> <version>1.0.0-RC4</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -14,7 +14,8 @@ public class CLConvolution { ...@@ -14,7 +14,8 @@ public class CLConvolution {
private Convolve gaussianFilter; private Convolve gaussianFilter;
public CLConvolution() throws IOException { public CLConvolution() throws IOException {
context = JavaCL.createBestContext(CLPlatform.DeviceFeature.GPU, CLPlatform.DeviceFeature.MaxComputeUnits); //context = JavaCL.createBestContext(CLPlatform.DeviceFeature.CPU, CLPlatform.DeviceFeature.MaxComputeUnits);
context = JavaCL.createBestContext();
gaussianFilter = new Convolve(context); gaussianFilter = new Convolve(context);
} }
......
...@@ -129,7 +129,7 @@ public class Convolution { ...@@ -129,7 +129,7 @@ public class Convolution {
for (int yOut = 0; yOut < nHeight; yOut++) { for (int yOut = 0; yOut < nHeight; yOut++) {
for (int xOut = 0; xOut < nWidth; xOut++) { for (int xOut = 0; xOut < nWidth; xOut++) {
final int idxOut = yOut * nWidth + xOut; final int idxOut = yOut * nWidth + xOut;
outMatrix[idxOut] = convolveCol(tmpOutMatrix, rowVector, nWidth, nHeight, nFilterWidth, xOut, yOut); outMatrix[idxOut] = convolveCol(tmpOutMatrix, colVector, nWidth, nHeight, nFilterWidth, xOut, yOut);
} }
} }
return outMatrix; return outMatrix;
......
package org.vadere.util.opencl;
import com.nativelibs4java.opencl.CLContext;
import com.nativelibs4java.opencl.CLDevice;
import com.nativelibs4java.opencl.JavaCL;
import org.junit.Test;
/**
* @author Benedikt Zoennchen
*/
public class TestJavaCL {
@Test
public void testContext() {
CLDevice device = JavaCL.getBestDevice();
CLContext context = JavaCL.createContext(null, device);
/*for (int i = 0; i < devices.length; i++) {
System.err.println(i+": "+devices[i]);
}*/
System.err.println("Now GC'ing");
System.gc(); // crash here
System.err.println("GC'ed");
}
}
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