<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Ali&#39;s Blog</title>
    <link rel="self" type="application/atom+xml" href="https://abzrgzdh.github.io/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://abzrgzdh.github.io"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-09-23T00:00:00+00:00</updated>
    <id>https://abzrgzdh.github.io/atom.xml</id>
    <entry xml:lang="en">
        <title>How to Practice CUDA Locally Without an NVIDIA GPU</title>
        <published>2026-07-14T00:00:00+00:00</published>
        <updated>2026-07-14T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://abzrgzdh.github.io/blog/cuda-without-nvidia-gpu/"/>
        <id>https://abzrgzdh.github.io/blog/cuda-without-nvidia-gpu/</id>
        
        <content type="html" xml:base="https://abzrgzdh.github.io/blog/cuda-without-nvidia-gpu/">&lt;p&gt;If you&#39;re learning CUDA without access to an NVIDIA GPU, you&#39;re no longer blocked.
Compiler Explorer can compile and even execute CUDA programs on remote hardware.
Just head over to &lt;a rel=&quot;external&quot; href=&quot;https://godbolt.org&quot;&gt;godbolt.org&lt;/a&gt;, choose a CUDA compiler, and you&#39;re ready to experiment.&lt;/p&gt;
&lt;p&gt;This post, however, aims to set up a local CLI development environment.
With it, you&#39;ll be able to code in the &lt;em&gt;comfort&lt;/em&gt; of your favorite terminal and editor.
&lt;label for=&quot;mn-mn-0&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-0&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; style=&quot;--note-offset: -1.5em&quot;&gt;
The only catch is that there&#39;s a few milliseconds of delay between when you run the command and get your outputs, due to the network latency.
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This setup is good for practicing CUDA syntax, checking that kernels and memory management compile correctly, and confirming small programs behave as expected, all without installing the CUDA toolkit or owning NVIDIA hardware.
It&#39;s &lt;em&gt;not&lt;/em&gt; a good fit for serious performance benchmarking, since you&#39;re sharing remote hardware and timing won&#39;t be reliable, or for large, stateful projects, since each run starts &lt;em&gt;fresh&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;To set this up locally, we&#39;ll use a small CLI that talks to Compiler Explorer and, if needed, a tool to flatten&lt;label for=&quot;sn-&quot; class=&quot;margin-toggle sidenote-number&quot;&gt;&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;sn-&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;sidenote&quot; &gt; Since Compiler Explorer receives a single source file, projects that rely on local headers need to be flattened first.&lt;/span&gt; multi-file projects into a single source file.
I picked &lt;a rel=&quot;external&quot; href=&quot;https://github.com/xfgusta/cexpl&quot;&gt;&lt;code&gt;cexpl&lt;/code&gt;&lt;/a&gt; and &lt;a rel=&quot;external&quot; href=&quot;https://github.com/Viatorus/quom&quot;&gt;&lt;code&gt;quom&lt;/code&gt;&lt;/a&gt;, respectively&lt;/p&gt;
&lt;p&gt;Set up a virtual environment and install &lt;code&gt;cexpl&lt;/code&gt;. If your project spans multiple files, install &lt;code&gt;quom&lt;/code&gt; as well.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; python -m venv venv&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; source venv/bin/activate&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; on Windows: venv\Scripts\activate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; pip install cexpl quom&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, write your CUDA code in a file, say &lt;code&gt;main.cu&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;cpp&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;cstdio&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;cuda_runtime.h&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;__global__&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; void&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; hello&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;    printf&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Hello from thread &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; threadIdx&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;x&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot; style=&quot;background-color: light-dark(#EAEEF280, #6E76811A);&quot;&gt;&lt;span&gt;    hello&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot; style=&quot;background-color: light-dark(#EAEEF280, #6E76811A);&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;    cudaDeviceSynchronize&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin-bottom: 0;&quot;&gt;
&lt;label for=&quot;mn-&quot; class=&quot;margin-toggle&quot;&gt;&amp;#8853;&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; style=&quot;--note-offset: -6.5em&quot;&gt;
This kernel just prints a message from 8 GPU threads.
Also, in practice you should check the return value of &lt;code&gt;cudaDeviceSynchronize&lt;/code&gt;.
&lt;/span&gt;
&lt;/p&gt;
&lt;hr style=&quot;border: none; margin: 0;&quot;&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;If your code includes local header files, make a combined file using &lt;code&gt;quom&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; quom main.cu combined.cu&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/blockquote&gt;
&lt;p&gt;Finally, compile and run it &lt;em&gt;remotely&lt;/em&gt; with&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; cexpl --exec --skip-asm --lang cuda main.cu&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;
&lt;label for=&quot;mn-mn-1&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-1&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; style=&quot;--note-offset: -3em&quot;&gt;
&lt;code&gt;--exec&lt;/code&gt; runs the compiled program, not just compile it;
&lt;code&gt;--skip-asm&lt;/code&gt; hides the generated assembly output, so you only see program results;
&lt;code&gt;--lang cuda&lt;/code&gt; tells Compiler Explorer to treat the file as CUDA code.
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;After a short delay, you should see something like:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;STDOUT:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;Hello from thread 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;Hello from thread 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;Hello from thread 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;Hello from thread 3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;Hello from thread 4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;Hello from thread 5&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;Hello from thread 6&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;Hello from thread 7&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That output was produced by an NVIDIA GPU running on Compiler Explorer&#39;s servers.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-important&quot;&gt;
&lt;p&gt;Keep in mind that the execution happens &lt;em&gt;in a fresh environment every run&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;&lt;code&gt;--exec&lt;/code&gt; can sometimes crash instead of showing errors. If your code has a compilation error, &lt;code&gt;cexpl --exec&lt;/code&gt; should normally print the compiler errors to stderr and stop there, but depending on your system or network, it sometimes crashes outright instead of showing you anything useful. If that happens, just drop &lt;code&gt;--exec&lt;/code&gt; and run:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; cexpl --skip-asm --lang cuda main.cu&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This only compiles the code and prints the compiler output, including any errors, without trying to execute it. Once your code compiles cleanly, add &lt;code&gt;--exec&lt;/code&gt; back to actually run it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;p&gt;That&#39;s all there is to it.
With that, you can practice and learn CUDA a bit more easily.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Build MPICH from source</title>
        <published>2026-07-03T00:00:00+00:00</published>
        <updated>2026-09-23T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://abzrgzdh.github.io/blog/build-mpich-from-source/"/>
        <id>https://abzrgzdh.github.io/blog/build-mpich-from-source/</id>
        
        <content type="html" xml:base="https://abzrgzdh.github.io/blog/build-mpich-from-source/">&lt;p&gt;MPICH&lt;label for=&quot;sn-sn-1&quot; class=&quot;margin-toggle sidenote-number&quot;&gt;&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;sn-sn-1&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;sidenote&quot; &gt;The CH part of the name was derived from &quot;Chameleon&quot;, which was a portable parallel programming library developed by William Gropp, one of the founders of MPICH. (&lt;a target=&quot;_blank&quot; href=https://en.wikipedia.org/wiki/MPICH#History&gt;wikipedia&lt;/a&gt;)&lt;/span&gt; is one of the most widely used MPI implementations.
Package managers often ship an old version, or one built without the options you need, so you might want to build it from source to meet the requirements of your project.
This guide covers that as well as setting up your shell so MPICH doesn&#39;t clash with other MPI installs like OpenMPI.&lt;/p&gt;
&lt;p&gt;The steps should be pretty much the same on Linux, macOS, and BSD. I&#39;ll call out the differences where they matter.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;You need a C compiler and &lt;code&gt;make&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Linux&lt;/strong&gt;: install the usual toolchain, e.g. &lt;code&gt;build-essential&lt;/code&gt; (Debian/Ubuntu).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;macOS&lt;/strong&gt;: run &lt;code&gt;xcode-select --install&lt;/code&gt; to get &lt;code&gt;clang&lt;/code&gt; and &lt;code&gt;make&lt;/code&gt;&lt;label for=&quot;sn-sn-2&quot; class=&quot;margin-toggle sidenote-number&quot;&gt;&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;sn-sn-2&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;sidenote&quot; &gt;I&#39;m not entirely sure, but I think xcode cli tools provide GNU make, so you should be fine.&lt;/span&gt;. Note &lt;code&gt;cc&lt;/code&gt; is &lt;code&gt;clang&lt;/code&gt; here, not GCC.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;BSD&lt;/strong&gt;: base &lt;code&gt;make&lt;/code&gt; is BSD make, not GNU make, which MPICH&#39;s build needs. Install GNU make (usually the &lt;code&gt;gmake&lt;/code&gt; package) and use &lt;code&gt;gmake&lt;/code&gt; instead of &lt;code&gt;make&lt;/code&gt; below.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;download-and-extract&quot;&gt;Download and extract&lt;/h2&gt;
&lt;p&gt;Grab the latest release tarball from the &lt;a rel=&quot;external&quot; href=&quot;https://www.mpich.org/downloads/&quot;&gt;MPICH downloads page&lt;/a&gt;, then extract it:
&lt;label for=&quot;mn-mn-2&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-2&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; &gt;You could also verify the checksum/signature provided on the &lt;a href=&quot;https://www.mpich.org/static/downloads/&quot;&gt;downloads index page&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; curl -LO https://www.mpich.org/static/downloads/4.2.3/mpich-4.2.3.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; tar -xzf mpich-4.2.3.tar.gz&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Don&amp;#39;t worry, it&amp;#39;s not a tarbomb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; cd mpich-4.2.3&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;
&lt;label for=&quot;mn-mn-2.5&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-2.5&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; style=&quot;--note-offset: -4.4em&quot;&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://en.wikipedia.org/wiki/Tar_(computing)#Tarbomb&quot; style=&quot;text-decoration: none;&quot;&gt;💣&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id=&quot;configure&quot;&gt;Configure&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; ./configure&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By default this installs to &lt;code&gt;/usr/local&lt;/code&gt;. To &lt;em&gt;keep&lt;/em&gt; MPICH separate from other MPI implementations, you could set a custom prefix:
&lt;label for=&quot;mn-mn-3&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-3&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; &gt;&lt;em&gt;Prefix&lt;/em&gt; is the base directory that everything gets installed into.&lt;/span&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; ./configure&lt;/span&gt;&lt;span&gt; --prefix&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;h&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;
&lt;label for=&quot;mn-mn-4&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-4&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; style=&quot;--note-offset: -3em&quot;&gt;The rest of this guide uses &lt;code&gt;/opt/mpich&lt;/code&gt; as prefix.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;You could add any other flags here. You could run &lt;code&gt;./configure --help&lt;/code&gt; to get a full list of all possible flags.
Here are some useful ones:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--enable-strict=all&lt;/code&gt; or slightly less pedantic &lt;code&gt;--enable-strict=most&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--disable-cxx&lt;/code&gt; / &lt;code&gt;--disable-fortran&lt;/code&gt;: skip C++ or Fortran bindings if you don&#39;t need them.&lt;/li&gt;
&lt;li&gt;For debug build:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--enable-g=most&lt;/code&gt;, which enables debugging, along with static analyzers, etc.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--enable-fast=O0&lt;/code&gt;. Even with the above debug flag being set, MPICH still uses the second level optimisation, i.e., &lt;code&gt;-O2&lt;/code&gt;, in compilation. with this we disable any kind of optimisation.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;For optimisation build:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--enable-g=none&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--enable-fast=all,O3&lt;/code&gt;, which drops debug instrumentation for a production build.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;CC=&lt;/code&gt;, &lt;code&gt;CXX=&lt;/code&gt;, &lt;code&gt;FC=&lt;/code&gt;: pick a specific compiler, e.g. &lt;code&gt;CC=gcc-13 ./configure ...&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote class=&quot;markdown-alert-tip&quot;&gt;
&lt;p&gt;Run &lt;code&gt;./configure --help&lt;/code&gt; for the full list of options and their description.
Additionally, read this document in the MPICH repo located at &lt;code&gt;:/doc/wiki/source_code/Building_MPICH_For_Development.md&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;markdown-alert-tip&quot;&gt;
&lt;p&gt;I usually install the debug and optimisation build in two separate directories of &lt;code&gt;/opt/mpich/{debug,opt}&lt;/code&gt;.
Then, I use shell functions to set the necessary environment variables to switch to each installation on demand.
Something similar to the following:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;mpich_debug&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    export&lt;/span&gt;&lt;span&gt; PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/opt/mpich/debug/bin:&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;mpich_opt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    export&lt;/span&gt;&lt;span&gt; PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/opt/mpich/opt/bin:&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/blockquote&gt;
&lt;h2 id=&quot;build&quot;&gt;Build&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; make &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;2&amp;gt;&amp;amp;1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; tee&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; log.make&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;
&lt;label for=&quot;mn-mn-5&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-5&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; style=&quot;--note-offset: -3em&quot;&gt;Use &lt;code&gt;gmake&lt;/code&gt; instead of &lt;code&gt;make&lt;/code&gt; on BSD.&lt;/span&gt;&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-tip&quot;&gt;
&lt;p&gt;Speed things up with &lt;code&gt;make -j$(nproc)&lt;/code&gt; on Linux or &lt;code&gt;make -j$(sysctl -n hw.ncpu)&lt;/code&gt; on macOS/BSD.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;install&quot;&gt;Install&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; sudo make install &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; tee&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; log.install&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;
&lt;label for=&quot;mn-mn-6&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-6&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; style=&quot;--note-offset: -3em&quot;&gt;You don&#39;t need to use &lt;code&gt;sudo&lt;/code&gt; if the current user owns the prefix directory.&lt;/span&gt;&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;You could skip &lt;code&gt;sudo&lt;/code&gt; entirely, by giving the user ownership over the prefix directory: &lt;code&gt;sudo mkdir -p /opt/mpich &amp;amp;&amp;amp; sudo chown $USER /opt/mpich&lt;/code&gt;; then you would re-run &lt;code&gt;make install&lt;/code&gt; without &lt;code&gt;sudo&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;verify&quot;&gt;Verify&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; /opt/mpich/bin/mpichversion&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;MPICH Version:      5.0.1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;MPICH Release date: Fri Apr 10 09:45:31 AM CDT 2026&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;MPICH ABI:          18:1:6&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;MPICH Device:       ch4:ofi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;MPICH configure:    --prefix=/opt/mpich&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;MPICH CC:           gcc   -fno-common   -O2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;MPICH CXX:          g++   -O2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;MPICH F77:          gfortran   -O2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;MPICH FC:           gfortran   -O2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;MPICH features:     threadcomm&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; /opt/mpich/bin/mpicc -show&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;gcc -I/opt/mpich/include -L/opt/mpich/lib -lmpi -lpmpi&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If both run cleanly, the install is good.&lt;/p&gt;
&lt;h2 id=&quot;add-it-to-your-shell&quot;&gt;Add it to your shell&lt;/h2&gt;
&lt;p&gt;The binaries aren&#39;t on your &lt;code&gt;PATH&lt;/code&gt; yet:
&lt;label for=&quot;mn-mn-7&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-7&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; &gt;&lt;code&gt;make install&lt;/code&gt; only copies stuff to the prefix directory; it does not tell the OS or the compilers where they could find MPICH binaries and libraries. We need to update certain shell environment variables so that the correct compiler is selected for execution and the correct library for linking.&lt;/span&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; export&lt;/span&gt;&lt;span&gt; PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/opt/mpich/bin:&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Putting it first ensures &lt;code&gt;mpicc&lt;/code&gt;/&lt;code&gt;mpirun&lt;/code&gt; resolve to this build, not another MPI implementation.&lt;/p&gt;
&lt;h3 id=&quot;why-not-just-add-this-to-our-shell-config&quot;&gt;Why not just add this to our shell config?&lt;/h3&gt;
&lt;p&gt;If you switch between MPI implementations often or use mostly an implementation other than MPICH, permanently prepending MPICH to &lt;code&gt;PATH&lt;/code&gt; means it silently wins every time, which can cause mismatches between the library your code was built against and the one &lt;code&gt;mpirun&lt;/code&gt; launches with.&lt;/p&gt;
&lt;p&gt;Instead, treat it like a Python virtual environment: activate it only when needed.
Create &lt;code&gt;/opt/mpich/activate.sh&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;MPICH_OLD_PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;export&lt;/span&gt;&lt;span&gt; PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/opt/mpich/bin:&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt; 3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;if&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; -n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;ZSH_VERSION&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; then&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt; 5&lt;/span&gt;&lt;span&gt;    MPICH_OLD_PROMPT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;PROMPT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt; 6&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    export&lt;/span&gt;&lt;span&gt; PROMPT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;(mpich) &lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;PROMPT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt; 7&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;else&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt; 8&lt;/span&gt;&lt;span&gt;    MPICH_OLD_PROMPT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;PS1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt; 9&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    export&lt;/span&gt;&lt;span&gt; PS1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;(mpich) &lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;PS1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;fi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;11&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;deactivate_mpich&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    export&lt;/span&gt;&lt;span&gt; PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;MPICH_OLD_PATH&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;14&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot; style=&quot;background-color: light-dark(#EAEEF280, #6E76811A);&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; -n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;ZSH_VERSION&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt; ]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; then&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot; style=&quot;background-color: light-dark(#EAEEF280, #6E76811A);&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        export&lt;/span&gt;&lt;span&gt; PROMPT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;MPICH_OLD_PROMPT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;17&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    else&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot; style=&quot;background-color: light-dark(#EAEEF280, #6E76811A);&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        export&lt;/span&gt;&lt;span&gt; PS1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;MPICH_OLD_PROMPT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;19&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    fi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;20&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;21&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    unset&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; MPICH_OLD_PATH&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;22&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    unset&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; MPICH_OLD_PROMPT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;23&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    unset&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; deactivate_mpich&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;giallo-ln&quot; style=&quot;color: light-dark(#8C959F, #6E7681);&quot;&gt;24&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;
&lt;label for=&quot;mn-mn-8&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-8&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; style=&quot;--note-offset: -14em&quot;&gt;zsh uses &lt;code&gt;PROMPT&lt;/code&gt;, bash uses &lt;code&gt;PS1&lt;/code&gt;; the script checks &lt;code&gt;$ZSH_VERSION&lt;/code&gt; to set the right one. You could adapt it if you use fish or any other non-POSIX shells.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Activate it in any shell session with:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot; style=&quot;background-color: light-dark(#EAEEF280, #6E76811A);&quot;&gt;&lt;span&gt;$ source /opt/mpich/activate.sh&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(mpich) $ type -a mpicc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mpicc is /opt/mpich/bin/mpicc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mpicc is /opt/homebrew/bin/mpicc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot; style=&quot;background-color: light-dark(#EAEEF280, #6E76811A);&quot;&gt;&lt;span&gt;(mpich) $ deactivate_mpich&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ type -a mpicc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mpicc is /opt/homebrew/bin/mpicc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;
&lt;label for=&quot;mn-mn-9&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-9&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; style=&quot;--note-offset: -10.3em&quot;&gt;If that&#39;s too much typing, you could add an alias to your config, like &lt;code&gt;mpich5&lt;/code&gt;.&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;label for=&quot;mn-mn-10&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-10&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; style=&quot;--note-offset: -5.3em&quot;&gt;&lt;code&gt;deactivate_mpich&lt;/code&gt; restores &lt;code&gt;PATH&lt;/code&gt; and the prompt to how they were before.&lt;/span&gt;&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Delete All GitHub Actions Workflow Runs Using GitHub CLI</title>
        <published>2026-06-26T00:00:00+00:00</published>
        <updated>2026-06-26T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://abzrgzdh.github.io/blog/delete-all-github-action-workflow-runs/"/>
        <id>https://abzrgzdh.github.io/blog/delete-all-github-action-workflow-runs/</id>
        
        <content type="html" xml:base="https://abzrgzdh.github.io/blog/delete-all-github-action-workflow-runs/">&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;TLDR: Here&#39;s the one-liner if you&#39;re here to just copy it.&lt;/p&gt;
&lt;div class=&quot;fullwidth&quot;&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; gh run list --all --limit 40 --json databaseId &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; jq&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.[].databaseId&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; xargs&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;n1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; gh&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; run&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; delete&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;blockquote class=&quot;markdown-alert-caution&quot;&gt;
&lt;p&gt;Change the limit, 40, to the actual number of actions present in your repository.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;p&gt;If you&#39;ve ever accumulated hundreds (or thousands) of GitHub Actions workflow runs, you&#39;ve probably wondered how to clean them all up.&lt;/p&gt;
&lt;p&gt;To my knowledge, GitHub&#39;s web interface provides no interface for this purpose.
Unfortunately, there isn&#39;t also an obvious builtin GitHub CLI command, like &lt;code&gt;gh run delete --all&lt;/code&gt;, that deletes every workflow run in a repository.
At best, the &lt;code&gt;gh run delete &amp;lt;run-id&amp;gt;&lt;/code&gt; only deletes one workflow run as this command only accepts one argument (or none for an interactive selection before deletion).&lt;/p&gt;
&lt;p&gt;If we could find a way to get a list of all runs, we then could wind up a for loop or pipe it to xargs to have them deleted programmatically.
For that, the following command&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; gh run list&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;lists workflow runs in your repository.
By default, it only returns 20 workflow runs.
We can pass an extra &lt;code&gt;--limit &amp;lt;int&amp;gt;&lt;/code&gt; flag to tell it list more.
&lt;label for=&quot;mn-mn-1&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-1&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; &gt;
You can check how many workflow runs exist by visiting the &lt;em&gt;Actions&lt;/em&gt; tab of your GitHub repository in your browser.
&lt;/span&gt;
Additionally, we have pass &lt;code&gt;--all&lt;/code&gt; (or &lt;code&gt;-a&lt;/code&gt;) to include disabled workflows.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; gh run list --all --limit 100&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, we need to extract the id&#39;s from the output, but the output format is in a human-readable/friendly way.
In other words, there&#39;s no fixed format so that we could parse it with &lt;code&gt;awk&lt;/code&gt;, for instance.
Luckily, there&#39;s a &lt;code&gt;--json&lt;/code&gt; flag that you can use to request only the fields/columns you need.
To see the list of correct field names, run&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; gh run list --json&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;it will show use the various column names.
Among them exists the &lt;code&gt;databaseId&lt;/code&gt;, which is what we want.
Issuing the following gives us a JSON output: a list of objects with only &lt;code&gt;databaseId&lt;/code&gt; as key.
&lt;label for=&quot;mn-mn-2&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-2&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; &gt;
Simply add more &lt;code&gt;--json&lt;field&gt;&lt;/code&gt; pairs to get more columns of data.
&lt;/span&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; gh run list --json databaseId&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    &amp;quot;databaseId&amp;quot;: 1234567890&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    &amp;quot;databaseId&amp;quot;: 1234567891&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we need to turn that JSON into a plain list of IDs.
The easiest tool to pipe the JSON output into &lt;a rel=&quot;external&quot; href=&quot;https://jqlang.org/&quot;&gt;&lt;code&gt;jq&lt;/code&gt;&lt;/a&gt;.
&lt;label for=&quot;mn-mn-3&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-3&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; &gt;
&lt;code&gt;.&lt;/code&gt; refers to the root JSON value;
&lt;code&gt;[]&lt;/code&gt; iterates over every element in the array; and
&lt;code&gt;.databaseId&lt;/code&gt; selects the &lt;code&gt;databaseId&lt;/code&gt; property from each object.
&lt;/span&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; gh run list --json databaseId &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; jq&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.[].databaseId&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1234567890&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1234567891&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1234567892&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we can go ahead and pipe the ids to &lt;code&gt;xargs&lt;/code&gt; to get deleted one-by-one.
&lt;label for=&quot;mn-mn-4&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-4&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; &gt;
The &lt;code&gt;-n1&lt;/code&gt; option tells &lt;code&gt;xargs&lt;/code&gt; to invoke &lt;code&gt;gh run delete&lt;/code&gt; once for each input line.
&lt;/span&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; gh run list --json databaseId &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; jq&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.[].databaseId&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; xargs&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;n1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; gh&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; run&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; delete&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;✓ Request to delete workflow run submitted.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;✓ Request to delete workflow run submitted.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;✓ Request to delete workflow run submitted.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is yet another example of how powerful Unix philosophy can be.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>X86-64 Assembly on ARM64 Mac</title>
        <published>2025-05-02T00:00:00+00:00</published>
        <updated>2025-05-02T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://abzrgzdh.github.io/blog/x64-assembly-apple-macs/"/>
        <id>https://abzrgzdh.github.io/blog/x64-assembly-apple-macs/</id>
        
        <content type="html" xml:base="https://abzrgzdh.github.io/blog/x64-assembly-apple-macs/">&lt;p&gt;If you&#39;re looking for a way to code and execute x86-64 programs on ARM64 macs, this tutorial is for you.
Through &lt;a rel=&quot;external&quot; href=&quot;https://support.apple.com/en-us/102527&quot;&gt;Rosetta 2&lt;/a&gt;, it is possible to compile and link C and x86-64  assembly programs into x86-64 binary and run it as if it were an ARM64 binary.&lt;label for=&quot;sn-sn-1&quot; class=&quot;margin-toggle sidenote-number&quot;&gt;&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;sn-sn-1&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;sidenote&quot; &gt;It even &lt;a href=&quot;https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment#Learn-what-Rosetta-cant-translate&quot;&gt;translates&lt;/a&gt; AVX and AVX2 instruction, but not AVX512.&lt;/span&gt;
Here, I&#39;ll demonstrate how to write assembly code and call it from a C code.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;The entire process is really simple.&lt;/p&gt;
&lt;p&gt;Write your assembly code in a &lt;code&gt;.s&lt;/code&gt; file.
Within it expose&lt;label for=&quot;sn-sn-2&quot; class=&quot;margin-toggle sidenote-number&quot;&gt;&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;sn-sn-2&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;sidenote&quot; &gt;
By &lt;em&gt;exposing&lt;/em&gt; or marking it as &lt;em&gt;global&lt;/em&gt;, I mean making it visible to the linker across translation units.
&lt;/span&gt; a symbol that you later on want to call in a C file.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  .text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  .globl _my_func&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;_my_func&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this particular example, we made the &lt;code&gt;_my_func&lt;/code&gt; symbol visible to the linker.&lt;/p&gt;
&lt;p&gt;Then, to compile the C code, before even linking it against the assembly code, we declare the corresponding function with leading underscore removed.&lt;!----&gt;
&lt;label for=&quot;mn-mn-1&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-1&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; &gt; Note the exposed symbol &lt;code&gt;_add_arrays&lt;/code&gt;, which matches a C function with name &lt;code&gt;add_arrays&lt;/code&gt;. This convention is part of MacOS&#39;s x86-64 ABI.&lt;/span&gt;
&lt;label for=&quot;mn-mn-2&quot; class=&quot;margin-toggle&quot;&gt;⊕&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;mn-mn-2&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;marginnote&quot; &gt;
Note also that you don&#39;t have to specify the &lt;code&gt;extern&lt;/code&gt; keyword before the function prototype since functions in C have external linkage by default.
However, for readability&#39;s sake, I like to keep it there to indicate the function is defined in an assembly file.
&lt;/span&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ~~~&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;extern&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span&gt;return_type&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; my_func&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;params&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ~~~&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;void&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we compile the whole thing by passing both C and assembly files to the compiler as well as the &lt;code&gt;-target x86_64-apple-macos&lt;/code&gt; flag.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; cc -target x86_64-apple-macos main.c my_func.s&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;C Compilers are able to do cross-compilation and produce binaries that target a specific architecture and ABI.
In this case, by passing this flag, we essentially tell it to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;assemble into x86-64 instructions&lt;/li&gt;
&lt;li&gt;an in doing so use Mac&#39;s x86-64 ABI and Mach-o binary file format.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;example-adding-integer-arrays-with-simd-operations&quot;&gt;Example: Adding Integer Arrays with SIMD Operations&lt;/h2&gt;
&lt;p&gt;To make this a bit concrete, let&#39;s go through a simple example of adding two arrays using &lt;a rel=&quot;external&quot; href=&quot;https://www.google.com/search?q=sse+instructions&amp;amp;oq=sse+instructions&amp;amp;sourceid=chrome&amp;amp;ie=UTF-8&quot;&gt;SSE instructions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here&#39;s the assembly code.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;# file: add_simd.s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;.text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.globl&lt;/span&gt;&lt;span&gt; _add_arrays&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;# void add_arrays(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#     const int *a,   rdi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#     const int *b,   rsi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#     int *res,       rdx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#     int n           rcx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;# )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;_add_arrays&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    xorq %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;r8&lt;/span&gt;&lt;span&gt;, %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;r8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;loop&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    cmpq %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;rcx&lt;/span&gt;&lt;span&gt;, %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;r8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    jge&lt;/span&gt;&lt;span&gt; .done&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    # Load four integers from `a` (%rdi)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    movdqu&lt;/span&gt;&lt;span&gt; (%&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;rdi&lt;/span&gt;&lt;span&gt;,%&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;r8&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;4&lt;/span&gt;&lt;span&gt;), %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;xmm0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    # Load four integers from `b` (%rsi)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    movdqu&lt;/span&gt;&lt;span&gt; (%&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;rsi&lt;/span&gt;&lt;span&gt;,%&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;r8&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;4&lt;/span&gt;&lt;span&gt;), %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;xmm1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    # Add four integers in parallel&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    paddd&lt;/span&gt;&lt;span&gt; %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;xmm1&lt;/span&gt;&lt;span&gt;, %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;xmm0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    # Store the result&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    movdqu&lt;/span&gt;&lt;span&gt; %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;xmm0&lt;/span&gt;&lt;span&gt;, (%&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;rdx&lt;/span&gt;&lt;span&gt;,%&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;r8&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;4&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    addq &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;$4&lt;/span&gt;&lt;span&gt;, %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;r8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    jmp&lt;/span&gt;&lt;span&gt; .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;loop&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;done&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    ret&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote class=&quot;markdown-alert-caution&quot;&gt;
&lt;p&gt;Here, we&#39;re assuming &lt;code&gt;n&lt;/code&gt; is a multiple of 4.
Ideally, we would need to handle remaining elements if &lt;code&gt;n&lt;/code&gt; weren&#39;t divisible by 4.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In the C code, we declare the &lt;code&gt;add_arrays&lt;/code&gt; function at the top of the file.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; file: main.c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;stdio.h&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;stdint.h&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;extern&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; void&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; add_arrays&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;a&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;b&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;res&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; n&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;void&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    int&lt;/span&gt;&lt;span&gt; a&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 3&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 4&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 5&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 6&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 7&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 8&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    int&lt;/span&gt;&lt;span&gt; b&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;10&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 20&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 30&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 40&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 50&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 60&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 70&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 80&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; res&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;8&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;    add_arrays&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;a&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; b&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; res&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 8&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    for&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;int&lt;/span&gt;&lt;span&gt; i &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; i &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 8&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; i&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;++&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;        printf&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; res&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;i&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;    printf&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, to compile and check the file format&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; clang -target x86_64-apple-macos main.c add_simd.s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; file a.out&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;a.out: Mach-O 64-bit executable x86_64&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Running it should gives us:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt; ./a.out&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;11 22 33 44 55 66 77 88&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
        
    </entry>
    <entry xml:lang="en">
        <title>First Post</title>
        <published>2025-03-08T00:00:00+00:00</published>
        <updated>2025-03-08T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://abzrgzdh.github.io/blog/first-post/"/>
        <id>https://abzrgzdh.github.io/blog/first-post/</id>
        
        <content type="html" xml:base="https://abzrgzdh.github.io/blog/first-post/">&lt;h2 id=&quot;epigraphs&quot;&gt;Epigraphs&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;The first principle is that you must not fool yourself — and you are the easiest person to fool.&lt;/p&gt;
&lt;footer&gt;
Richard Feynman
&lt;/footer&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;It is a capital mistake to theorize before one has data.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;I have made this longer than usual because I have not had time to make it shorter.&lt;/p&gt;
&lt;footer&gt;
Blaise Pascal
, 
Lettres Provinciales
&lt;/footer&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;quotes&quot;&gt;Quotes&lt;/h2&gt;
 &lt;blockquote&gt;
   &lt;p&gt;
Graphical excellence is the well-designed presentation of interesting data.
&lt;/p&gt;
   &lt;footer&gt;
     Edward Tufte
     , 
     &lt;cite&gt;The Visual Display of Quantitative Information
   &lt;/footer&gt;
 &lt;/blockquote&gt;
&lt;p&gt;This is exactly what Orwell had in mind when he wrote:&lt;/p&gt;
 &lt;blockquote&gt;
   &lt;p&gt;
Never use a long word where a short one will do.
&lt;/p&gt;
   &lt;footer&gt;
     George Orwell
     , 
     &lt;cite&gt;Politics and the English Language
   &lt;/footer&gt;
 &lt;/blockquote&gt;
&lt;p&gt;And that principle applies equally to code.&lt;/p&gt;
&lt;h2 id=&quot;side-notes-and-margin-notes&quot;&gt;Side notes and margin notes&lt;/h2&gt;
&lt;p&gt;This is the &lt;code&gt;simd&lt;/code&gt; first post.&lt;label for=&quot;sn-sn-1&quot; class=&quot;margin-toggle sidenote-number&quot;&gt;&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;sn-sn-1&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;sidenote&quot; &gt;You can use all your shortcodes here too.&lt;/span&gt;&lt;/p&gt;
&lt;h2 id=&quot;full-width&quot;&gt;Full-width&lt;/h2&gt;
&lt;p&gt;Normal code that does not overflow the text width.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;cpp&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;void&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;  std&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;cout&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Hello, World&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Full width code that does overflow.&lt;/p&gt;
&lt;div class=&quot;fullwidth&quot;&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; a wide block that needs more horizontal space&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;result&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; some_very_long_function_name&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;argument_one&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; argument_two&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; argument_three&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;alert-environments&quot;&gt;Alert environments&lt;/h2&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;This is a note with some additional context.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;markdown-alert-tip&quot;&gt;
&lt;p&gt;A helpful tip for the reader.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;markdown-alert-important&quot;&gt;
&lt;p&gt;Something the reader really should not miss.
This is the &lt;code&gt;simd&lt;/code&gt; first post.&lt;label for=&quot;sn-sn-2&quot; class=&quot;margin-toggle sidenote-number&quot;&gt;&lt;/label&gt;
&lt;input type=&quot;checkbox&quot; id=&quot;sn-sn-2&quot; class=&quot;margin-toggle&quot;/&gt;
&lt;span class=&quot;sidenote&quot; &gt;side note in alert/quote.&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;markdown-alert-warning&quot;&gt;
&lt;p&gt;A warning about potential pitfalls.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;markdown-alert-caution&quot;&gt;
&lt;p&gt;A strong caution about destructive or irreversible actions.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;math-support&quot;&gt;Math support&lt;/h2&gt;
&lt;p&gt;Various ways to write math $x$:&lt;/p&gt;
&lt;p&gt;$$
x^2
\frac{1}{x}
12\,\rm{m}^2
$$&lt;/p&gt;
&lt;p&gt;Inline math:
&lt;span class=&quot;math&quot;&gt;\(\frac{1}{2}\)&lt;/span&gt;
\(\frac34\)&lt;/p&gt;
&lt;p&gt;Display math:&lt;/p&gt;
&lt;div class=&quot;math-display&quot;&gt;\[
\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
12\,\rm{m}^2
\]&lt;/div&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;div class=&quot;math-display&quot;&gt;\[
x^2
\frac{1}{x}
12\,\rm{m}^2
\]&lt;/div&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;div class=&quot;math-display&quot;&gt;\[\int_0^\infty...\]&lt;/div&gt;
</content>
        
    </entry>
</feed>
