Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Aparapi
Aparapi Examples
Commits
a68be997
Commit
a68be997
authored
Oct 21, 2017
by
Jeffrey Phillips Freeman
💥
Browse files
feat: moved Correlation matrix to root of project.
parent
3652780c
Changes
13
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
a68be997
# Aparapi Examples Changelog
## 1.4.1
*
Updated parent pon to v6.
...
...
@@ -14,13 +15,13 @@
## 1.3.4
*
Updated to aparapi-jni 1.1.2 thus fixing
`UnsatisfiedLinkError`
which occured only on Windows.
*
Synced to Aparapi 1.3.4
*
Updated to aparapi-jni 1.1.2 thus fixing
`UnsatisfiedLinkError`
which occured only on Windows.
## 1.3.3
*
Fixed "
`
CXXABI_1.3.8' not found " error encountered on some older systems.
*
Synced to Aparapi 1.3.3
*
Fixed "
`
CXXABI_1.3.8' not found " error encountered on some older systems.
## 1.3.2
...
...
@@ -42,12 +43,15 @@
## 1.1.2
*
Synced to Aparapi 1.1.2
*
Fixed some bugs causing the OpenCL kernel to be compiled twice.
## 1.1.
0
## 1.1.
1
*
Synced to Aparapi 1.1.1
*
Changed package to com.aparapi
## 1.1.0
*
Synced to Aparapi 1.1.0
*
Changed group id and package to com.aparapi
\ No newline at end of file
examples/correlation-matrix/.gitignore
deleted
100644 → 0
View file @
3652780c
/.libs/
/classes/
/junit/
examples/correlation-matrix/.project
deleted
100644 → 0
View file @
3652780c
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
correlation-matrix
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
</natures>
</projectDescription>
examples/correlation-matrix/CC-4257_FINAL_060612.pdf
deleted
100644 → 0
View file @
3652780c
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
examples/correlation-matrix/build.xml
deleted
100644 → 0
View file @
3652780c
<?xml version="1.0"?>
<project
name=
"correlation-matrix"
default=
"junit"
basedir=
"."
>
<!--
USER CONFIGURABLE PROPERTIES
-->
<property
name=
"libs.root"
value=
"${basedir}/.libs"
/>
<property
name=
"commons.lang.jar"
value=
"commons-lang3-3.1.jar"
/>
<property
name=
"log4j.jar"
value=
"log4j-1.2.17.jar"
/>
<property
name=
"lucene.jar"
value=
"lucene-core-3.5.0.jar"
/>
<property
name=
"junit.jar"
value=
"junit-4.10.jar"
/>
<property
name=
"commons.lang.url"
value=
"http://repo1.maven.org/maven2/org/apache/commons/commons-lang3/3.1/${commons.lang.jar}"
/>
<property
name=
"log4j.url"
value=
"http://repo1.maven.org/maven2/log4j/log4j/1.2.17/${log4j.jar}"
/>
<property
name=
"lucene.url"
value=
"http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/3.5.0/${lucene.jar}"
/>
<property
name=
"junit.url"
value=
"http://repo1.maven.org/maven2/junit/junit/4.10/${junit.jar}"
/>
<!--
SYSTEM PROPERTIES
-->
<echo>
OS Name: ${os.name}
</echo>
<echo>
OS Version: ${os.version}
</echo>
<echo>
OS Arch: ${os.arch}
</echo>
<echo>
Java Version: ${java.version}
</echo>
<!-- Ideally this would be the latest version of Java but not everyone is going to have it installed -->
<!-- Additionally we want to avoid "Class not found: javac1.8" errors from old Ant versions (i.e. Eclipse) -->
<property
name=
"build.compiler"
value=
"javac1.7"
/>
<property
name=
"ant.build.javac.source"
value=
"1.7"
/>
<property
name=
"ant.build.javac.target"
value=
"1.7"
/>
<path
id=
"classpath"
>
<pathelement
path=
"${basedir}/../../com.aparapi/dist/aparapi.jar"
/>
<pathelement
path=
"${libs.root}/${commons.lang.jar}"
/>
<pathelement
path=
"${libs.root}/${log4j.jar}"
/>
<pathelement
path=
"${libs.root}/${lucene.jar}"
/>
<pathelement
path=
"${libs.root}/${junit.jar}"
/>
<pathelement
path=
"classes"
/>
</path>
<target
name=
"install.deps"
>
<mkdir
dir=
"${libs.root}"
/>
<!-- Cleanup all existing deps -->
<delete
failonerror=
"false"
includeEmptyDirs=
"true"
>
<fileset
dir=
"${libs.root}"
includes=
"*/"
/>
</delete>
<!-- Download and unzip requested deps -->
<get
src=
"${commons.lang.url}"
dest=
"${libs.root}/${commons.lang.jar}"
/>
<get
src=
"${log4j.url}"
dest=
"${libs.root}/${log4j.jar}"
/>
<get
src=
"${lucene.url}"
dest=
"${libs.root}/${lucene.jar}"
/>
<get
src=
"${junit.url}"
dest=
"${libs.root}/${junit.jar}"
/>
</target>
<target
name=
"clean"
>
<delete
dir=
"classes"
/>
<delete
dir=
"junit"
/>
<delete
file=
"correlation-matrix.jar"
/>
</target>
<target
name=
"junit"
depends=
"clean"
>
<mkdir
dir=
"classes"
/>
<mkdir
dir=
"junit/data"
/>
<!-- Runtime Code -->
<javac
debug=
"true"
debuglevel=
"lines,vars,source"
srcdir=
"src/java"
destdir=
"classes"
includeAntRuntime=
"false"
classpathref=
"classpath"
>
<compilerarg
value=
"-Xlint"
/>
<compilerarg
value=
"-Xlint:-path"
/>
</javac>
<!-- JUnit Tests -->
<javac
debug=
"true"
debuglevel=
"lines,vars,source"
srcdir=
"src/test"
destdir=
"classes"
includeAntRuntime=
"false"
classpathref=
"classpath"
>
<compilerarg
value=
"-Xlint"
/>
<compilerarg
value=
"-Xlint:-path"
/>
</javac>
<copy
todir=
"classes"
file=
"src/java/log4j.xml"
/>
<!-- Even though fork is slower we need to set the library path and this requires fork -->
<junit
printsummary=
"false"
fork=
"true"
haltonfailure=
"false"
failureproperty=
"tests.failed"
showoutput=
"true"
>
<sysproperty
key=
"java.library.path"
value=
"${basedir}/../../com.aparapi.jni/dist"
/>
<!-- USER DEFINED PROPERTIES -->
<sysproperty
key=
"numRows"
value=
"1024"
/>
<sysproperty
key=
"numColumns"
value=
"16384"
/>
<sysproperty
key=
"useGPU"
value=
"true"
/>
<formatter
type=
"xml"
/>
<classpath
refid=
"classpath"
/>
<batchtest
todir=
"junit/data"
>
<fileset
dir=
"src/test"
/>
</batchtest>
</junit>
<junitreport
todir=
"junit/data"
>
<fileset
dir=
"junit/data"
/>
</junitreport>
</target>
</project>
\ No newline at end of file
examples/correlation-matrix/src/java/log4j.xml
deleted
100644 → 0
View file @
3652780c
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!--
| For more configuration information and examples see the Jakarta Log4j
| website: http://jakarta.apache.org/log4j
-->
<log4j:configuration
xmlns:log4j=
"http://jakarta.apache.org/log4j/"
debug=
"false"
>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender
name=
"CONSOLE"
class=
"org.apache.log4j.ConsoleAppender"
>
<param
name=
"Threshold"
value=
"DEBUG"
/>
<param
name=
"Target"
value=
"System.out"
/>
<param
name=
"Encoding"
value=
"UTF-8"
/>
<layout
class=
"org.apache.log4j.PatternLayout"
>
<!-- The default pattern: Date Priority [Category] (Thread) Message\n -->
<param
name=
"ConversionPattern"
value=
"%d %-5p [%c{1}] %m%n"
/>
<!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
-->
</layout>
</appender>
<appender
name=
"FILE"
class=
"org.apache.log4j.FileAppender"
>
<param
name=
"File"
value=
"log/corrmatrix.log"
/>
<param
name=
"Append"
value=
"true"
/>
<param
name=
"Encoding"
value=
"UTF-8"
/>
<layout
class=
"org.apache.log4j.PatternLayout"
>
<!-- The default pattern: Date Priority [Category] (Thread) Message\n -->
<param
name=
"ConversionPattern"
value=
"%d %-5p [%c] %m%n"
/>
<!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
-->
</layout>
</appender>
<!-- Limit categories -->
<logger
name=
"gov.pnnl"
>
<level
value=
"DEBUG"
/>
</logger>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
<appender-ref
ref=
"CONSOLE"
/>
<!-- <appender-ref ref="FILE"/> -->
</root>
</log4j:configuration>
\ No newline at end of file
pom.xml
View file @
a68be997
...
...
@@ -81,7 +81,7 @@
<dependency>
<groupId>
com.aparapi
</groupId>
<artifactId>
aparapi
</artifactId>
<version>
1.4.
2-SNAPSHOT
</version>
<version>
1.4.
1
</version>
</dependency>
<dependency>
<groupId>
org.jogamp.gluegen
</groupId>
...
...
@@ -98,6 +98,25 @@
<artifactId>
gluegen
</artifactId>
<version>
2.3.2
</version>
</dependency>
<dependency>
<groupId>
org.apache.lucene
</groupId>
<artifactId>
lucene-core
</artifactId>
<version>
3.6.2
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
3.6
</version>
</dependency>
<dependency>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
<version>
1.2.17
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/aparapi/examples/All.java
View file @
a68be997
...
...
@@ -82,6 +82,7 @@ public class All {
System
.
out
.
println
(
" 33) NBody - Sequential"
);
System
.
out
.
println
(
" 34) OOPN Body"
);
System
.
out
.
println
(
" 35) Map-reduce"
);
System
.
out
.
println
(
" 36) Correlation Matrix"
);
System
.
out
.
println
();
Scanner
in
=
new
Scanner
(
System
.
in
);
...
...
@@ -217,6 +218,9 @@ public class All {
case
"35"
:
com
.
aparapi
.
examples
.
mapreduce
.
Main
.
main
(
args
);
break
;
case
"36"
:
com
.
aparapi
.
examples
.
matrix
.
Main
.
main
(
args
);
break
;
default
:
System
.
out
.
println
(
"Invalid selection."
);
}
...
...
examples/correlation-matrix/src/java/gov/pnnl/aparapi
/matrix/CorrMatrixHost.java
→
src/main/java/com/aparapi/examples
/matrix/CorrMatrixHost.java
View file @
a68be997
/**
* Copyright (c) 2016 - 2017 Syncleus, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This material was prepared as an account of work sponsored by an agency of the United States Government.
* Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any of
...
...
@@ -6,7 +21,7 @@
* completeness, or usefulness or any information, apparatus, product, software, or process disclosed, or represents
* that its use would not infringe privately owned rights.
*/
package
gov.pnnl.aparapi
.matrix
;
package
com.aparapi.examples
.matrix
;
import
org.apache.log4j.Logger
;
...
...
@@ -40,7 +55,7 @@ public class CorrMatrixHost {
* @return result Matrix
* @throws Exception
*/
public
static
int
[][]
intersectionMatrix
(
final
long
[][]
matrixA
,
final
long
[][]
matrixB
,
final
EXECUTION_MODE
executionMode
)
throws
Exception
{
public
static
int
[][]
intersectionMatrix
(
final
long
[][]
matrixA
,
final
long
[][]
matrixB
,
final
EXECUTION_MODE
executionMode
)
{
// Basic validation
if
(
matrixA
==
null
)
{
...
...
@@ -225,7 +240,7 @@ public class CorrMatrixHost {
for
(
int
i
=
aSubRowStart
;
i
<
aSubRowEnd
;
i
++)
{
if
(
matrixA_numLongs
!=
matrixA
[
i
].
length
)
{
throw
new
Exception
(
"All rows in the matrix need be the same length"
);
throw
new
IllegalState
Exception
(
"All rows in the matrix need be the same length"
);
}
System
.
arraycopy
(
matrixA
[
i
],
0
,
subMatrixA
,
(
i
-
aSubRowStart
)
*
matrixA_numLongs
,
matrixA_numLongs
);
...
...
@@ -236,7 +251,7 @@ public class CorrMatrixHost {
for
(
int
i
=
bSubRowStart
;
i
<
bSubRowEnd
;
i
++)
{
if
(
matrixA_numLongs
!=
matrixB
[
i
].
length
)
{
throw
new
Exception
(
"All rows in the matrix need be the same length"
);
throw
new
IllegalState
Exception
(
"All rows in the matrix need be the same length"
);
}
System
.
arraycopy
(
matrixB
[
i
],
0
,
subMatrixB
,
(
i
-
bSubRowStart
)
*
matrixB_numLongs
,
matrixB_numLongs
);
...
...
examples/correlation-matrix/src/java/gov/pnnl/aparapi
/matrix/CorrMatrixKernel.java
→
src/main/java/com/aparapi/examples
/matrix/CorrMatrixKernel.java
View file @
a68be997
/**
* Copyright (c) 2016 - 2017 Syncleus, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This material was prepared as an account of work sponsored by an agency of the United States Government.
* Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any of
...
...
@@ -6,7 +21,7 @@
* completeness, or usefulness or any information, apparatus, product, software, or process disclosed, or represents
* that its use would not infringe privately owned rights.
*/
package
gov.pnnl.aparapi
.matrix
;
package
com.aparapi.examples
.matrix
;
import
com.aparapi.Kernel
;
...
...
src/main/java/com/aparapi/examples/matrix/Main.java
0 → 100644
View file @
a68be997
/**
* Copyright (c) 2016 - 2017 Syncleus, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This material was prepared as an account of work sponsored by an agency of the United States Government.
* Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any of
* their employees, nor any jurisdiction or organization that has cooperated in the development of these materials,
* makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy,
* completeness, or usefulness or any information, apparatus, product, software, or process disclosed, or represents
* that its use would not infringe privately owned rights.
*/
package
com.aparapi.examples.matrix
;
import
com.aparapi.Kernel.EXECUTION_MODE
;
import
org.apache.commons.lang3.tuple.ImmutablePair
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.apache.lucene.util.OpenBitSet
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Random
;
/**
* This test class performs the following functions:
*
* 1) Create a randomly populated set of matrices for correlation/co-occurrence computation
* 2) Execute the CPU-based computation using Lucene OpenBitSets
* 3) Execute the GPU-based computation using Aparapi CorrMatrix host and kernel
* 4) Verify the results of OpenBitSet and CorrMatrix by comparing matrices to each other
*
* @author ryan.lamothe at gmail.com
*
*/
public
class
Main
{
/**
* NumTerms and NumLongs (documents) need to be adjusted manually right now to force 'striping' to occur (see Host code for details)
*/
public
static
void
main
(
String
[]
_args
)
{
final
List
<
Pair
<
OpenBitSet
,
OpenBitSet
>>
obsPairs
=
new
ArrayList
<
Pair
<
OpenBitSet
,
OpenBitSet
>>();
;
final
Random
rand
=
new
Random
();
int
[][]
obsResultMatrix
;
/*
* Populate test data
*/
System
.
out
.
println
(
"----------"
);
System
.
out
.
println
(
"Populating test matrix data using settings from build.xml..."
);
System
.
out
.
println
(
"----------"
);
final
int
numTerms
=
Integer
.
getInteger
(
"numRows"
,
300
);
// # Rows
// numLongs*64 for number of actual documents since these are 'packed' longs
final
int
numLongs
=
Integer
.
getInteger
(
"numColumns"
,
10000
);
// # Columns
for
(
int
i
=
0
;
i
<
numTerms
;
++
i
)
{
final
long
[]
bits
=
new
long
[
numLongs
];
for
(
int
j
=
0
;
j
<
numLongs
;
++
j
)
{
bits
[
j
]
=
rand
.
nextLong
();
}
obsPairs
.
add
(
i
,
new
ImmutablePair
<
OpenBitSet
,
OpenBitSet
>(
new
OpenBitSet
(
bits
,
numLongs
),
new
OpenBitSet
(
bits
,
numLongs
)));
}
/*
* OpenBitSet calculations
*/
System
.
out
.
println
(
"Executing OpenBitSet intersectionCount"
);
final
long
startTime
=
System
.
currentTimeMillis
();
obsResultMatrix
=
new
int
[
obsPairs
.
size
()][
obsPairs
.
size
()];
// This is an N^2 comparison loop
// FIXME This entire loop needs to be parallelized to show an apples-to-apples comparison to Aparapi
for
(
int
i
=
0
;
i
<
obsPairs
.
size
();
i
++)
{
final
Pair
<
OpenBitSet
,
OpenBitSet
>
docFreqVector1
=
obsPairs
.
get
(
i
);
for
(
int
j
=
0
;
j
<
obsPairs
.
size
();
j
++)
{
final
Pair
<
OpenBitSet
,
OpenBitSet
>
docFreqVector2
=
obsPairs
.
get
(
j
);
// # of matches in both sets of documents
final
int
result
=
(
int
)
OpenBitSet
.
intersectionCount
(
docFreqVector1
.
getLeft
(),
docFreqVector2
.
getRight
());
obsResultMatrix
[
i
][
j
]
=
result
;
}
}
final
long
endTime
=
System
.
currentTimeMillis
()
-
startTime
;
System
.
out
.
println
(
"OpenBitSet Gross Execution Time: "
+
endTime
+
" ms <------OpenBitSet"
);
System
.
out
.
println
(
"----------"
);
/*
* GPU calculations
*/
System
.
out
.
println
(
"Executing Aparapi intersectionCount"
);
final
long
[][]
matrixA
=
new
long
[
obsPairs
.
size
()][];
final
long
[][]
matrixB
=
new
long
[
obsPairs
.
size
()][];
// Convert OpenBitSet pairs to long primitive arrays for use with Aparapi
// TODO It would be nice if we could find a way to put the obsPairs onto the GPU directly :)
for
(
int
i
=
0
;
i
<
obsPairs
.
size
();
i
++)
{
final
OpenBitSet
obsA
=
obsPairs
.
get
(
i
).
getLeft
();
final
OpenBitSet
obsB
=
obsPairs
.
get
(
i
).
getRight
();
matrixA
[
i
]
=
obsA
.
getBits
();
matrixB
[
i
]
=
obsB
.
getBits
();
}
// The reason for setting this property is because the CorrMatrix host/kernel code
// came from a GUI where a user could select "Use Hardware Acceleration" instead
// of the application forcing the setting globally on the command-line
final
int
[][]
gpuResultMatrix
;
gpuResultMatrix
=
CorrMatrixHost
.
intersectionMatrix
(
matrixA
,
matrixB
,
EXECUTION_MODE
.
GPU
);
// Compare the two result arrays to make sure we are generating the same output
System
.
out
.
println
(
"[i][j] -> OpenBitSet Result : GPU Result Array"
);
for
(
int
i
=
0
;
i
<
obsResultMatrix
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
obsResultMatrix
[
i
].
length
;
j
++)
if
(
obsResultMatrix
[
i
][
j
]
!=
gpuResultMatrix
[
i
][
j
])
{
System
.
out
.
println
(
"["
+
i
+
"]["
+
j
+
"] -> "
+
obsResultMatrix
[
i
][
j
]
+
" : "
+
gpuResultMatrix
[
i
][
j
]);
}
}
System
.
out
.
println
(
"Any elements not listed matched!"
);
}
}
src/main/resources/log4j.properties
0 → 100644
View file @
a68be997
# Root logger option
log4j.rootLogger
=
DEBUG, stdout
# Direct log messages to stdout
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern
=
%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
\ No newline at end of file
examples/correlation-matrix/
src/test/
gov/pnnl
/aparapi/
test
/CorrMatrixTest.java
→
src/test/
java/com
/aparapi/
examples/matrix
/CorrMatrixTest.java
View file @
a68be997
/**
* Copyright (c) 2016 - 2017 Syncleus, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This material was prepared as an account of work sponsored by an agency of the United States Government.
* Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any of
...
...
@@ -6,9 +21,7 @@
* completeness, or usefulness or any information, apparatus, product, software, or process disclosed, or represents
* that its use would not infringe privately owned rights.
*/
package
gov.pnnl.aparapi.test
;
import
gov.pnnl.aparapi.matrix.CorrMatrixHost
;
package
com.aparapi.examples.matrix
;
import
java.io.File
;
import
java.io.PrintWriter
;
...
...
@@ -29,12 +42,12 @@ import com.aparapi.Kernel.EXECUTION_MODE;
/**
* This test class performs the following functions:
*
*
* 1) Create a randomly populated set of matrices for correlation/co-occurrence computation
* 2) Execute the CPU-based computation using Lucene OpenBitSets
* 3) Execute the GPU-based computation using Aparapi CorrMatrix host and kernel
* 4) Verify the results of OpenBitSet and CorrMatrix by comparing matrices to each other
*
*
* @author ryan.lamothe at gmail.com
*
*/
...
...
@@ -126,11 +139,7 @@ public class CorrMatrixTest {
// came from a GUI where a user could select "Use Hardware Acceleration" instead
// of the application forcing the setting globally on the command-line
final
int
[][]
gpuResultMatrix
;
if
(
Boolean
.
getBoolean
(
"useGPU"
))
{
gpuResultMatrix
=
CorrMatrixHost
.
intersectionMatrix
(
matrixA
,
matrixB
,
EXECUTION_MODE
.
GPU
);
}
else
{
gpuResultMatrix
=
CorrMatrixHost
.
intersectionMatrix
(
matrixA
,
matrixB
,
EXECUTION_MODE
.
CPU
);
}
gpuResultMatrix
=
CorrMatrixHost
.
intersectionMatrix
(
matrixA
,
matrixB
,
EXECUTION_MODE
.
GPU
);
// Compare the two result arrays to make sure we are generating the same output
for
(
int
i
=
0
;
i
<
obsResultMatrix
.
length
;
i
++)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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