dohashi

1172 Reputation

10 Badges

14 years, 348 days
I am a Senior Software Developer in the Kernel Group, working on the Maple language interpreter. I have been working at Maplesoft since 2001 on many aspects of the Kernel, however recently I have been focusing on enabling parallel programming in Maple. I have added various parallel programming tools to Maple, and have been trying to teaching parallel programming techniques to Maple programmers. I have a Master's degree in Mathematics (although really Computer Science) from the University of Waterloo. My research focused on Algorithm and Data Structure, Design and Analysis.

MaplePrimes Activity


These are answers submitted by dohashi

In Maple 12, the kernelopts( multithreaded ) command indicates that the kernel is capable of running multiple threads, not that it is using multiple threads. This is a bit of a backwards compatibility thing from Maple 11 where there were two separate kernels, one that was capable of running multiple threads and one that was not. In Maple 12 forward we have one kernel and it is always capable of running multiple threads. The kernelopts commands in general, and numcpus in particular, return the previous value, not the value that is being set. That is the expected behaviour. As you mentioned, the multi-threaded package is still quite new. There are some significant performance issues in Maple 12 that reduce the usefulness of multiple threads for general computation. The best available documentation is probably the Threads help pages. For the next release of Maple we are planning improvements to both the performance and usability of multi-threaded programming in Maple. Darin -- Kernel Developer Maplesoft

 

The amount of  "available" memory on the system is not accessable in Maple code.  That value is something that the classic GUI calculates on its own.  The only memory values that are accessable in Maple code are those available through kernelopts.

Darin

-- Kernel Developer Maplesoft

I notice you are running on OS X.  By default, OS X has a really low memory limit when running commands in a shell.

Try executing  "ulimit -a".  What value is "data set size" set to?

If it is low, try resetting it to unlimited

ulimit -d unlimited

Darin

-- Kernel Developer Maplesoft

 

The difficulty on the Mac is that Maple is not installed in the same way as it is on other platforms.  It sounds like you were able to build the class file, but are having difficulties running it.

You need to set two enviroment variables, MAPLE and DYLD_LIBRARY_PATH.

MAPLE should be set to the path where the Maple binaries are installed.  For example

export MAPLE=/Library/Frameworks/Maple.framework/Version/Current

DYLD_LIBRARY_PATH is set to the location where libjopenmaple.jnilib can be found, this should be

export DYLD_LIBRARY_PATH=$MAPLE/bin.APPLE_UNIVERSAL_OSX

With those two environment variables set, you should be able to execute:

java -classpath $MAPLE/java/externalcall.jar:$MAPLE/java/jopenmaple.jar:. test

Darin

-- Kernel Developer Maplesoft

The problem here is that you are only using one table. The second time through the loop you change the same table that was used the first time through the loop. You need to create a new table each time through the loop. The assignment PlotTable[thicknesstable[k]] := eval(MMatrixListReal); Does not make a copy of the table MMatrixListReal, it creates a reference to the table. Add MMatrixListReal := table(); at the top of the main loop. This will create a new table for each iteration of the loop. Darin -- Kernel Developer Maplesoft
The manual entry is really meant for users developing external calling code in higher level languages. On Windows, shared libraries do use different calling conventions. Therefore we specify which convention (stdcall) must be used for external calling. In UNIX it is very unlikely that a shared library would not use the default calling convention. Therefore Maple expects the default C calling convention be used when executing functions via external calling. Your assembly functions on UNIX should use whatever the standard calling convention is for the platform you are developing on. You might consider using inline assembly in a C library so that the compiler and linker can take care of the calling conventions. You can always edit the generated assembly. Darin -- Kernel Developer Maplesoft
1) Why is this so? Well, C is a compiled programming language, so the resulting binary executes directly on the CPU. Maple is an interpreted programming language, meaning that there is a piece of software that reads your code and decides how to execute it. In addtion, for numeric code, C works in hardware datatypes (floats and integers) whereas Maple works with software data types. A hardware float multiplication will take one CPU cycle, a software float multiplication may take hundreds or thousands (depending on the length of the float). 2) How do we make it run faster? What was the point of taking C code and converting it into Maple? Did you want greater accuracy? Usually people would develop the code in Maple first, and then export it to C for greater performance. If you don't need more accuracy than C, then check out ?evalhf and ?Compiler. Those will give you a lot of speed ups by executing the code at hardware precision. However the final results may not be very different that your results from C. Without seeing your Maple code, I can only suggest areas for you to investigate. The Maple functions map, seq, add, and mul are more efficient than for loops. For example, this
# create the data
n := 10^6;
L := [ seq( i, i=1..n ) ];
s := 0;

for i from 1 to n
do
    s := s+L[i];
end do;
is slower than
# create the data
n := 10^6;
L := [ seq( i, i=1..n ) ];

s := add( L[i], i=1..n );
In this particular case you could just do this:
# create the data
n := 10^6;
s := add( i, i=1..n );
However often the data represented here by L won't be so simple. As well, growing lists element by element is very slow. This is bad code:

n := 10^6;

L := [];

for i from 1 to n
do
    L := [ op(L), i ]:
end do:

L;
This is far more efficient
n := 10^6;

L := [ seq( i, i=1..n ) ];
Maple also provides built in data structures with built in operations. Using them appropreately can greatly speed up your code. In particular, Maple's hash tables (?table) might be useful. Darin -- Kernel Developer Maplesoft
1 2 Page 2 of 2