dohashi

1172 Reputation

10 Badges

16 years, 79 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 replies submitted by dohashi

 

I don't think that particular issue will be resolved in Maple 14.  It will require a fairly significant re-write of the communication code.  There are a few places in the kernel that still don't work optimially with multiple threads, and we are focusing on fixing the ones that are performance bottlenecks first.

 

Darin

-- Kernel Developer Maplesoft

 

I think the Question and Answer system with voting for replies is ok, if each reply still has nested comments that move with the original reply.  One potential solution would also be to allow for different types of forums.  Maybe a set of Q & A forums with these voted replies, and a set of discussion forums where the comments work as they do now.

As for the colaberative editting, it seems like instead of allowing people to edit other people's posts, we should just add a wiki to MaplePrimes, (an idea that is not new).  When good information is developed in the forum, it can me made into an article in the wiki.

Darin

-- Kernel Developer Maplesoft

 

I wish MaplePrimes had the ability to save drafts of blog posts so they could be worked on over time.  I'm currently writing most of my posts off site, and just copying and pasting them when I'm ready to post.

Darin

-- Kernel Developer Maplesoft

 

Except for a bit of lag when first starting, this seems to work:

Download 122_timer.mw

Darin

-- Kernel Developer Maplesoft

 

Except for a bit of lag when first starting, this seems to work:

Download 122_timer.mw

Darin

-- Kernel Developer Maplesoft

 

You should be able to call SetProperty from the background thread.  Just put your code in place of the print( st )

Darin

-- Kernel Developer Maplesoft

 

You should be able to call SetProperty from the background thread.  Just put your code in place of the print( st )

Darin

-- Kernel Developer Maplesoft

 

When I run your code on my actual multi-core machine, I do see interlaced output:

                                 "thread 2: time = .746"

                                 "thread 1: time = .746"

                                "thread 2: time = 2.857"

                                "thread 1: time = 4.861"

                                "thread 1: time = 6.865"

                                "thread 2: time = 8.870"

                                "thread 2: time = 10.875"

                                "thread 1: time = 12.879"

                                "thread 2: time = 14.882"

                                "thread 1: time = 16.886"

Here is my best guess to why you aren't seeing interlaced output.  The system call is executed by the client (cmaple or the GUI), not in the kernel itself.  Communication between the kernel and the client is synchronized, so while the system call is executing another thread has to wait to send its system call to the client.  However once the first thread's sleep is over, the amount of time it spends in the kernel is very short, so it makes it back into the system call before the other thread wakes up (because you are on a single core machine), blocking the other thread once again.  Thus one thread manages to monopilize the client interface while the other thread is stuck waiting.

Once the first thread is done, the other thread can finish.

Now as for why printf works when print doesn't.  I think this has to do with how printf works.  printf sends multiple messages to the client, thus is locking and unlocking more frequently.  My guess is this allows the second thread a better chance of waking up and being able to get its system command to the client.

Darin

-- Kernel Developer Maplesoft

 

When I run your code on my actual multi-core machine, I do see interlaced output:

                                 "thread 2: time = .746"

                                 "thread 1: time = .746"

                                "thread 2: time = 2.857"

                                "thread 1: time = 4.861"

                                "thread 1: time = 6.865"

                                "thread 2: time = 8.870"

                                "thread 2: time = 10.875"

                                "thread 1: time = 12.879"

                                "thread 2: time = 14.882"

                                "thread 1: time = 16.886"

Here is my best guess to why you aren't seeing interlaced output.  The system call is executed by the client (cmaple or the GUI), not in the kernel itself.  Communication between the kernel and the client is synchronized, so while the system call is executing another thread has to wait to send its system call to the client.  However once the first thread's sleep is over, the amount of time it spends in the kernel is very short, so it makes it back into the system call before the other thread wakes up (because you are on a single core machine), blocking the other thread once again.  Thus one thread manages to monopilize the client interface while the other thread is stuck waiting.

Once the first thread is done, the other thread can finish.

Now as for why printf works when print doesn't.  I think this has to do with how printf works.  printf sends multiple messages to the client, thus is locking and unlocking more frequently.  My guess is this allows the second thread a better chance of waking up and being able to get its system command to the client.

Darin

-- Kernel Developer Maplesoft

Maple does not connect to the operating system kernel, except via standard API calls. The core Maple evaluation engine is contained in an executable we refer to as "the kernel". The Maple GUI connects to the Maple kernel. Darin -- Kernel Developer Maplesoft
The DAG classes have private constructors. To create objects use the exports of the Engine object. This style of construction is used because the Maple engine is required to create a DAG. Java OpenMaple does not currently have objects for all the DAG types, which I agree is a shame. Actually what I think might be even more useful would be adding functions like add, multiply and power to the Algebraic class. That would make it much easier to form complex DAGs. op would probably be a good function to add as well. It is not clear what you would do with (for example) a sum dag that you could not do with a Algebraic. I guess if you constructed the dag then you could control the evaluation better. How would you suggest creating a procedure? (Note it is not a function call) I think that the use of a string, (thus Maple syntax) is pretty natural. Procedure.execute allows one to form and evaluate a function call. Algebraic.eval on the procedure will evaluate the procedure DAG. As for the expression sequence thing, if you notice, an expression sequence can only be assigned to before unique is called. This allows one to construct an expression sequence without having to have all the Algbraics pre-computed. So you can create an expression sequence in a for loop. There are also some instances, like in Procedure.execute where an array of algebraics can be used in place of an expression sequence. Darin -- Kernel Developer Maplesoft
The DAG classes have private constructors. To create objects use the exports of the Engine object. This style of construction is used because the Maple engine is required to create a DAG. Java OpenMaple does not currently have objects for all the DAG types, which I agree is a shame. Actually what I think might be even more useful would be adding functions like add, multiply and power to the Algebraic class. That would make it much easier to form complex DAGs. op would probably be a good function to add as well. It is not clear what you would do with (for example) a sum dag that you could not do with a Algebraic. I guess if you constructed the dag then you could control the evaluation better. How would you suggest creating a procedure? (Note it is not a function call) I think that the use of a string, (thus Maple syntax) is pretty natural. Procedure.execute allows one to form and evaluate a function call. Algebraic.eval on the procedure will evaluate the procedure DAG. As for the expression sequence thing, if you notice, an expression sequence can only be assigned to before unique is called. This allows one to construct an expression sequence without having to have all the Algbraics pre-computed. So you can create an expression sequence in a for loop. There are also some instances, like in Procedure.execute where an array of algebraics can be used in place of an expression sequence. Darin -- Kernel Developer Maplesoft
Convenient as it might be, I still suggest you don't write code assuming map order. It is like using any undocumented feature. We don't test the correctness or consistency of the map order, so we can't make guarantees that it is going to work across platforms, across versions or even from session to session. Darin -- Kernel Developer Maplesoft
As a note, one should not write code that depends on the order that map applies the function to the data. This is left unspecified on purpose. We may make changes and optimizations that effect the order and so your code may break. Darin -- Kernel Developer Maplesoft
Yes. Maple 9 was the first version to support OS X. Darin -- Kernel Developer Maplesoft
1 2 3 4 5 6 Page 5 of 6