# How to run a task using multiple cores

**URL:** <https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414>\
**Category:** PyLith\
**Created:** [May 13, 2022, 5:06pm UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414 "2022-05-13T17:06:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wang](https://avatars.discourse-cdn.com/v4/letter/w/edb3f5/32.png) [@Wang](https://community.geodynamics.org/u/Wang)\
**Post date:** [May 13, 2022, 5:06pm UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414/1 "2022-05-13T17:06:52Z")

</div>

Dear Pylith team,  
I try to run a task on multiple cores (my machine owns 32 cores) to speed up my simulation, but it happens some errors when i add the next words in pylithapp.cfg:  
[pylithapp]  
scheduler = pbs  
[pylithapp.launcher]  
command = mpirun -np ${nodes} -machinefile hosts  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/geodynamics/original/2X/2/2a1b98d97f4069d9cdcfc8960aaf04c1d1668ba2.png)  
Could you help me how to modify it so that it runs on multiple cores successfully， I’ve only seen one core being used when running the task.

Thanks for your help with this issue.

---

<div class="post-metadata">

**Author:** ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)\
**Post date:** [May 13, 2022, 5:22pm UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414/2 "2022-05-13T17:22:33Z")

</div>

The PBS (Portable Batch System) scheduler settings are for clusters that use the PBS batch queue system.

If you are running on a desktop machine without a batch queue system, simply use the command line argument `--nodes=NPROCS` where `NPROCS` is the number of processes. The parallel performance depends on the memory architecture; once the memory bus is saturated adding more processes will generally not reduce the runtime.

---

<div class="post-metadata">

**Author:** ![Wang](https://avatars.discourse-cdn.com/v4/letter/w/edb3f5/32.png) [@Wang](https://community.geodynamics.org/u/Wang)\
**Post date:** [May 14, 2022, 2:44pm UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414/3 "2022-05-14T14:44:29Z")

</div>

Dear Brad,

It works now. Thanks!

---

<div class="post-metadata">

**Author:** ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)\
**Post date:** [May 17, 2022, 3:37am UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414/4 "2022-05-17T03:37:08Z")

</div>

Split this topic on May 17, 2022, 3:37am UTC

A post was merged into an existing topic: [Single step elastic deformation with gravity](https://community.geodynamics.org/t/single-step-elastic-deformation-with-gravity/2128/20)

---

<div class="post-metadata">

**Author:** ![zhouyishuo](https://avatars.discourse-cdn.com/v4/letter/z/e274bd/32.png) [@zhouyishuo](https://community.geodynamics.org/u/zhouyishuo)\
**Post date:** [June 17, 2022, 1:22pm UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414/5 "2022-06-17T13:22:06Z")

</div>

Dear Pylith team,  
I have two problems:

1. I am running the code in Linux and use “-- Nodes” to speed it up.But I found it more slow；  
2.i find run the code in desktop is faster than orther disks,but my desktop storage is insufficient .  
Do you have any solution?

Thanks for your help with this issue.

---

<div class="post-metadata">

**Author:** ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)\
**Post date:** [June 17, 2022, 1:58pm UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414/6 "2022-06-17T13:58:05Z")

</div>

1. Finding the optimal number of processes when running in parallel to get maximum speedup depends on several factors, including your hardware (number of cores and memory architecture), the solver settings, and the type of problem). If you provide more information about the problem you are running, which version of PyLith you are using, any PETSc settings you are using, and the hardware you are using (processor type), we can provide more guidance.

2. Do you mean the hard disk storage is insufficient on your desktop or you have insufficient memory on your desktop? If the simulation is too large for your desktop, you can run PyLith on a cluster. In most cases, using multiple compute nodes on a cluster will provide more speedup than using additional processes on a desktop.

---

<div class="post-metadata">

**Author:** ![zhouyishuo](https://avatars.discourse-cdn.com/v4/letter/z/e274bd/32.png) [@zhouyishuo](https://community.geodynamics.org/u/zhouyishuo)\
**Post date:** [June 21, 2022, 5:28am UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414/7 "2022-06-21T05:28:40Z")

</div>

Dear Brad:  
1.I am using Pylith-v2.2.2, and my processor is 5950x, the PETSc setting is not changed when i run my code. In addition, I found the same issue when I run it on another machine or VMware Workstation.  
2.Due to insufficient desktop memory, I set the output path in the code to HDD (writer.filename=), and the linux system was installed on the SSD, which resulted in a much slower running speed.

---

<div class="post-metadata">

**Author:** ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)\
**Post date:** [June 21, 2022, 5:12pm UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414/8 "2022-06-21T17:12:30Z")

</div>

Please provide all of your parameter (.cfg) files that show which settings you are using. If you are not setting any PETSc solver options, then you should certainly be selection options that are more suitable for the type of problem you are running.

The AMD 5950x processor has 16 cores. With multithreading enabled it will look like it has 32 cores. The [AMD specs](https://www.amd.com/en/product/10456) don’t show the memory architecture, but my guess is that the memory bus gets saturated when you use more than about 4-6 cores.

---

<div class="post-metadata">

**Author:** ![zhouyishuo](https://avatars.discourse-cdn.com/v4/letter/z/e274bd/32.png) [@zhouyishuo](https://community.geodynamics.org/u/zhouyishuo)\
**Post date:** [June 24, 2022, 3:36am UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414/9 "2022-06-24T03:36:12Z")

</div>

Hi,Brad:  
my codes are here:  
[pylithapp]

# ----------------------------------------------------------------------

# journal

# ----------------------------------------------------------------------

[pylithapp.journal.info]  
timedependent = 1  
explicitlumped = 1  
explicitlumpedtet4 = 1  
petsc = 1  
meshiocubit = 1  
distributor = 1  
elasticityexplicit = 1  
elasticityexplicittet4 = 1  
meshimporter = 1  
#quadrature3d = 1  
#fiatlagrange = 1  
faultcohesivedyn = 1  
absorbingdampers = 1

[pylithapp.journal.debug]  
#pylithapp = 1  
#problem = 1  
#explicit = 1

# ----------------------------------------------------------------------

# mesh\_generator

# ----------------------------------------------------------------------

[pylithapp.mesh\_generator]  
reader = pylith.meshio.MeshIOCubit  
reorder\_mesh = True  
reader.filename = large200 2000.exo  
#refiner = pylith.topology.RefineUniform

#distributor.write\_partition = True  
#distributor.data\_writer = pylith.meshio.DataWriterHDF5Ext  
#distributor.data\_writer.filename = output/partition.h5

[pylithapp.mesh\_generator.reader]  
coordsys.space\_dim = 3

# ----------------------------------------------------------------------

# problem

# ----------------------------------------------------------------------

[pylithapp.timedependent]  
dimension = 3

elastic\_prestep = False  
formulation = pylith.problems.ExplicitTet4  
formulation.norm\_viscosity = 0.5  
normalizer = spatialdata.units.NondimElasticDynamic  
normalizer.shear\_wave\_speed = 3464_m/s  
normalizer.wave\_period = 0.01_s

[pylithapp.timedependent.formulation.time\_step]  
total\_time = 15_s  
dt = 0.003_s

# ----------------------------------------------------------------------

# materials

# ----------------------------------------------------------------------

[pylithapp.timedependent]  
materials = [elastic]  
materials.elastic = pylith.materials.ElasticIsotropic3D

[pylithapp.timedependent.materials.elastic]  
label = Elastic material  
id = 1

db\_properties = spatialdata.spatialdb.SimpleDB  
db\_properties.label = Elastic properties  
db\_properties.iohandler.filename = matprops.spatialdb  
db\_properties.query\_type = nearest

quadrature.cell = pylith.feassemble.FIATSimplex  
quadrature.cell.dimension = 3

# ----------------------------------------------------------------------

# boundary conditions

# ----------------------------------------------------------------------

[pylithapp.timedependent]  
bc = [x\_neg,x\_pos,y\_neg,y\_pos,z\_pos,z\_neg]  
bc.x\_neg = pylith.bc.AbsorbingDampers  
bc.x\_pos = pylith.bc.AbsorbingDampers  
bc.y\_neg = pylith.bc.AbsorbingDampers  
bc.y\_pos = pylith.bc.AbsorbingDampers  
bc.z\_neg = pylith.bc.AbsorbingDampers  
bc.z\_pos = pylith.bc.AbsorbingDampers

[pylithapp.timedependent.bc.x\_pos]  
label = face\_xpos  
db.label = Absorbing BC +x  
db.iohandler.filename = matprops.spatialdb  
quadrature.cell = pylith.feassemble.FIATSimplex  
quadrature.cell.dimension = 2  
quadrature.cell.quad\_order = 2

[pylithapp.timedependent.bc.x\_neg]  
label = face\_xneg  
db.label = Absorbing BC -x  
db.iohandler.filename = matprops.spatialdb  
quadrature.cell = pylith.feassemble.FIATSimplex  
quadrature.cell.dimension = 2  
quadrature.cell.quad\_order = 2

[pylithapp.timedependent.bc.y\_pos]  
label = face\_ypos  
db.label = Absorbing BC +y  
db.iohandler.filename = matprops.spatialdb  
quadrature.cell = pylith.feassemble.FIATSimplex  
quadrature.cell.dimension = 2  
quadrature.cell.quad\_order = 2

[pylithapp.timedependent.bc.y\_neg]  
label = face\_yneg  
db.label = Absorbing BC -y  
db.iohandler.filename = matprops.spatialdb  
quadrature.cell = pylith.feassemble.FIATSimplex  
quadrature.cell.dimension = 2  
quadrature.cell.quad\_order = 2

[pylithapp.timedependent.bc.z\_pos]  
label = face\_zpos  
db.label = Absorbing BC +z  
db.iohandler.filename = matprops.spatialdb  
quadrature.cell = pylith.feassemble.FIATSimplex  
quadrature.cell.dimension = 2  
quadrature.cell.quad\_order = 2  
up\_dir = [1, 1, 0]

[pylithapp.timedependent.bc.z\_neg]  
label = face\_zneg  
db.label = Absorbing BC -z  
db.iohandler.filename = matprops.spatialdb  
quadrature.cell = pylith.feassemble.FIATSimplex  
quadrature.cell.dimension = 2  
quadrature.cell.quad\_order = 2  
up\_dir = [1, 0, 0]

# ----------------------------------------------------------------------

# faults

# ----------------------------------------------------------------------

[pylithapp.timedependent]  
interfaces = [fault]  
interfaces.fault = pylith.faults.FaultCohesiveDyn

[pylithapp.timedependent.interfaces.fault]  
id = 10  
label = fault  
up\_dir = [0, 0, 1]  
friction = pylith.friction.SlipWeakening  
friction.label = Slip weakening  
zero\_tolerance = 1.0e-3  
zero\_tolerance\_normal = 1.0e-3

friction.db\_properties = spatialdata.spatialdb.SimpleDB  
friction.db\_properties.label = Slip weakening  
friction.db\_properties.query\_type = nearest  
friction.db\_properties.iohandler.filename = tpv16\_friction.spatialdb

traction\_perturbation = pylith.faults.TractPerturbation  
quadrature.cell = pylith.feassemble.FIATSimplex  
quadrature.cell.dimension = 2  
quadrature.cell.quad\_order = 2

[pylithapp.timedependent.interfaces.fault.traction\_perturbation]  
db\_initial = spatialdata.spatialdb.SimpleDB  
db\_initial.label = Initial fault tractions  
db\_initial.query\_type = nearest  
db\_initial.iohandler.filename = tpv16\_tractions.spatialdb

# fault – change

db\_change = spatialdata.spatialdb.SimpleDB  
db\_change.label = Amplitude of Initial traction\_perturbation on Nucleation  
db\_change.iohandler.filename = tractions\_axial\_pressure.spatialdb

# Use linear interpolation

db\_change.query\_type = nearest

th\_change = spatialdata.spatialdb.TimeHistory  
th\_change.label = Time history for Initial traction\_perturbation on Nucleation  
th\_change.filename = loadcycle.timedb

#output.cell\_info\_fields = [change\_in\_value,change\_start\_time]  
#output.writer.filename = output/step19-traction.vtk  
#output.cell\_filter = pylith.meshio.CellFilterAvg

# ----------------------------------------------------------------------

# output

# ----------------------------------------------------------------------

[pylithapp.timedependent.formulation]  
output = [domain]  
#output.subdomain = pylith.meshio.OutputSolnSubset

[pylithapp.problem.formulation.output.domain]

vertex\_data\_fields = [displacement,velocity]  
writer.time\_format = %06.0f  
writer.filename = output/tpv16\_hex8\_150m.vtk  
writer.time\_constant = 0.003\*s

#[pylithapp.problem.formulation.output.subdomain]  
#label = face\_zpos  
#vertex\_data\_fields=[displacement,velocity]

[pylithapp.timedependent.interfaces.fault.output]  
vertex\_info\_fields = [strike\_dir,normal\_dir,traction\_initial\_value,static\_coefficient,dynamic\_coefficient,slip\_weakening\_parameter,cohesion]  
vertex\_data\_fields = [slip,slip\_rate,traction]  
writer.time\_format = %06.0f  
writer.time\_constant = 0.003\*s  
writer.filename = output/tpv16\_hex8\_150m-fault.vtk

[pylithapp.timedependent.materials.elastic.output]  
cell\_data\_fields =   
cell\_filter = pylith.meshio.CellFilterAvg

writer.time\_format = %06.0f  
writer.time\_constant = 0.003\*s  
writer.filename = output/tpv16\_hex8\_150m-elastic.vtk

# ----------------------------------------------------------------------

# PETSc

# ----------------------------------------------------------------------

[pylithapp.petsc]  
petscpartitioner\_type = parmetis  
log\_summary = true

---

<div class="post-metadata">

**Author:** ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)\
**Post date:** [June 24, 2022, 2:19pm UTC](https://community.geodynamics.org/t/how-to-run-a-task-using-multiple-cores/2414/10 "2022-06-24T14:19:15Z")

</div>

It looks like you are running a problem with explicit time stepping. This should scale very well when running in parallel. In PyLith v2.x the mesh is loaded onto a single process, the faults created, and then the mesh is distributed. I recommend monitoring the memory use to make sure you have sufficient memory for these steps of the initialization. As mentioned previously, the speedup is generally controlled by the memory architecture. You can use the PETSc log summary to evaluate the different stages to find the best distribution strategy (number of processes) for your problem.
