Cuda for Pascal(Delphi) ?

The ISA is not available to the public. Driver API is an alternative to the runtime API for device control, not some assembly-level construct.

So there’s no chance to remake an open-source pascal compiler and turn into GPU programming language? :D

Very sad, we’ll have to track every step of CUDA :(

Shortly about we thought about: an independent IDE, where users can write some functions that would be implemented on the GPU, the output would be a DLL and its header (PAS or H, depending on options) it that a bad idea? External Image

One more question, please: I can use asm-like low-level code in shaders, does CUDA code run any other way?

You can write your own PTX and compile that with ptxas, if you really want to. (See the PTX manual in the CUDA documentation.)

So still there’s a chance? :)

Could you point to that topic? Or I have to all the documentation that can be found about CUDA? :D

I should point out that PTX is a “GPU virtual machine” assembly language. It is closer to the true instruction set of the GPU, but it is not final instruction set of the GPU. However, if you are writing a new language frontend for CUDA, outputting PTX is the right way to go. nvcc converts the device code in C to PTX and sends it to ptxas. (Use the --ptx flag to nvcc to see the generated PTX.) It is also worth noting that ptxas does the final register assignment, automatically discovering when registers can be reused.

As for PTX documentation, all I know of is the documentation provided with the CUDA toolkit.

10x man External Image External Image

Hope that little dram will come true External Image (or we’ll bring it true :P)


Ok people, I’ve read a few docs about PTX and this seems to be a nice thing, but actually I couldn’t find any documentation about how to build an PTX code, so if anyone have smth about that, sample projects or anything helpful please help us by uploading or giving links :)


One more thing, about our “team”-s (we’re only two students yet :D) plans: We’re gonna pick an opensource compiler (Free Pascal at start, if deal goes well, a c variant would be plenty well too) and remake it for PTX :) any suggestions? ideas? We don’t have much experience so every tutorial, documentation, sample programs, methods… anything about PTX would be nice :)

You can take a look at the nvcc sources from NVIDIA (as they are based on Open64) ftp://download.nvidia.com/CUDAOpen64/

There is also a paper on the net, written by the NVIDIA employee that did this initial port. http://www.capsl.udel.edu/conferences/open…/Papers/101.doc

http://www.capsl.udel.edu/conferences/open…/Slides/101.ppt

Thx :) now I’m reading PTX manual, it’s really a piece of beauty :)

As it seems the only thing we need from Free Pascal is Syntax Parser, cuz not object-oriented code gets translated almost directly to PTX.

Maybe this question seems funny but I still don’t understand: is it possible to have as many threads as many shader processors are on the GPU running each on separate core? I mean independent streams, not like SIMD or vector.

no, there is only 1 instruction decoder per multiprocessor, and processing runs per warp (32 threads)

Understand, but one more noobish question: what to do with .bin file that is produced by PTX after compiling? Should I define something special in parameters? and if I want to test a PTX function, how to call it from a DLL or EXE? it was said ptx-based code is translated once for the target architecture, how to do this?

You will have to check the 2.1 documentation. In the releasenotes it is told that 2.1 has just in time compilation. So you generate ptx code, and when trying to run this code (through the driver API) the code is automatically converted into gpu code for you as far as I understand the feature, but I am not 100% sure.

But in general, you will need to use the driver API, so reading the driver API examples from the SDK should give you a good start.

OK, but how does CUDA do that? As I see ptx code gets crammed into EXE, how? It uses Cudart.dll and that uses Driver API, right? The latest documentation I could find is 1.3, could you tell me where to find 2.1?

ptxas is used to convert ptx into device code.

1.3 is probably the ptx related to the compute capability (1.3 is the latest released hardware)

Documentation for release 2.1 is in the toolkit of 2.1

Think u misunderstood, I want to make a PTX code run from an EXE and I couldn’t find any way how to do this, I have CUDA toolkit 2.1 installed but couldn’t find any way how to make make a linkable file from PTX, can anyone explain the whole procedure from writing a ptx code, for example

.version 1.3

.target sm_13

.func (.reg .f32 res) gpu_sqrt(.reg .f32 a)

{

 sqrt.f32 res,a; 

}

to calling it from a C-based program, for example DEV-C++ compiler,

#include <something.h> // GPU functions header

#include <stdlib.h>

#include <iostream.h>

using namespace std;

int main()

{

single a,b;

cin >> a;

b=gpu_sqrt(q);

cout<< endl << b;

system("pause");

}

P.S. maybe it’s better to open a new topic for this discussion? Hope mr. moder will place these PTX-based post there :)

The PTX code is converted into machine code. Normally you compile your device code into .cubin files and then load/call them via the runtime or driver API in the host code (which really could be anything, since the runtime DLL or driver DLL can be accessed by pretty much any programming language).

some of our customers request for Cuda support in our products listed at VSO-Software

unfornutly our video conversion tool, are written in Delphi and the conversion of any lib takes time.
For sure, maybe ConvertXtoDVD would benefit of Cuda, but we have basically 2 options, either to wait the Cuda support to be implemented in FFmpeg ( which is the encoder we are using ) , or take some key sensitive task part ( as image processing and rescaling ) in our delphi part

thanks for the code posted in this forum, I will send the information to the developpers
There are not that many tools ( end-users style ) supporting Cuda

For E.D Riedijk:
I think there is a more simple way to use cuda in delphi (and other language).
Considering I want to use a C code like (in pseudo code):

global void add(array of integer: A,B; Array of integer: OUTPUT);
var i:integer;
begin
for i=1 to 5
begin
OUTPUT=A[i] + B[i];
end;
end;

External function Prova (thread, block,array of integer: A,B; Array of integer: OUTPUT);
begin
add<<<thread,block>>>(A,B,OUTPUT);
end;

ok?
Well…how Do I compile it for making a dll with nvcc???
I need for a basic sample to use nvcc to make a dll linkable…
I think it is the better way to use cuda in delphi (using a mix of delphi and c)…
Thanx!!! :-D

pls, can anybody reupload the attachment

Here, spread

This work has inspired me to another[attachment=14551:simpleTe…OnDelphi.rar]