Parallel run when i call a yade script from another file

Asked by JOHN

Good evening,
I am currently calling a yade python script from another python script.
something like this

import Yadesimulation

 from Yadesimulation import *

where Yadesimulation is the yade script.
My question is, how can i run I speed it up? I tried running it on parallel, using [1]. However, although when i try similar examples with pure jade and yade -j4 it gives me a good speedup, the script approach produces no speedup at all. Am i missing something?

For the record i put

import sys
import os
sys.argv.extend(['-j','4'])
os.system("ln -s /usr/bin/yade yadeimport.py")
from yadeimport import yade

in my yade script and i have 4 cores in my linux machine, so there should be a lot more than enough threads.

[1]https://answers.launchpad.net/yade/+question/271679

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
JOHN
Solved:
Last query:
Last reply:
Revision history for this message
Deepak (deepak-kn1990) said :
#1

Hi John,

Before you execute your python script, you can set the number of threads :

export OMP_NUM_THREADS=4

and then you could run your simulation like this:

python yourscipt.py -j4

Could you check if this works?

On Wed, Feb 28, 2018 at 10:42 AM, JOHN <<email address hidden>
> wrote:

> New question #665054 on Yade:
> https://answers.launchpad.net/yade/+question/665054
>
> Good evening,
> I am currently calling a yade python script from another python script.
> something like this
>
> import Yadesimulation
>
> from Yadesimulation import *
>
> where Yadesimulation is the yade script.
> My question is, how can i run I speed it up? I tried running it on
> parallel, using [1]. However, although when i try similar examples with
> pure jade and yade -j4 it gives me a good speedup, the script approach
> produces no speedup at all. Am i missing something?
>
>
> For the record i put
>
> import sys
> import os
> sys.argv.extend(['-j','4'])
> os.system("ln -s /usr/bin/yade yadeimport.py")
> from yadeimport import yade
>
>
> in my yade script and i have 4 cores in my linux machine, so there should
> be a lot more than enough threads.
>
>
>
> [1]https://answers.launchpad.net/yade/+question/271679
>
>
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
JOHN (washingmachine) said :
#2

Hello,
Thanks, the method does seem to work, however the speedup was 10% at best for a simulation of ~70.000 particles interracting with a wall under the effects of gravity
Still 10% is better than nothing :-)

Revision history for this message
Deepak (deepak-kn1990) said :
#3

Hello John,

One way to speed up your simulation would be to identify the bottlenecks in your script. This could come from the loops inside your python script.
 For example : looping through all the bodies in every time step and doing some calculations. Such loops inside the python script can lower the performance.
If you have a python function which does something similar every timestep, it would be better to write them in C++ and call the C++ function in your script.

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#4

Hi,
Initially:
>"when i try similar examples with pure jade and yade -j4 it gives me a good speedup"
then:
>"the method does seem to work, however the speedup was 10% at best"

Was the mentionned "good speedup" about 10%?
Else I would say the method still does not work and you got a nearly random fluctuation of CPU time...
Bruno

Revision history for this message
JOHN (washingmachine) said :
#5

Thank you!
When i removed almost every iteration (save for the predicate for removing particles from the walls) 4 cores gave an almost 200% speedup.

I suppose Ill start writting them in c++ and importing them in the Pyrunners
Thanks again