开发者

Programming CUDA using Delphi or FreePascal

Can I create CUDA/OpenCL applications using Delphi or FreePascal?

Or am I forced to use C++ and Visual Studio?

A quick search: cuda + pascal

Turns up some promising leads, but none of them seem to w开发者_运维技巧ork out, what options do I have if I want to fire up all those unused cores using Pascal?


Try it DELPHI CUDA In delphi you shoud use DRIVER API for run kernel , this implementation help you. There are examples in source code http://code.google.com/p/pascuda/


GLScene has CUDA + OpenCL header conversions in it's ComputeAPIs folder, but unfortunately there is no Pascal for CUDA/OpenCL, so the actual kernels will need to be written in C for OpenCL/CUDA.

It is possible to use clEnqueueNativeKernel to use purely all Delphi code, but native kernels will only work on the CPU, not on any existing GPU at the moment. In recent Delphi versions, it is possible to combine native kernels with anonymous methods, to produce a fairly nice solution.

eg. You could write a wrapper function that accepts an anonymous method as a parameter, and passes it to OpenCL as a native kernel, the wrapper function could operate something like this:

var
  input1, input2, output: array[0..1023] of integer;
begin
  Parallel.For(0, 1023,
         procedure(i: Integer)
         begin
           output[i] := SomeFunc(input1[i]) + AnotherFunc(input2[i]);
         end);


You will need to write the actual CUDA kernels in C / C++. There is no other way. Unless Pascal can be extended with C or can link against C/C++ libraries, (which I asusme it does from the link you mentioned), I do not think there is any other way.


An example/demo (including source) about how to use OpenCL in Delphi can be found here: https://plus.google.com/110131086673878874356/posts/eWcipK16MV7 However you need to write C/C++ for OpenCL itself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜