CuBlas & CULA for Delphi 7 Matrix/Vector Classes for Dense Linear Algebra

The File Atteched Has The Units To Work With Delphi 7.0

Visual Example
CULACuBlasMtxVec
CULA (interface unit)
CuBlas (Interface Unit)

Tested with
Delphi 7.0
Cuda ToolKit 4
Cula Premim R12
devdriver_4.0_winxp_32_270.81_general
PNY NVIDIA Quadro VCQ 4000 Professional Graphics Card VCQ4000-PB

Some of the Copy Functions doesn’t work, so don’t use them.

Any Ideas To Improvet It are Welcome

Now I have code BicgStab using Cublas in Delphi 7.0

I use the same example to run it with culaDgesv(Cula) and BicgStab(cublas).

The next week I will work with GMRES.

It was tested with Quadro 4000 and GTX 450.

Here is the interface unit for CuBlas (double & single) and Cuda (just some functions) in Cuda 4.0 Version, the older files that I have in my Forum are not 4.0.
The Zipped File includes the CuBlasMtxVec Classes (Vector & Matrix) using only CuBlas functions, the solvers are CG and BiCGStab, GMRES is pending, sorry, I will work on it, but first I had to create the CuBlas interface unit for Cuda 4.0 in Delphi 7.0.

…the file also includes:
cublas_api.pas
cudaRT_v2.pas
cublas.pas
and an example

and PDF files from where I took the information or code for CG and BiCGStab.

[twitter]Tavo_Nice[/twitter] Finally here is GMRES in CuBlas V2 Cuda 4 for Delphi with Cuda RunTime, CuBlas and Cublas API unit interfaces…
I have included the Standard LU Decomposition and Block LU Decomposition, but without examples.
GMRES_CuBLAS.zip (289 KB)

GMRES with Reorthogonalization method, just change reorth:=1; to reorth:=0; if you want it or not

The Solution of the Triangular System is made with Cublas too.

Code:

for col:= 0 to ii-1 do cudaMemcpy(@h_device[colii], @H[col(m+1)],ii*sizeof(double),cudaMemcpyHostToDevice);

statuscublas:= cublasSetVector(ii, sizeof(double),@s[0],1,@y[0],1);

cublasDtrsv(’ ‘,’ ‘,’ ',(ii), h_device[0], (ii), y[0], 1);

cublasDgemv(‘N’, N, (ii), 1.0, V[0], N, y[0], 1, 1.0, xx[0] , 1);
GMRES_CuBLAS.zip (318 KB)

Now I have included the Simpler GMRES with Modified Gram Schmidt in the future I will include its Householder version.

Cublas V2
Cuda 4.0

Object Oriented Dense Linear Algebra for Nvidia GPU’s with Delphi 7.0

Conjugate Gradient CG
BiConjugate Gradient Stabilizated BiCGStab
Generalized Minimal Residual with Modified Gram Schmidt GMRES
Simpler Generalized Minimal Residual with Modified Gram Schmidt SGMRES
Adaptive Simpler Generalized Minimal Residual with Modified Gram Schmidt AdaptiveSGMRES
GMRES_CuBLAS.zip (923 KB)

Here is the whole idea of creating Object Oriented Dense Linear Algebra with Iterative Solvers

Object Oriented Linear Circuit Simulator using Object Oriented Dense Linear Algebra (Cublas Wrapper for Delphi 7.0)

example (included):

TCircuitProblem = [b]Class/b
public
VDC1, VDC2: TDCVSource;
IDC1: TDCISource;
R1, R2, R3: TResistor;
constructor Create;
end;
.
.
.
{ TCircuitProblem }

constructor TCircuitProblem.Create;
begin
inherited Create;
VDC1:= TDCVSource.Create(1,0,4.5);
VDC2:= TDCVSource.Create(3,0,4.5);
IDC1:= TDCISource.Create(2,0,2.0);
R1:= TResistor.Create(1,2,4.0);
R2:= TResistor.Create(2,3,4.0);
R3:= TResistor.Create(2,0,3.0);
Add(VDC1);
Add(VDC2);
Add(IDC1);
Add(R1);
Add(R2);
Add(R3);
end;

DC Analysis:
CircuitProblem.DCAnalysis //the solver is LU Decomposition Totally Implemented with CuBLAS

in the furure I will make the NonLinear…
Linear_Circuit_Simulator_using_CuBLASMtxVec.zip (689 KB)

Object Oriented Dense Linear Algebra for Nvidia GPU’s with Delphi 7.0 using CuBLAS

Direct Solvers:
LU Decomposition Solver LUSolve
Gauss Elimination Solver GaussSolve

Iterative Solvers:
Conjugate Gradient CG
BiConjugate Gradient Stabilizated BiCGStab
Generalized Minimal Residual with Modified Gram Schmidt GMRES
Simpler Generalized Minimal Residual with Modified Gram Schmidt SGMRES
Adaptive Simpler Generalized Minimal Residual with Modified Gram Schmidt AdaptiveSGMRES

Plus:
Add, Sub, Prod, NormL2, Dot functions using CuBLAS. CUDA 4.0.

Examples:
Linear Algebra & Linear Circuit Simulator (DC Analysis)

code c, c++, cpp, h, pascal
LU_&_Gauss_Solvers_using_CuBLASMtxVec.zip (683 KB)

Linear & NonLinear Electronic Circuit Simulator

DAE Solver (Differential Algebraic Equations) with CUBLAS in Delphi 7.0 (Object Pascal)
& CuBLAS Dense Linear Algebra Matrix Vector Classes with Direct and Krylov Methods

The Circuit Analysis Technique is Modified Nodal Analysis.

Transient and DC Analysis (Damped Newton Method)

Examples:

Rectifier Bridge with RC Filter Load

Rectifier Bridge with DC Linear Voltage Regulator and RC Filter Load

both with options to run Half Wave, Full Wave and to adjust RL, CL, Freq and Vi AC Volts.

Integration Methods include BE (Backward Euler), TR (Trapezoidal), BDF2 (Backwad Differentiation Formula 2nd or Gear 2nd Method) and TRBDF2

with automatic step size and order control.

Circuit Simulation with GPU.zip (1.43 MB)