Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Two simultaneous COMSOL instances on one machine can save time

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Dear community,

today I tested something I had in mind for quite some time. On my workhorse computer, a 3.6 GHz Core i7 with 4 cores I always observe that a COMSOL calculation brings up CPU use to a maximum of 50%. Only starting a second COMSOL instance brings up CPU usage to 100%.
I was wondering if dividing extensive parameter studies into two instances would yield a benefit or the increased CPU usage would suffer from increased overhead.
Here is the result for a small AC/DC parameter study:
1 instance: 2min 58 s
2 parallel identical instances: 3min 48 s
The direct MUMPS solver was used.
So this is a significant benefit. I still have to check if it is the same for large models that take much more time for a single parameter step behave the same way. Of course the machine has to have enough memory for the two parallel instances.

Cheers
Edgar

--
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com

5 Replies Last Post 19.08.2014, 03:35 GMT-4

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 14.08.2014, 20:35 GMT-4
Interesting. I'm not sure which tasks COMSOL can effectively run in parallel when just executed through a single COMSOL instance, but you may get similar speed-up by enabling the multicore capabilities in the COMSOL preferences under "Multicore and Cluster Computing". If you haven't already tried that.

My computer has 8 cores. Without multicore enabled, COMSOL never seems to use more than 50% of my total CPU (I guess either it or my CPU/OS are smart enough to give COMSOL more than just 1/8th of my total CPU by default). With multicore enabled and number of cores set to 8, running a major task in COMSOL will frequently ramp my CPU usage up to 100%. This limits my ability to multi-task with other applications, of course, but can help COMSOL finish faster.
Interesting. I'm not sure which tasks COMSOL can effectively run in parallel when just executed through a single COMSOL instance, but you may get similar speed-up by enabling the multicore capabilities in the COMSOL preferences under "Multicore and Cluster Computing". If you haven't already tried that. My computer has 8 cores. Without multicore enabled, COMSOL never seems to use more than 50% of my total CPU (I guess either it or my CPU/OS are smart enough to give COMSOL more than just 1/8th of my total CPU by default). With multicore enabled and number of cores set to 8, running a major task in COMSOL will frequently ramp my CPU usage up to 100%. This limits my ability to multi-task with other applications, of course, but can help COMSOL finish faster.

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 15.08.2014, 05:18 GMT-4
In the Core i7 machine it doesn't matter whether I activate the multicore feature or not. All 4 cores are used but only to 50% in one instance.
Which cpu is in your machine?

--
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
In the Core i7 machine it doesn't matter whether I activate the multicore feature or not. All 4 cores are used but only to 50% in one instance. Which cpu is in your machine? -- Edgar J. Kaiser emPhys Physical Technology http://www.emphys.com

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 15.08.2014, 12:31 GMT-4
Mine is actually the same family of CPU as yours:
Intel Core i7-4800MQ CPU @ 2.70GHz

Technically, I think this processor has 4 cores, but it has 8 threads. Enabling multicore processing in comsol and setting the number of coress to 4 shows little deviation from the default comsol behavior. Setting the number of cores to 8, however, seems to let comsol consume all of my CPU resources.

I would not be surprised if telling comsol I have 8 cores would lead to erratic behavior on occasion, but I haven't used it enough to say for sure. I typically just leave this multicore functionality disabled as I'm often multi-tasking on my PC and am satisfied with comsol just using ~half of my CPU's resources.
Mine is actually the same family of CPU as yours: Intel Core i7-4800MQ CPU @ 2.70GHz Technically, I think this processor has 4 cores, but it has 8 threads. Enabling multicore processing in comsol and setting the number of coress to 4 shows little deviation from the default comsol behavior. Setting the number of cores to 8, however, seems to let comsol consume all of my CPU resources. I would not be surprised if telling comsol I have 8 cores would lead to erratic behavior on occasion, but I haven't used it enough to say for sure. I typically just leave this multicore functionality disabled as I'm often multi-tasking on my PC and am satisfied with comsol just using ~half of my CPU's resources.

Pär Persson Mattsson COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 18.08.2014, 05:32 GMT-4
Hi,
The reason why COMSOL only seems to be using 50% of the CPU power is that you have hyper threading activated (see www.comsol.de/support/knowledgebase/1096/, the section about hyperthreading). Hyperthreading allows each core to handle two threads, and the operating system will therefore assume that the i7 has twice as many cores as it has (4 of them are virtual cores). COMSOL, however, will use only the true, physical cores by default. The operating system will show that COMSOL uses only 50% of the CPU power, while it actually utilizes the physical cores at 100%.

You can of course force COMSOL to use the virtual cores as well by setting the number of cores to 8 manually (you might be shown a warning, though). Normally, though, one COMSOL session will not benefit from activating hyperthreading. The reason why two COMSOL instances, running in parallel, give a speedup is most probably due to the optimization in the operating system in combination with a smaller model using a direct solver.

Anyhow, if you want to compute a parametric sweep in parallel on your workstation, the recommended way to do this is to use the batch sweep functionality. We published a blog post describing how to use this feature here: www.comsol.com/blogs/added-value-task-parallelism-batch-sweeps/

Best,
Pär Persson Mattsson
Technical Support Engineer at Comsol
Hi, The reason why COMSOL only seems to be using 50% of the CPU power is that you have hyper threading activated (see http://www.comsol.de/support/knowledgebase/1096/, the section about hyperthreading). Hyperthreading allows each core to handle two threads, and the operating system will therefore assume that the i7 has twice as many cores as it has (4 of them are virtual cores). COMSOL, however, will use only the true, physical cores by default. The operating system will show that COMSOL uses only 50% of the CPU power, while it actually utilizes the physical cores at 100%. You can of course force COMSOL to use the virtual cores as well by setting the number of cores to 8 manually (you might be shown a warning, though). Normally, though, one COMSOL session will not benefit from activating hyperthreading. The reason why two COMSOL instances, running in parallel, give a speedup is most probably due to the optimization in the operating system in combination with a smaller model using a direct solver. Anyhow, if you want to compute a parametric sweep in parallel on your workstation, the recommended way to do this is to use the batch sweep functionality. We published a blog post describing how to use this feature here: http://www.comsol.com/blogs/added-value-task-parallelism-batch-sweeps/ Best, Pär Persson Mattsson Technical Support Engineer at Comsol

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 19.08.2014, 03:35 GMT-4
Dear Pär,

thank you for elaborating on the subject. Specifically the batch sweep is an interesting new feature. I had heard of it but haven't used it so far.
One of my motivations for the test was to learn whether two parallel COMSOL instances would provide any benefit at all or in the worst case would even be slower in total due to increased overhead.

So far it looks like smaller models can be run on parallel instances. This is particularly interesting if the batch sweep cannot be applied, e.g. in case two different models are to be computed.
What I learned from your contribution is that much depends on the specific case and optimization can go different ways.

Thank you and best regards
Edgar

--
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Dear Pär, thank you for elaborating on the subject. Specifically the batch sweep is an interesting new feature. I had heard of it but haven't used it so far. One of my motivations for the test was to learn whether two parallel COMSOL instances would provide any benefit at all or in the worst case would even be slower in total due to increased overhead. So far it looks like smaller models can be run on parallel instances. This is particularly interesting if the batch sweep cannot be applied, e.g. in case two different models are to be computed. What I learned from your contribution is that much depends on the specific case and optimization can go different ways. Thank you and best regards Edgar -- Edgar J. Kaiser emPhys Physical Technology http://www.emphys.com

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.