Gillee

242 Reputation

8 Badges

9 years, 51 days

MaplePrimes Activity


These are replies submitted by Gillee

@C_R 

Thank you so much for the update, really appreciate your attention.

@Carl Love 

Thank you for your interest.

I entered your suggestions into Maple 2026; the results are mixed:

Results after first time execution gpus were faster than cpus

kernelopts(version);
  Maple 2026.0, X86 64 WINDOWS, Mar 05 2026, Build ID 2001916

CUDA:-HasDoubleSupport();
                       TABLE([0 = true])

n := 4000;
M1 := LinearAlgebra:-RandomMatrix(n, n, datatype = float[4]);
M2 := LinearAlgebra:-RandomMatrix(n, n, datatype = float[4]);
CUDA:-IsEnabled();
                             false

tNoCUDA := time[real](M1 . M2);
                        tNoCUDA := 0.633

CUDA:-Enable(true);
                             false

CUDA:-IsEnabled();
                              true

tCUDA := time[real](M1 . M2);
                         tCUDA := 0.487

evalf(tNoCUDA/tCUDA);
                          1.299794661

CUDA:-Enable(false);
                              true

CUDA:-IsEnabled();
                             false

Results after second and third time execution on the same program and computer, cpus were faster than gpus

kernelopts(version);
  Maple 2026.0, X86 64 WINDOWS, Mar 05 2026, Build ID 2001916

CUDA:-HasDoubleSupport();
                       TABLE([0 = true])

n := 4000;
M1 := LinearAlgebra:-RandomMatrix(n, n, datatype = float[4]);
M2 := LinearAlgebra:-RandomMatrix(n, n, datatype = float[4]);
CUDA:-IsEnabled();
                             false

tNoCUDA := time[real](M1 . M2);
                        tNoCUDA := 0.302

CUDA:-Enable(true);
                             false

CUDA:-IsEnabled();
                              true

tCUDA := time[real](M1 . M2);
                         tCUDA := 0.462

evalf(tNoCUDA/tCUDA);
                          0.6536796537

CUDA:-Enable(false);
                              true

CUDA:-IsEnabled();
                             false
Thanks again.

@C_R 

I ran this same code on an older computer and the results showed an improvement doing the matrix multiplication in the gpu versus the cpu, where speed factor was 1.54. Here are the results:

  Maple 2022.2, X86 64 WINDOWS, Oct 23 2022, Build ID 1657361

CUDA enabled? false

                        tNoCUDA := 1.675

Time without CUDA: 1.675 seconds

                      prevSetting := false

Previous CUDA setting: false
CUDA enabled now? true

                         tCUDA := 1.090

Time with CUDA: 1.090 seconds
Speedup factor: 1.54

props := [TABLE(["Major" = 7, 

  "Max Threads Dimensions" = [1024, 1024, 64], "ID" = 0, 

  "Max Grid Size" = [2147483647, 65535, 65535], 

  "Texture Alignment" = 512, "Total Constant Memory" = 65536, 

  "Kernel Exec Timeout Enabled" = true, 

  "Resisters Per Block" = 65536, 

  "Total Global Memory" = 4294967295, 

  "Name" = "NVIDIA GeForce GTX 1660 Ti", 

  "MultiProcessor Count" = 24, "Shared Memory Per Block" = 49152, 

  "Clock Rate" = 1590000, "Memory Pitch" = 2147483647, 

  "Max Threads Per Block" = 1024, "Device Overlap" = 1, 

  "Minor" = 5, "Warp Size" = 32])]


I can't say for certain why the differences between the two computers other than the cpus in the newer computer is much faster than the gpus in the graphics card and the reverse for the older computer.

I will assumed the Maple code works.

@mmcdara Thank you for your answer.

@acer Thank you for your answer.

@acer In the define_external line, I deleted the RETURN:: ... phrase to get a NULL return and added "c" after the fmay_mult(a,b,c,3,3).

>fmat_mult:=define_external( 'mat_mult', LIB= "C:/Users/familee/OneDrive/Documents/Maple/DLL-example/mat_mult.dll", FORTRAN, 'a'::(ARRAY(datatype=float[8])), 'b'::(ARRAY(datatype=float[8])), 'c'::(ARRAY(datatype=float[8])), 'm'::(integer[4]), 'n'::(integer[4]) ):

The results should be the Matrix c

>fmat_mult(a,b,c,3,3)
>c
                        [30.  66.  102.]
                        [36.  81.  126.]
                        [42.  96.  150.]

@sursumCorda

I ran your program and it works. I did not make any changes to the C++ compiler.

Thanks again  

@sursumCorda 

I added the line infolevel[compiler]:=3. I got a similar response in Maple 2023 Windows 11: Compile: Compile Command: "C:\Program Files\Maple 2023\llvm\bin\x86_64-w64-mingw32-clang++.exe" -c  -DX86_64_WINDOWS=1 -I"C:\Program Files\Maple 2023\extern\include" -O2  -w  

In Maple 2022 Windows 11, the response is: Compile: Compiling generated C code with LLVM. Then everything works.

I also have Maple 2023 running on Linux, it works fine.

Thank you for your input.

@Jean-Michel 

Thanks for your response.

One more try at speeding it up. Write procedure and compile it to native code. The compiled procedure is faster than any of the previous attempts found in Threads_datLoop_vs_seq.mw.

 


 

restart; kernelopts(version)

`Maple 2021.1, X86 64 WINDOWS, May 19 2021, Build ID 1539851`

(1)

datLoop := proc (i_high::integer, j_high::integer, X::(Vector(datatype = float[8])), Y::(Vector(datatype = float[8])), Z::(Vector(datatype = float[8]))) local i::integer, j::integer, k::integer, di::(float[8]), dj::(float[8]); k := 1; di := 1.0/i_high; dj := 1.0/j_high; for j to j_high do for i to i_high do X[k] := i*di; Y[k] := j*dj; Z[k] := X[k]^2+Y[k]^2; k := k+1 end do end do end proc

 

If you can compile a Maple procedure to native code, then it runs fast. There are only small number of mathematical functions in the run-time library, see help on Compiler.  

 

cdatLoop := Compiler:-Compile(datLoop)

proc () options call_external, define_external(_mf85e7835c3fc2354c4b104b43e721728, MAPLE, IN_MEM = 2379591451296); call_external(0, 2379591451296, true, false, args) end proc

(2)

 

Initialize variables:

 

i_high := 1000; j_high := 1000; X := Vector(1 .. i_high*j_high, datatype = float[8]); Y := Vector(1 .. i_high*j_high, datatype = float[8]); Z := Vector(1 .. i_high*j_high, datatype = float[8])

 

Run datLoop procedure

 

CodeTools:-Usage(datLoop(i_high, j_high, X, Y, Z))

memory used=480.47MiB, alloc change=8.00MiB, cpu time=5.44s, real time=5.49s, gc time=1.94s

 

 

Display the first ten data points

 

X[1 .. 10], Y[1 .. 10], Z[1 .. 10]

Vector[column](%id = 36893490527006812148), Vector[column](%id = 36893490527006812268), Vector[column](%id = 36893490527006812388)

(3)

 

Run compiled datLoop procedure: cdatLoop

 

CodeTools:-Usage(cdatLoop(i_high, j_high, X, Y, Z))

memory used=1.06KiB, alloc change=0 bytes, cpu time=16.00ms, real time=17.00ms, gc time=0ns

 

X[1 .. 10], Y[1 .. 10], Z[1 .. 10]

Vector[column](%id = 36893490527006802756), Vector[column](%id = 36893490527006802876), Vector[column](%id = 36893490527006802996)

(4)

"n:=3: f(x,y):=x^(~2)+y^(~2): data := CodeTools:-Usage([seq([seq([i/10^(n), j/10^(n), f(i/10^(n), j/10^(n))], i = 1 .. 10^(n))], j = 1 .. 10^(n))]): "

memory used=0.99GiB, alloc change=225.29MiB, cpu time=6.73s, real time=5.95s, gc time=1.75s

 

data[1][1 .. 2][1 .. 2]

[[1/1000, 1/1000, 1/500000], [1/500, 1/1000, 1/200000]]

(5)

``


 

Download Compiled_datLoop_vs_seq.mw

@Kitonum 

I realized I should have shown that zeta = xi - beta * I.

I added negative signs to the following two lines of code:

soln1:=select(s->Re(s)>0 and -Im(s)>0, soln);

  and

imaginary_part:=-Im(L[1]);

It is a nice solution.

 

Thank you

 

1 2 3 Page 1 of 3