Created
May 8, 2012 11:58
-
-
Save chemikadze/2634455 to your computer and use it in GitHub Desktop.
Trying to make OpenCL behave like scala collection library
This file contains 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 openclscala; | |
import com.chemikadze.scalacl._ | |
import java.lang.Float | |
object addOne extends JavaCLFunction11Impl[Float, Float]( | |
"addOne", | |
""" | |
__kernel void addOne(__global const float* in, __global float* out, int n) | |
{ | |
int i = get_global_id(0); | |
if (i >= n) | |
return; | |
out[i] = in[i] + 1.0; | |
} | |
""" | |
) | |
object App extends App { | |
val scalaList = List(1.0, 2.0, 3.0, 4.0, 5.0) | |
val javaList: List[java.lang.Float] = scalaList.map(new Float(_)) | |
val result = javaList.cl.map(addOne).get | |
println(result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment