Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
9587ac67
Commit
9587ac67
authored
Mar 28, 2017
by
Benedikt Zoennchen
Browse files
add simple javaCL test, which fails on os x and windows 10
parent
4892ea13
Changes
8
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/src/org/vadere/simulator/models/density/IGaussianFilter.java
View file @
9587ac67
...
...
@@ -8,7 +8,6 @@ import java.util.function.BiFunction;
import
org.vadere.simulator.models.potential.timeCostFunction.loading.IPedestrianLoadingStrategy
;
import
org.vadere.state.attributes.scenario.AttributesAgent
;
import
org.vadere.state.scenario.Agent
;
import
org.vadere.state.scenario.Pedestrian
;
import
org.vadere.state.scenario.Topography
;
/**
...
...
VadereSimulator/src/org/vadere/simulator/models/density/JGaussianFilter.java
View file @
9587ac67
...
...
@@ -14,6 +14,6 @@ public class JGaussianFilter extends GaussianFilter {
@Override
public
void
filterImage
()
{
outputMatrix
=
Convolution
.
convolve
(
inputMatrix
,
kernel
,
matrixWidth
,
matrixHeight
,
kernelWidth
);
outputMatrix
=
Convolution
.
convolve
Seperate
(
inputMatrix
,
kernel
,
kernel
,
matrixWidth
,
matrixHeight
,
kernelWidth
);
}
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/PedestrianDensityGaussianProcessor.java
View file @
9587ac67
...
...
@@ -2,6 +2,7 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import
org.vadere.simulator.projects.dataprocessing.ProcessorManager
;
import
org.vadere.state.attributes.processor.AttributesPedestrianDensityGaussianProcessor
;
import
org.vadere.state.attributes.processor.AttributesProcessor
;
/**
* @author Mario Teixeira Parente
...
...
@@ -19,4 +20,13 @@ public class PedestrianDensityGaussianProcessor extends PedestrianDensityProcess
super
.
init
(
manager
);
}
@Override
public
AttributesProcessor
getAttributes
()
{
if
(
super
.
getAttributes
()
==
null
)
{
setAttributes
(
new
AttributesPedestrianDensityGaussianProcessor
());
}
return
super
.
getAttributes
();
}
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/PointDensityGaussianAlgorithm.java
View file @
9587ac67
...
...
@@ -2,6 +2,8 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import
org.vadere.simulator.control.SimulationState
;
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
;
/**
...
...
@@ -35,37 +37,35 @@ public class PointDensityGaussianAlgorithm extends PointDensityAlgorithm {
@Override
public
double
getDensity
(
final
VPoint
pos
,
final
SimulationState
state
)
{
// if (state.getStep() > this.lastStep) {
// // obstacle will not change so we do it once.
// if (!this.filteredObstacles && this.isObstacleDensity) {
// this.obstacleFilter = IGaussianFilter.create(
// state.getTopography(),
// this.scale,
// this.standDev);
// this.obstacleFilter.filterImage();
// this.filteredObstacles = true;
// }
//
// this.pedestrianFilter = IGaussianFilter.create(
// state.getTopography().getBounds(),
// state.getTopography().getElements(Pedestrian.class),
// this.scale,
// this.standDev,
// state.getTopography().getAttributesPedestrian(),
// IPedestrianLoadingStrategy.create());
// this.pedestrianFilter.filterImage();
//
// this.lastStep = state.getStep();
// }
//
// double density = 0.0;
// if (this.isObstacleDensity)
// density = this.obstacleFilter.getFilteredValue(pos.x, pos.y);
//
// density += this.pedestrianFilter.getFilteredValue(pos.x, pos.y);
//
// return density;
return
0.0
;
// TODO: uncomment above but wait until Bene fixed the OpenCL bug
if
(
state
.
getStep
()
>
this
.
lastStep
)
{
// obstacle will not change so we do it once.
if
(!
this
.
filteredObstacles
&&
this
.
isObstacleDensity
)
{
this
.
obstacleFilter
=
IGaussianFilter
.
create
(
state
.
getTopography
(),
this
.
scale
,
this
.
standDev
);
this
.
obstacleFilter
.
filterImage
();
this
.
filteredObstacles
=
true
;
}
this
.
pedestrianFilter
=
IGaussianFilter
.
create
(
state
.
getTopography
().
getBounds
(),
state
.
getTopography
().
getElements
(
Pedestrian
.
class
),
this
.
scale
,
this
.
standDev
,
state
.
getTopography
().
getAttributesPedestrian
(),
IPedestrianLoadingStrategy
.
create
());
this
.
pedestrianFilter
.
filterImage
();
this
.
lastStep
=
state
.
getStep
();
}
double
density
=
0.0
;
if
(
this
.
isObstacleDensity
)
density
=
this
.
obstacleFilter
.
getFilteredValue
(
pos
.
x
,
pos
.
y
);
density
+=
this
.
pedestrianFilter
.
getFilteredValue
(
pos
.
x
,
pos
.
y
);
return
density
;
}
}
VadereUtils/pom.xml
View file @
9587ac67
...
...
@@ -92,7 +92,7 @@
<repositories>
<repository>
<id>
nativelibs4java
</id>
<id>
nativelibs4java
-repo
</id>
<name>
nativelibs4java Maven2 Repository
</name>
<url>
http://nativelibs4java.sourceforge.net/maven
</url>
</repository>
...
...
@@ -101,13 +101,15 @@
<dependencies>
<dependency>
<groupId>
com.nativelibs4java
</groupId>
<artifactId>
libcl-bridj
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<artifactId>
bridj
</artifactId>
<version>
0.7.0
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
com.nativelibs4java
</groupId>
<artifactId>
javacl
</artifactId>
<version>
1.0.0-RC4
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
...
...
VadereUtils/src/org/vadere/util/math/CLConvolution.java
View file @
9587ac67
...
...
@@ -14,7 +14,8 @@ public class CLConvolution {
private
Convolve
gaussianFilter
;
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
);
}
...
...
VadereUtils/src/org/vadere/util/math/Convolution.java
View file @
9587ac67
...
...
@@ -129,7 +129,7 @@ public class Convolution {
for
(
int
yOut
=
0
;
yOut
<
nHeight
;
yOut
++)
{
for
(
int
xOut
=
0
;
xOut
<
nWidth
;
xOut
++)
{
final
int
idxOut
=
yOut
*
nWidth
+
xOut
;
outMatrix
[
idxOut
]
=
convolveCol
(
tmpOutMatrix
,
row
Vector
,
nWidth
,
nHeight
,
nFilterWidth
,
xOut
,
yOut
);
outMatrix
[
idxOut
]
=
convolveCol
(
tmpOutMatrix
,
col
Vector
,
nWidth
,
nHeight
,
nFilterWidth
,
xOut
,
yOut
);
}
}
return
outMatrix
;
...
...
VadereUtils/tests/org/vadere/util/opencl/TestJavaCL.java
0 → 100644
View file @
9587ac67
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"
);
}
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment