Commit 3a60d804 authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman 💥
Browse files

Moved convolution sample to active project.

parent 85ce2dbf
......@@ -95,6 +95,7 @@
<mainClass>com.syncleus.aparapi.examples.All</mainClass>
<arguments>
<argument>com.syncleus.aparapi.executionMode=GPU</argument>
<argument>com.syncleus.aparapi.enableShowGeneratedOpenCL=true</argument>
</arguments>
</configuration>
</plugin>
......
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>convolution</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>
<?xml version="1.0"?>
<project name="convolution" default="build" basedir=".">
<!-- 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="compiler.class.path">
<pathelement path="../../com.syncleus.aparapi/dist/aparapi.jar" />
</path>
<path id="runtime.class.path" cache="true">
<path refid="compiler.class.path" />
<pathelement path="${ant.project.name}.jar" />
</path>
<target name="build" depends="clean">
<mkdir dir="classes" />
<javac srcdir="src" destdir="classes" debug="on" includeantruntime="false">
<classpath>
<pathelement path="../../com.syncleus.aparapi/dist/aparapi.jar" />
</classpath>
</javac>
<copy file="src\com\amd\aparapi\sample\convolution\convolution.cl" toDir="classes\com\amd\aparapi\sample\convolution" />
<jar jarfile="${ant.project.name}.jar" basedir="classes" />
</target>
<target name="clean">
<delete dir="classes" />
<delete file="${ant.project.name}.jar" />
</target>
<target name="run-jtp">
<java classname="com.syncleus.aparapi.sample.convolution.Convolution" fork="true">
<classpath refid="runtime.class.path" />
<sysproperty key="java.library.path" path="..\..\com.syncleus.aparapi.jni\dist" />
<sysproperty key="com.syncleus.aparapi.executionMode" value="JTP" />
</java>
</target>
<target name="run-gpu">
<java classname="com.syncleus.aparapi.sample.convolution.Convolution" fork="true">
<classpath refid="runtime.class.path" />
<sysproperty key="java.library.path" path="..\..\com.syncleus.aparapi.jni\dist" />
<sysproperty key="com.syncleus.aparapi.executionMode" value="GPU" />
</java>
</target>
<target name="run" depends="run-gpu" />
</project>
java ^
-Djava.library.path=../../com.syncleus.aparapi.jni/dist ^
-Dcom.syncleus.aparapi.executionMode=%1 ^
-Dcom.syncleus.aparapi.enableShowGeneratedOpenCL=true ^
-classpath ../../com.syncleus.aparapi/dist/aparapi.jar;convolution.jar ^
com.syncleus.aparapi.sample.convolution.Convolution %2
java \
-Djava.library.path=../../com.syncleus.aparapi.jni/dist\
-Dcom.syncleus.aparapi.executionMode=$1\
-Dcom.syncleus.aparapi.enableShowGeneratedOpenCL=true\
-classpath ../../com.syncleus.aparapi/dist/aparapi.jar:convolution.jar\
com.syncleus.aparapi.sample.convolution.Convolution $2
java ^
-Djava.library.path=../../com.syncleus.aparapi.jni/dist ^
-Dcom.syncleus.aparapi.executionMode=%1 ^
-classpath ../../com.syncleus.aparapi/dist/aparapi.jar;convolution.jar ^
com.syncleus.aparapi.sample.convolution.ConvolutionOpenCL %2
java ^
-Djava.library.path=../../com.syncleus.aparapi.jni/dist ^
-Dcom.syncleus.aparapi.executionMode=%1 ^
-classpath ../../com.syncleus.aparapi/dist/aparapi.jar;convolution.jar ^
com.syncleus.aparapi.sample.convolution.PureJava %2
......@@ -13,11 +13,14 @@ package com.syncleus.aparapi.examples;
import java.util.Scanner;
public class All {
public static void main(String[] _args) {
public static void main(String[] _args) throws Exception {
System.out.println("Select which example to run:");
System.out.println(" 1) Game of Life");
System.out.println(" 2) Mandelbrot");
System.out.println(" 3) Mandlebrot 2D");
System.out.println(" 4) Convolution");
System.out.println(" 5) Convolution (OpenCL)");
System.out.println(" 6) Convolution (pure Java)");
System.out.println();
Scanner in = new Scanner(System.in);
......@@ -28,7 +31,7 @@ public class All {
if( in.hasNextLine() )
{
String line = in.nextLine();
running = selected(line);
running = selected(line, _args);
System.out.println();
}
else
......@@ -41,7 +44,7 @@ public class All {
}
}
private static boolean selected(String line)
private static boolean selected(String line, String[] args) throws Exception
{
if( line.toUpperCase().equals("Q") )
return false;
......@@ -49,13 +52,22 @@ public class All {
switch(line)
{
case "1":
com.syncleus.aparapi.examples.life.Main.main(null);
com.syncleus.aparapi.examples.life.Main.main(args);
break;
case "2":
com.syncleus.aparapi.examples.mandel.Main.main(null);
com.syncleus.aparapi.examples.mandel.Main.main(args);
break;
case "3":
com.syncleus.aparapi.examples.mandel.Main2D.main(null);
com.syncleus.aparapi.examples.mandel.Main2D.main(args);
break;
case "4":
com.syncleus.aparapi.examples.convolution.Convolution.main(args);
break;
case "5":
com.syncleus.aparapi.examples.convolution.ConvolutionOpenCL.main(args);
break;
case "6":
com.syncleus.aparapi.examples.convolution.PureJava.main(args);
break;
default:
System.out.println("Invalid selection.");
......
/**
* This product currently only contains code developed by authors
* of specific components, as identified by the source code files.
*
* Since product implements StAX API, it has dependencies to StAX API
* classes.
*
* For additional credits (generally to people who reported problems)
* see CREDITS file.
*/
/*
Copyright (c) 2010-2011, Advanced Micro Devices, Inc.
All rights reserved.
......@@ -36,7 +46,7 @@ under those regulations, please refer to the U.S. Bureau of Industry and Securit
*/
package com.syncleus.aparapi.sample.convolution;
package com.syncleus.aparapi.examples.convolution;
import java.awt.BorderLayout;
import java.awt.Component;
......
/**
* This product currently only contains code developed by authors
* of specific components, as identified by the source code files.
*
* Since product implements StAX API, it has dependencies to StAX API
* classes.
*
* For additional credits (generally to people who reported problems)
* see CREDITS file.
*/
/*
Copyright (c) 2010-2011, Advanced Micro Devices, Inc.
All rights reserved.
......@@ -36,7 +46,7 @@ under those regulations, please refer to the U.S. Bureau of Industry and Securit
*/
package com.syncleus.aparapi.sample.convolution;
package com.syncleus.aparapi.examples.convolution;
import com.syncleus.aparapi.*;
......@@ -46,7 +56,7 @@ public class Convolution {
public static void main(final String[] _args) throws IOException {
final File file = new File(_args.length == 1 ? _args[0] : "./samples/convolution/testcard.jpg").getCanonicalFile();
final File file = new File(_args.length == 1 ? _args[0] : "./src/main/resources/testcard.jpg").getCanonicalFile();
final ImageConvolution convolution = new ImageConvolution();
......
/**
* This product currently only contains code developed by authors
* of specific components, as identified by the source code files.
*
* Since product implements StAX API, it has dependencies to StAX API
* classes.
*
* For additional credits (generally to people who reported problems)
* see CREDITS file.
*/
/*
Copyright (c) 2010-2011, Advanced Micro Devices, Inc.
All rights reserved.
......@@ -36,7 +46,7 @@ under those regulations, please refer to the U.S. Bureau of Industry and Securit
*/
package com.syncleus.aparapi.sample.convolution;
package com.syncleus.aparapi.examples.convolution;
import com.syncleus.aparapi.*;
import com.syncleus.aparapi.device.*;
......@@ -48,7 +58,7 @@ import java.io.*;
public class ConvolutionOpenCL{
@Resource("com/amd/aparapi/sample/convolution/convolution.cl") interface Convolution extends OpenCL<Convolution>{
@Resource("com/syncleus/aparapi/examples/convolution/convolution.cl") interface Convolution extends OpenCL<Convolution>{
Convolution applyConvolution(//
Range range, //
@GlobalReadOnly("_convMatrix3x3") float[] _convMatrix3x3,//// only read from kernel
......@@ -59,7 +69,7 @@ public class ConvolutionOpenCL{
}
public static void main(final String[] _args) {
final File file = new File(_args.length == 1 ? _args[0] : "testcard.jpg");
final File file = new File(_args.length == 1 ? _args[0] : "./src/main/resources/testcard.jpg");
final OpenCLDevice openclDevice = (OpenCLDevice) KernelManager.instance().bestDevice();
......
/**
* This product currently only contains code developed by authors
* of specific components, as identified by the source code files.
*
* Since product implements StAX API, it has dependencies to StAX API
* classes.
*
* For additional credits (generally to people who reported problems)
* see CREDITS file.
*/
/*
Copyright (c) 2010-2011, Advanced Micro Devices, Inc.
All rights reserved.
......@@ -36,7 +46,7 @@ under those regulations, please refer to the U.S. Bureau of Industry and Securit
*/
package com.syncleus.aparapi.sample.convolution;
package com.syncleus.aparapi.examples.convolution;
import java.awt.BorderLayout;
import java.awt.Color;
......
/**
* This product currently only contains code developed by authors
* of specific components, as identified by the source code files.
*
* Since product implements StAX API, it has dependencies to StAX API
* classes.
*
* For additional credits (generally to people who reported problems)
* see CREDITS file.
*/
/*
Copyright (c) 2010-2011, Advanced Micro Devices, Inc.
All rights reserved.
......@@ -36,7 +46,7 @@ under those regulations, please refer to the U.S. Bureau of Industry and Securit
*/
package com.syncleus.aparapi.sample.convolution;
package com.syncleus.aparapi.examples.convolution;
import java.io.File;
......@@ -89,7 +99,7 @@ public class PureJava{
}
public static void main(final String[] _args) {
File file = new File(_args.length == 1 ? _args[0] : "testcard.jpg");
File file = new File(_args.length == 1 ? _args[0] : "./src/main/resources/testcard.jpg");
final ImageConvolution convolution = new ImageConvolution();
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Supports Markdown
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