Is it possible to use forks to fill in values of a matrix?

7 views
Skip to first unread message

Andrew Orry

unread,
Dec 7, 2021, 5:33:12 PM12/7/21
to MolSoft ICM Knowledge Base
Q.
Is it possible to use forks to fill in values of a matrix?

For example, I have a square matrix M with shape NxN, and for M[i, j] I need to perform a computation using some table concatenations etc. before taking the Sum() of a column as the value for M[i, j].

The computation is taking a while so I wondered if I can parallelize it.

A.

In Linux and Mac we have 'fork' mechanism to add parallelization to ICM scripts.
This option/command is not available on Windows platform due to OS specifics.

fork is described here:

http://molsoft.com/icm/icm-commands.html#fork

The closest to what you need to is 'fork' option for 'for' loop

Example:

for i=1,Nof(t) fork 8 t   # run in 8 cores, declare 't' as shared table
  # some long running code which calculates r_out
  t.B[i] = r_out
endfor

Note that you can declare only table type as 'shared'  between processes in 'for' loop.

So, if you on Mac or Linux you can probably adopt your code to take advantage of this, otherwise the cross platform approach would be less elegant and will require launching few background jobs (e.g: each job will calculate some row range of your matrix) and then read the result from temporary files from each job and assemble it together.


Reply all
Reply to author
Forward
0 new messages