<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.anunna.wur.nl/index.php?action=history&amp;feed=atom&amp;title=Workflows%2FMulti-threaded</id>
	<title>Workflows/Multi-threaded - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.anunna.wur.nl/index.php?action=history&amp;feed=atom&amp;title=Workflows%2FMulti-threaded"/>
	<link rel="alternate" type="text/html" href="https://wiki.anunna.wur.nl/index.php?title=Workflows/Multi-threaded&amp;action=history"/>
	<updated>2026-08-09T12:10:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.anunna.wur.nl/index.php?title=Workflows/Multi-threaded&amp;diff=3025&amp;oldid=prev</id>
		<title>Honfi001: Fix links</title>
		<link rel="alternate" type="text/html" href="https://wiki.anunna.wur.nl/index.php?title=Workflows/Multi-threaded&amp;diff=3025&amp;oldid=prev"/>
		<updated>2026-08-05T08:02:57Z</updated>

		<summary type="html">&lt;p&gt;Fix links&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:02, 5 August 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Workflows/Serial&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-Workflows&lt;/del&gt;|Serial]] ran one program on one core. This page takes that same job and lets the program spread its work across &#039;&#039;&#039;many&#039;&#039;&#039; cores on the &#039;&#039;&#039;same&#039;&#039;&#039; machine — still one process, but now with several &#039;&#039;threads&#039;&#039; inside it, all sharing the same memory. It is the gentlest real step up the ladder, because for most tools someone else already did the hard part: the program already knows how to use extra cores. Your job is only to give it some, and to tell it how many.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Workflows/Serial|Serial]] ran one program on one core. This page takes that same job and lets the program spread its work across &#039;&#039;&#039;many&#039;&#039;&#039; cores on the &#039;&#039;&#039;same&#039;&#039;&#039; machine — still one process, but now with several &#039;&#039;threads&#039;&#039; inside it, all sharing the same memory. It is the gentlest real step up the ladder, because for most tools someone else already did the hard part: the program already knows how to use extra cores. Your job is only to give it some, and to tell it how many.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If you have read the serial page you already have the whole script. This one is that script with two lines touched — and seeing exactly which two is the point.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If you have read the serial page you already have the whole script. This one is that script with two lines touched — and seeing exactly which two is the point.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l11&quot;&gt;Line 11:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* It runs as a single program — not several cooperating copies, and not across more than one node.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* It runs as a single program — not several cooperating copies, and not across more than one node.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Plenty of everyday tools are built this way: read aligners, &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt;, and many of the numerical libraries underneath R and Python. If a tool has a threads option and you have been leaving it at its default of 1, this page is how you turn it up correctly on Anunna. If the program has no such option, it is [[Workflows/Serial&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-Workflows&lt;/del&gt;|serial]] — more cores will not help it, and you should go back one rung.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Plenty of everyday tools are built this way: read aligners, &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt;, and many of the numerical libraries underneath R and Python. If a tool has a threads option and you have been leaving it at its default of 1, this page is how you turn it up correctly on Anunna. If the program has no such option, it is [[Workflows/Serial|serial]] — more cores will not help it, and you should go back one rung.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== What it looks like on Anunna ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== What it looks like on Anunna ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l84&quot;&gt;Line 84:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 84:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Workflows/Parallel-Computing|Parallel Computing]] — the overview, and the map to the other workflow types.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Workflows/Parallel-Computing|Parallel Computing]] — the overview, and the map to the other workflow types.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Workflows/Serial&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-Workflows&lt;/del&gt;|Serial Workflows]] — the baseline this page starts from.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Workflows/Serial|Serial Workflows]] — the baseline this page starts from.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Workflows/Multi-Process-Workflows|Multi-Process Workflows]] — the next rung, for when one node is not enough.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Workflows/Multi-Process-Workflows|Multi-Process Workflows]] — the next rung, for when one node is not enough.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Tutorials/Parallelism-Estimating-Pi|Parallelism: Estimating π]] — its OpenMP rung is the worked example for this page.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Tutorials/Parallelism-Estimating-Pi|Parallelism: Estimating π]] — its OpenMP rung is the worked example for this page.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Compute Hardware Overview]] — how many cores a single node actually has.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Compute Hardware Overview]] — how many cores a single node actually has.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Honfi001</name></author>
	</entry>
	<entry>
		<id>https://wiki.anunna.wur.nl/index.php?title=Workflows/Multi-threaded&amp;diff=3020&amp;oldid=prev</id>
		<title>Honfi001: Created page with &quot;Serial ran one program on one core. This page takes that same job and lets the program spread its work across &#039;&#039;&#039;many&#039;&#039;&#039; cores on the &#039;&#039;&#039;same&#039;&#039;&#039; machine — still one process, but now with several &#039;&#039;threads&#039;&#039; inside it, all sharing the same memory. It is the gentlest real step up the ladder, because for most tools someone else already did the hard part: the program already knows how to use extra cores. Your job is only to give it some, and...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.anunna.wur.nl/index.php?title=Workflows/Multi-threaded&amp;diff=3020&amp;oldid=prev"/>
		<updated>2026-07-28T19:15:59Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/index.php?title=Workflows/Serial-Workflows&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Workflows/Serial-Workflows (page does not exist)&quot;&gt;Serial&lt;/a&gt; ran one program on one core. This page takes that same job and lets the program spread its work across &amp;#039;&amp;#039;&amp;#039;many&amp;#039;&amp;#039;&amp;#039; cores on the &amp;#039;&amp;#039;&amp;#039;same&amp;#039;&amp;#039;&amp;#039; machine — still one process, but now with several &amp;#039;&amp;#039;threads&amp;#039;&amp;#039; inside it, all sharing the same memory. It is the gentlest real step up the ladder, because for most tools someone else already did the hard part: the program already knows how to use extra cores. Your job is only to give it some, and...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Workflows/Serial-Workflows|Serial]] ran one program on one core. This page takes that same job and lets the program spread its work across &amp;#039;&amp;#039;&amp;#039;many&amp;#039;&amp;#039;&amp;#039; cores on the &amp;#039;&amp;#039;&amp;#039;same&amp;#039;&amp;#039;&amp;#039; machine — still one process, but now with several &amp;#039;&amp;#039;threads&amp;#039;&amp;#039; inside it, all sharing the same memory. It is the gentlest real step up the ladder, because for most tools someone else already did the hard part: the program already knows how to use extra cores. Your job is only to give it some, and to tell it how many.&lt;br /&gt;
&lt;br /&gt;
If you have read the serial page you already have the whole script. This one is that script with two lines touched — and seeing exactly which two is the point.&lt;br /&gt;
&lt;br /&gt;
== When this is you ==&lt;br /&gt;
&lt;br /&gt;
You are looking at a multi-threaded workflow when the program itself knows how to use more than one core, and says so:&lt;br /&gt;
&lt;br /&gt;
* Its manual offers a flag like &amp;lt;code&amp;gt;--threads 8&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-p 4&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;-@ 16&amp;lt;/code&amp;gt; — some way to hand it a number of cores.&lt;br /&gt;
* Or its documentation mentions &amp;#039;&amp;#039;&amp;#039;OpenMP&amp;#039;&amp;#039;&amp;#039;, and it responds to an &amp;lt;code&amp;gt;OMP_NUM_THREADS&amp;lt;/code&amp;gt; setting.&lt;br /&gt;
* It runs as a single program — not several cooperating copies, and not across more than one node.&lt;br /&gt;
&lt;br /&gt;
Plenty of everyday tools are built this way: read aligners, &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt;, and many of the numerical libraries underneath R and Python. If a tool has a threads option and you have been leaving it at its default of 1, this page is how you turn it up correctly on Anunna. If the program has no such option, it is [[Workflows/Serial-Workflows|serial]] — more cores will not help it, and you should go back one rung.&lt;br /&gt;
&lt;br /&gt;
== What it looks like on Anunna ==&lt;br /&gt;
&lt;br /&gt;
Everything from the serial job still holds: you never run the analysis on the login node, your work lives under &amp;lt;code&amp;gt;$myScratch&amp;lt;/code&amp;gt; on Lustre rather than in your home directory, and you describe the job in a script handed to &amp;lt;code&amp;gt;sbatch&amp;lt;/code&amp;gt;. Only two lines change.&lt;br /&gt;
&lt;br /&gt;
Start from the serial script, raise the core count, and keep &amp;#039;&amp;#039;&amp;#039;one&amp;#039;&amp;#039;&amp;#039; task:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH --job-name=my_analysis&lt;br /&gt;
#SBATCH --ntasks=1            # still ONE process ...&lt;br /&gt;
#SBATCH --cpus-per-task=16   # ... but now sixteen cores for it&lt;br /&gt;
#SBATCH --mem=4G             # unchanged: the threads share this memory&lt;br /&gt;
#SBATCH --time=01:00:00      # wall-clock limit; the job is killed past this&lt;br /&gt;
#SBATCH --output=%x-%j.out   # stdout + stderr, named by job name and id&lt;br /&gt;
&lt;br /&gt;
cd &amp;quot;$myScratch/my_analysis&amp;quot;&lt;br /&gt;
&lt;br /&gt;
module load 2024 Python/3.12.3       # replace with your actual module&lt;br /&gt;
&lt;br /&gt;
# Hand the core count Slurm gave you to the program:&lt;br /&gt;
export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
python myScript.py --input data.csv --output results.csv&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Against the serial script the difference is exactly two lines. &amp;lt;code&amp;gt;--cpus-per-task&amp;lt;/code&amp;gt; went from 1 to 16, and one new line was added just before the program runs. Three things did &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; change, and each is deliberate:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;--ntasks&amp;lt;/code&amp;gt; stayed at &amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039;. This is one process that grows more arms, not many processes — the distinction that separates this page from [[Workflows/Multi-Process-Workflows|Multi-Process]].&lt;br /&gt;
* &amp;lt;code&amp;gt;--mem&amp;lt;/code&amp;gt; stayed the same. The threads all read and write the &amp;#039;&amp;#039;same&amp;#039;&amp;#039; memory, so asking for more cores does not multiply your memory need the way separate processes would.&lt;br /&gt;
* Everything else — the module, the command, the scratch directory — is untouched.&lt;br /&gt;
&lt;br /&gt;
The one new line depends on how your tool takes its core count. An OpenMP program, like the one above, reads the &amp;lt;code&amp;gt;OMP_NUM_THREADS&amp;lt;/code&amp;gt; environment variable. A tool with its own flag takes the same number directly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
samtools sort --threads ${SLURM_CPUS_PER_TASK} -o sorted.bam input.bam&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Either way the rule is identical: whatever number you put in &amp;lt;code&amp;gt;--cpus-per-task&amp;lt;/code&amp;gt;, feed that same number to the program. Write &amp;lt;code&amp;gt;${SLURM_CPUS_PER_TASK}&amp;lt;/code&amp;gt; rather than hard-coding &amp;lt;code&amp;gt;16&amp;lt;/code&amp;gt; in two places — then changing the request is a one-line edit and the two can never drift apart.&lt;br /&gt;
&lt;br /&gt;
== The line that does the real work ==&lt;br /&gt;
&lt;br /&gt;
It is tempting to read &amp;lt;code&amp;gt;--cpus-per-task=16&amp;lt;/code&amp;gt; as the line that parallelised the job. It is not. That line only &amp;#039;&amp;#039;reserves&amp;#039;&amp;#039; sixteen cores; by itself it does exactly what it did for the serial program — fifteen of them sit idle with your name on them.&lt;br /&gt;
&lt;br /&gt;
The line that actually uses them is the one that passes the count to the program. Slurm sets the cores aside and exports the number as &amp;lt;code&amp;gt;SLURM_CPUS_PER_TASK&amp;lt;/code&amp;gt;, but it never tells your software they exist — you do. This is the single most common mistake on this rung: raise &amp;lt;code&amp;gt;--cpus-per-task&amp;lt;/code&amp;gt;, forget the hand-off line, and you get a serial run that merely wasted fifteen cores and a longer queue wait to boot.&lt;br /&gt;
&lt;br /&gt;
The [[Tutorials/Parallelism-Estimating-Pi|π tutorial]] makes you do this by hand: its OpenMP job ships with &amp;lt;code&amp;gt;OMP_NUM_THREADS=FIXME&amp;lt;/code&amp;gt;, and [[Tutorials/Parallelism-Estimating-Pi#Step 3: Fill in the two blanks|Step 3]] is filling in &amp;lt;code&amp;gt;${SLURM_CPUS_PER_TASK}&amp;lt;/code&amp;gt;. If you want the muscle memory for this page, that is where to get it.&lt;br /&gt;
&lt;br /&gt;
== What it buys you ==&lt;br /&gt;
&lt;br /&gt;
The tutorial runs the same ten-billion-dart π estimate at several thread counts on one node. The shape of the result is the whole lesson:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
variant   cores    wall_s&lt;br /&gt;
serial        1    26.008&lt;br /&gt;
omp           1    26.499&lt;br /&gt;
omp          16     1.663&lt;br /&gt;
omp         128     0.235&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One thread costs the serial time, as it should — same work, one core, plus a hair of overhead. Sixteen cores bring it down roughly sixteenfold; 128 cores by over a hundredfold. For this deliberately friendly problem the threads scale almost perfectly.&lt;br /&gt;
&lt;br /&gt;
Real tools rarely scale this cleanly. Some part of every program refuses to be split, and past a point extra threads stop helping — that is [https://en.wikipedia.org/wiki/Amdahl%27s_law Amdahl&amp;#039;s law], sketched as intuition on the [[Workflows/Parallel-Computing#Why not just ask for a thousand cores|overview]] and shown with the actual curves in the [[Tutorials/Parallelism-Estimating-Pi#Discussion|tutorial&amp;#039;s discussion]]. The practical habit that follows: try a few thread counts on &amp;#039;&amp;#039;your&amp;#039;&amp;#039; data and watch where the speedup flattens, rather than requesting a whole node by reflex.&lt;br /&gt;
&lt;br /&gt;
== The honest limitation ==&lt;br /&gt;
&lt;br /&gt;
Threads share memory, and shared memory means &amp;#039;&amp;#039;&amp;#039;one node&amp;#039;&amp;#039;&amp;#039;. Every thread must reach the same physical RAM, so a multi-threaded job cannot spill onto a second machine — its hard ceiling is the core count of a single node, and not one core beyond. Anunna&amp;#039;s nodes range from tens to hundreds of cores depending on generation (see [[Compute Hardware Overview]]); whichever node you land on, that number is your absolute maximum here.&lt;br /&gt;
&lt;br /&gt;
When a problem needs more than one node&amp;#039;s worth of cores, threads alone cannot take you there. That is the boundary where [[Workflows/Multi-Process-Workflows|multi-process (MPI)]] begins — many processes across many nodes — and where [[Workflows/Hybrid-Workflows|hybrid]] workflows combine the two. Do not reach for them early, though: one node of modern cores is a great deal of compute, and staying on a single node keeps your job script simple and your queue wait short. Climb to the next rung only once you have measured yourself hitting this one&amp;#039;s ceiling.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Workflows/Parallel-Computing|Parallel Computing]] — the overview, and the map to the other workflow types.&lt;br /&gt;
* [[Workflows/Serial-Workflows|Serial Workflows]] — the baseline this page starts from.&lt;br /&gt;
* [[Workflows/Multi-Process-Workflows|Multi-Process Workflows]] — the next rung, for when one node is not enough.&lt;br /&gt;
* [[Tutorials/Parallelism-Estimating-Pi|Parallelism: Estimating π]] — its OpenMP rung is the worked example for this page.&lt;br /&gt;
* [[Compute Hardware Overview]] — how many cores a single node actually has.&lt;/div&gt;</summary>
		<author><name>Honfi001</name></author>
	</entry>
</feed>