Problem with OpenMP

Asked by Roxana Saghafian Larijani

Dear all ,

I am trying to run my simulation on multiple cores using openMP (using j -n). However, I can see that only one core is being used at 100% cpu. I have provided the MWE below and was wondering if you know what might be wrong?

I am not sure if it is the same problem as question 689131 or not. I tried to use sp.cellFill as Jan mentions in that question, but if I am not mistaken it cannot be used for periodic=False case , and my simulation is not periodic.

from yade import ymport
from yade import pack
from yade import utils, plot,wrapper

fr = 0.38
rho = 3000

En = 0.22
Et = 0.22
poi=0.3
yoM=200e6

r = 0.0005

Gamma = 0.073
Theta = 0
vB = 6.03 * 1e-9
CapType="Rabinovich"
KN=2*(47.17)
KS=2*(13.48)
CN=2*(0.0053)
CS=2*(0.0015)

##definig material

mat=O.materials.append(
        ViscElCapMat(frictionAngle=fr, density=rho, poisson=poi, young= yoM, Vb=vB, gamma=Gamma, theta=Theta, Capillar=True, CapillarType=CapType,en=En, et=Et,kn=KN,ks=KS,cn=CN, cs=CS)
)

#defining the spheres

sp=pack.SpherePack()
sp.makeCloud((-0.033,-0.033,-0.01),(0.033,0.033,0.01),rMean=r)
sp.toSimulation(material=mat)
Nprtcl=len(O.bodies)
print(Nprtcl)
Tt= utils.PWaveTimeStep()
O.dt = 0.5*Tt

#liquidMigration
VV=0.03
Vmin=0.0

for s in O.bodies:
        if not type(s.shape)==wrapper.Sphere:
                continue
        s.state.Vf=VV * (4/3) * 3.14*(s.shape.radius)**3
        s.state.Vmin=Vmin
##

Drum=geom.facetCylinder(material=mat,center=(0.0,0.0,0.0), segmentsNumber=32, radius=0.05,height=0.03,orientation=Quaternion(Vector3(0,0,1),(pi/2.0)))
walls = O.bodies.append(Drum)

##engine
O.engines = [
        ForceResetter(),
        InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
        InteractionLoop(
                [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
                [Ip2_ViscElCapMat_ViscElCapMat_ViscElCapPhys()],
                [Law2_ScGeom_ViscElCapPhys_Basic()],

        ),

        NewtonIntegrator(gravity=[0, -9.8, 0]),
        RotationEngine(ids=walls,rotationAxis=[0,0,1],rotateAroundZero=True, zeroPoint=[0.0,0.0,0.0], angularVelocity=0.45),
        LiqControl(label='lqc')
         ]

import math

O.timingEnabled = 1
from yade import timing

duration=60.0/O.dt
O.run( 2 * math.floor(duration),True)

timing.stats()

###saving for Restart
O.save('test.bz2')

Regards,
Roxana

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Karol Brzezinski (kbrzezinski) said :
#1

Hi Roxana,

Please note that this was discussed in this forum several times, and you can find more information on other topics (e.g., [1]).

Very briefly, I would summarise it in two points:
- First, parallelization efficiency depends on the simulation. If one person can paint the room in eight hours, it doesn't mean that 48 people would paint the room in ten minutes :)
- Secondly, the source code needs to be prepared for OpenMP parallelization. In Yade, it is usually realized by "#pragma omp parallel for" directive [2]. It tells the program where computations can be split in several threads without causing problems. It is usually used for long loops of independent operations (e.g. newtonIntegrator). So, if your engine does not have such a directive inside, your simulation will use one core most of the time.

Best wishes
Karol

[1] https://answers.launchpad.net/yade/+question/699458
[2] https://yade-dem.org/doc/prog.html#parallel-execution

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

Hello Roxana,
I have no real knowledge of how LiqControl works but maybe it's taking most of the time, and if it is not parallelized it would explain.
I see you enabled timing, would you paste the output of "timing.stats()" after many iterations? It would tell.
Bruno

Can you help with this problem?

Provide an answer of your own, or ask Roxana Saghafian Larijani for more information if necessary.

To post a message you must log in.