This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.nativelibs4java</groupId> | |
<artifactId>javacl-tutorial</artifactId> | |
<name>JavaCL Tutorial</name> | |
<url>http://code.google.com/p/javacl/</url> | |
<version>1.0-beta-6</version> | |
<packaging>jar</packaging> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Enable double-precision floating point numbers support. | |
// Not all platforms / devices support this, so you may have to switch to floats. | |
#pragma OPENCL EXTENSION cl_khr_fp64 : enable | |
__kernel void dft( | |
__global const double2 *in, // complex values input | |
__global double2 *out, // complex values output | |
int length, // number of input and output values | |
int sign) // sign modifier in the exponential : | |
// 1 for forward transform, -1 for backward. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void dft( | |
const double *in, // complex values input (packed real and imaginary) | |
double *out, // complex values output | |
int length, // number of input and output values | |
int sign) // sign modifier in the exponential : | |
// 1 for forward transform, -1 for backward. | |
{ | |
for (int i = 0; i < length; i++) | |
{ | |
// Initialize sum and inner arguments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tutorial; | |
import com.nativelibs4java.opencl.*; | |
import com.nativelibs4java.opencl.CLPlatform.DeviceFeature; | |
import com.nativelibs4java.util.*; | |
import java.io.IOException; | |
import java.nio.DoubleBuffer; | |
public class DFT { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tutorial; | |
import com.nativelibs4java.opencl.*; | |
import java.io.IOException; | |
import java.nio.DoubleBuffer; | |
public class DFT2 { | |
final CLQueue queue; | |
final CLContext context; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tutorial; | |
import com.nativelibs4java.opencl.*; | |
import java.io.IOException; | |
/// Auto-generated wrapper around the OpenCL program DiscreteFourierTransformProgram.cl | |
public class DiscreteFourierTransformProgram extends CLAbstractUserProgram { | |
public DiscreteFourierTransformProgram(CLContext context) throws IOException { | |
super(context, readRawSourceForClass(DiscreteFourierTransformProgram.class)); | |
} | |
public DiscreteFourierTransformProgram(CLProgram program) throws IOException { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def propagateZero(a: Int, b: Int) = | |
when(a * b) { | |
case List(IntConstant(0), _) | List(_, IntConstant(0)) => | |
replaceBy(0) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
val bean = new MyBean | |
bean.setFoo(10) | |
bean.setBar(12) | |
bean | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beans.create[MyBean]( | |
foo = 10, | |
bar = 12 | |
) | |
/* | |
UPDATE: the latest code in github (see link below) implements | |
the following, more flexible and friendly syntax: | |
new MyBean().set( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package scalaxy | |
import scala.language.dynamics | |
import scala.reflect.NameTransformer | |
import scala.reflect.macros.Context | |
/** | |
Syntactic sugar to instantiate Java beans with a very Scala-friendly syntax. | |
(full sources and tests: https://github.com/ochafik/Scalaxy/tree/master/Beans) |
OlderNewer