www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - How feasible to wrap Nvidia Toolkit for CUDA Programming

reply "TJB" <broughtj gmail.com> writes:
D Masters,

I'm not a hardware guy at all, but I find myself needing to 
process a lot of data through some Monte Carlo statistical 
algorithms.  I am considering general purpose GPU computing for 
this task.  My question is how feasible will it be to wrap the 
Nvidia cuBLAS and cuRAND libraries for this purpose?  They are 
written in C, so is it pretty straight forward?

I do not have in mind running D code directly on the GPU cores, 
but having D call out to C code to do so.  Is it possible?  
Feasible?  Are there already codes to do this somewhere?

Thanks for your insights!

TJB
Aug 16 2012
next sibling parent David <d dav1d.de> writes:
Am 17.08.2012 00:20, schrieb TJB:
 D Masters,

 I'm not a hardware guy at all, but I find myself needing to process a
 lot of data through some Monte Carlo statistical algorithms.  I am
 considering general purpose GPU computing for this task.  My question is
 how feasible will it be to wrap the Nvidia cuBLAS and cuRAND libraries
 for this purpose?  They are written in C, so is it pretty straight forward?

 I do not have in mind running D code directly on the GPU cores, but
 having D call out to C code to do so.  Is it possible? Feasible?  Are
 there already codes to do this somewhere?

 Thanks for your insights!

 TJB
There is a OpenCL Wrapper written in D: https://github.com/Trass3r/cl4d
Aug 16 2012
prev sibling parent reply Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> writes:
On Fri, 17 Aug 2012 00:20:10 +0200
"TJB" <broughtj gmail.com> wrote:

 D Masters,
 
 I'm not a hardware guy at all, but I find myself needing to 
 process a lot of data through some Monte Carlo statistical 
 algorithms.  I am considering general purpose GPU computing for 
 this task.  My question is how feasible will it be to wrap the 
 Nvidia cuBLAS and cuRAND libraries for this purpose?  They are 
 written in C, so is it pretty straight forward?
 
 I do not have in mind running D code directly on the GPU cores, 
 but having D call out to C code to do so.  Is it possible?  
 Feasible?  Are there already codes to do this somewhere?
 
 Thanks for your insights!
 
 TJB
Accessing/wrapping C libs in general is pretty straightforward in D: http://dlang.org/interfaceToC.html There's a few things to be aware of (especially on Windows), but this series of articles covers them very well: http://www.gamedev.net/blog/1140/entry-2254003-binding-d-to-c/
Aug 16 2012
next sibling parent Jens Mueller <jens.k.mueller gmx.de> writes:
Nick Sabalausky wrote:
 On Fri, 17 Aug 2012 00:20:10 +0200
 "TJB" <broughtj gmail.com> wrote:
 
 D Masters,
 
 I'm not a hardware guy at all, but I find myself needing to 
 process a lot of data through some Monte Carlo statistical 
 algorithms.  I am considering general purpose GPU computing for 
 this task.  My question is how feasible will it be to wrap the 
 Nvidia cuBLAS and cuRAND libraries for this purpose?  They are 
 written in C, so is it pretty straight forward?
 
 I do not have in mind running D code directly on the GPU cores, 
 but having D call out to C code to do so.  Is it possible?  
 Feasible?  Are there already codes to do this somewhere?
 
 Thanks for your insights!
 
 TJB
Accessing/wrapping C libs in general is pretty straightforward in D: http://dlang.org/interfaceToC.html There's a few things to be aware of (especially on Windows), but this series of articles covers them very well: http://www.gamedev.net/blog/1140/entry-2254003-binding-d-to-c/
And once you have converted the header files please consider creating a pull request for cuBLAS and cuRAND for Deimos (https://github.com/D-Programming-Deimos). Jens
Aug 17 2012
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-08-17 01:27, Nick Sabalausky wrote:

 Accessing/wrapping C libs in general is pretty straightforward in D:

 http://dlang.org/interfaceToC.html

 There's a few things to be aware of (especially on Windows), but this
 series of articles covers them very well:
 http://www.gamedev.net/blog/1140/entry-2254003-binding-d-to-c/
Or just use DStep to automatically generate the bindings: https://github.com/jacob-carlborg/dstep -- /Jacob Carlborg
Aug 17 2012