How to code for multiple cores (rand() and monte carlo)?

melisen

New Member
Joined
Apr 9, 2013
Messages
13
I have a rather smallish workbook I am trying to speed up. It is a behavioral model where each row consist of a “choice”: Based on some rand()s and likelihoods calculated from the result of the previous row it generates its own result that are then used in the next line etc for a total of 250 lines. Since each line depend on the result of the previous I have no ambition to make this calculation multiple core aware and a single simulation only takes a blink of an eye.

BUT I use a Monte Carlo simulation to create a list the result of 20000 of these “lives” (one variable per life) and that should be a clear candidate for multiple core aware calculations, no? Each simulated life is not dependent on anything else and I have made sure there is absolutely no calculations made on the 20000 results before the monte carlo simulation is over but Excel (2013) is still only using one core.

I use this data table “hack” to do my monte carlo simulation:https://www.youtube.com/watch?v=UeGncSFijUM I am not aware if there is another way to do monte carlo simulations in excel?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

J.Ty.

Well-known Member
Joined
Feb 4, 2012
Messages
1,118
Office Version
  1. 365
  2. 2013
  3. 2010
Platform
  1. Windows
  2. Web
Hi,

As far as I understand, your entire worksheet consists of a single column (perhaps a few columns) and 250 rows, and you want to run 20000 copies of it and have the calculation run as parallel as possible.

First, make sure that you enabled multiprocessor calculations in the Excel options (this is the default, so if you didn't touch it, it should be permitted).

Next, make as many copies of your calculation as possible, locating them next to each other (you can use automated filling for that purpose). Excel allows about 16k columns, so it should be sufficient for a few thousand copies.

Next, make copies of this complete block below (also doable by filling), to reach 20k copies.

Run everything by F9. According to all my experience, it should utilize as many cores as possible on your machine.

If you want my "manual" help, please send me a private message.

J.Ty.

P.S. If you indeed use "data table hack", this prevents Excel from using multiple cores and there is no way to achieve parallelism using thi method.
 
Last edited:

Forum statistics

Threads
1,137,349
Messages
5,680,971
Members
419,947
Latest member
cchristian6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top