Carl Love

Carl Love

27726 Reputation

25 Badges

12 years, 162 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are questions asked by Carl Love

How can I limit the number of processors that are used by a multi-threaded operation? The help pages ?multithreaded and ?kernelopts both suggest, vaguely, that this can be controlled with kernelopts(numcpus). The following worksheet shows, however, that this doesn't work: While Maple does remember what you set numcpus to, this setting has no effect on the number processors used by Threads. And, if this doesn't work, what purpose is there in being able to set the value of numcpus?

restart:

First, warm-up and stretch the memory. Otherwise, the timings are invalid.

L:= RandomTools:-Generate(list(integer, 2^18)):

CodeTools:-Usage(Threads:-Mul(x, x= L)):

memory used=1.21GiB, alloc change=0.98GiB, cpu time=18.66s, real time=3.75s, gc time=27.54m

Now this is the actual test.

L:= RandomTools:-Generate(list(integer, 2^18)):

gc();

for n to kernelopts(numcpus) do
     print(kernelopts(numcpus= n));
     CodeTools:-Usage(Threads:-Mul(x, x= L), iterations= 4)
end do:

8

memory used=1.21GiB, alloc change=322.34MiB, cpu time=4.04s, real time=933.75ms, gc time=566.41ms

1

memory used=1.21GiB, alloc change=-2.00MiB, cpu time=4.22s, real time=859.50ms, gc time=656.25ms

2

memory used=1.21GiB, alloc change=-1.17MiB, cpu time=4.03s, real time=841.75ms, gc time=566.41ms

3

memory used=1.21GiB, alloc change=256.00MiB, cpu time=4.47s, real time=911.25ms, gc time=738.28ms

4

memory used=1.21GiB, alloc change=0 bytes, cpu time=4.33s, real time=852.50ms, gc time=605.47ms

5

memory used=1.21GiB, alloc change=0 bytes, cpu time=4.34s, real time=853.50ms, gc time=628.91ms

6

memory used=1.21GiB, alloc change=0 bytes, cpu time=4.27s, real time=826.75ms, gc time=535.16ms

7

memory used=1.21GiB, alloc change=0 bytes, cpu time=4.19s, real time=841.50ms, gc time=308.59ms

 

Download numcpus.mw

You'll get equivalent results if you replace Mul by Add and increase the size of L to about 2^24.

I've read the help page ?printf for the format codes many times over the years. I think that this is new:

The Z modifier, "%Zm" can be used to generate an alternate equivalent dotm representation that is used in communication with the GUI and in DocumentTools related functionality for the creation of XML content for .mw files.

Could someone show me an example of that?

 

The problem that I'm asking about here doesn't show in the MaplePrimes display of the worksheet below; you'll need to download the worksheet to see it. The problem is that the last subsection (which is currently empty) overlaps with the second-to-last subsection. It also overlapped when it was not empty. I just want to delete that last subsection, but nothing that I've tried works. This is not the first time that I've had overlapping subsections, but previously I've always been able to fix the problem by closing and re-opening the worksheet. That doesn't work in this case.

ReparamT.mw: A scratch space for testing NewSLO:-reparam

Modify at will.

Created by Carl 2016Jun17.

 

Important: If any change is made to KB.mpl or NewSLO.mpl then before running this worksheet

1. Restart all open Maple sessions.

2. From the command line, run "cmaple -q < update-archive.mpl".

 

restart;

dir:= "C:/cygwin64/home/owner/hakaru/maple/":

Load:= proc(package::symbol) read ""||dir||package||".mpl" end proc:

 

with(NewSLO);

with(KB);

Load(ReparamT);

 

Passed cases

   

Cases being worked on

 

infolevel[reparam]:= 2:

 

Linear fractional transformation (LFT) with symbolic coefficients

   

LFT with explicit coefficients

   

Simplest nonlinear LFT: 1/x

   

Symbolic constant multiple

   

Two-variable LFT with Gamma

   

Two-variable constant multiple with ChiSquare and Standard Normal

   

(t16) Sum of std normals to Normal(0, sqrt(2))

   

(t20) Sum of n Bernoullis to Binomial

   

(t23) Sum of Exponentials to Gamma

   
 
   

 

Download ReparamT.mw

Why won't this procedure Compile? All I get is a cryptic and ungrammatical error message.

    step:= proc(
          n::integer[4],
          XYZ::Matrix(datatype= float[8]),
          E::Vector(datatype=integer[4]), F::Vector(datatype=integer[4]),
          W::Matrix(datatype= float[8]), #3x2 scratch matrix
          mu::integer[4]
     )
     option autocompile;
     local
          i::integer[4], j::integer[4],
          ed::float[8],
          fd::float[8],
          p::float[8], t::float[8]       
     ;
          to mu do
               for i to n do
                    ed:= 0;  fd:= 0;
                    for j to 3 do
                          p:= XYZ[i,j];
                          t:= XYZ[E[i],j] - p;
                          ed:= ed+t^2;
                          W[j,1]:= t;
                          t:= XYZ[F[i],j] - p;
                          fd:= fd+t^2;
                          W[j,2]:= t
                    od;
                    ed:= sqrt(ed) + .01;  fd:= sqrt(fd) + .01;
                    for j to 3 do
                         XYZ[i,j]:= 0.995*XYZ[i,j] - 0.01*W[j,1]/ed + 0.02*W[j,2]/fd
                    od
               od
          od
     end proc;
Compiler:-Compile(step);

Error, (in Compiler:-Compile1) In memory compilation failed

I have seen several animated avatars on MaplePrimes. How is this done? I tried to make an animated GIF file my avatar, but it only shows the first frame. Here is the animation:

3 4 5 6 7 8 9 Page 5 of 9