Helpful resources for GPU programming in X10 include our web page, and the X10'11 Workshop paper, which is available on the page. Also useful are the sample programs, under x10.dist/samples/CUDA http://x10-lang.org/documentation/practical-x10-programming/x10-on-gpus.html http://x10.sourceforge.net/documentation/papers/X10Workshop2011/cuda.pdf
It's fine to access method arguments within a kernel (see CUDABlackScholes .x10). The arguments will be copied from the host to the GPU as a part of kernel invocation, as they would with any 'at' in X10. But as with any 'at', you should be aware that what appears at the remote location (or in the GPU) is a copy of the original data, not a reference to the original object. For efficiency, you want the data copied to the remote place to be small (only bring what you need), and it has to be something that can be serialized and recreated at a remote location (no dangling pointers, no references to locks/sockets, no references to 'here', etc). Structs are fine. Beyond that, you have the limitations of the CUDA hardware itself. You can't have recursion, there are limits on what sorts of function calls can be made, etc. x10.matrix.Vector is too complex internally to bring into a CUDA kernel. Instead, I suggest you directly allocate the buffers you need on the device via CUDAUtilities.makeGlobalRail(), and copy the data you need out of A.d to the device with Rail.asyncCopy(). Then within the kernel you perform your calculations, and after the kernel, bring results back from the device to your local destination with Rail.asyncCopy() again. An additional tip - if you have many kernels, try to avoid moving data back and forth between the device and host in between kernel executions. It's better to leave data in the device and reuse it, than to copy it back and forth. CUDAUtilities.makeGlobalRail()/deleteGlobalRail() helps you follow this pattern. - Ben From: Luca Salucci <lucasalu...@libero.it> To: x10-users@lists.sourceforge.net, Date: 02/12/2014 06:50 AM Subject: [X10-users] @CUDA kernel scope I would like to ask if it is possible to clarify a point. What is possible to refer to in a @CUDA kernel in X10? "As in normal X10 programs, the code in '...' can access variables from the enclosing scope, i.e. the host. Such captured variables will be automatically copied to the GPU" I am having a bunch of problems, and error messages do not help in clarifying them. Is it possible to refer variables in the current scope or only variables in the block (and not all the names in the scope)? For example if I try to refer to a formal parameter of a function (input parameter) within @CUDA kernel which is inside the function itself and I get a compile error. Something like this: public static def cellwise_bi (A: Vector, B: Vector(A.M), C: Vector(A.M), op:(Double, Double) => Double ):cuVector(C) { val g = gpu; val threads:Int = 64N; val blocks:Int = 32N; ... finish async at (g) @CUDA @CUDADirectParams{ finish for (block in 0n..(blocks-1n)) async { clocked finish for (thread in 0n..(threads-1n)) clocked async { val idx = block * blocks + thread; ... ----> val num = A(idx) ... } } } } Is it coherent with the semantic and I am doing wrong OR is it a bug? Moreover can I refer only to primitive types within a @CUDA kernel or can I refer also struct and objects? If you clarify these points it would be of great help! Thanks a lot, Luca Salucci ------------------------------------------------------------------------------ Android apps run on BlackBerry 10 Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now. http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users
<<inline: graycol.gif>>
------------------------------------------------------------------------------ Android apps run on BlackBerry 10 Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now. http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users