Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 work out, what options do I have if I want to fire up all those unused cores using Pascal?

like image 223
Johan Avatar asked May 06 '11 23:05

Johan


2 Answers

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/

like image 164
DELPHI CUDA Avatar answered Sep 17 '22 20:09

DELPHI CUDA


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);
like image 41
Dan Bartlett Avatar answered Sep 21 '22 20:09

Dan Bartlett