HackMD
  • Prime
    Prime  Full-text search on all paid plans
    Search anywhere and reach everything in a Workspace with Prime plan.
    Got it
      • Create new note
      • Create a note from template
    • Prime  Full-text search on all paid plans
      Prime  Full-text search on all paid plans
      Search anywhere and reach everything in a Workspace with Prime plan.
      Got it
      • Options
      • Versions and GitHub Sync
      • Transfer ownership
      • Delete this note
      • Template
      • Save as template
      • Insert from template
      • Export
      • Dropbox
      • Google Drive
      • Gist
      • Import
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
      • Download
      • Markdown
      • HTML
      • Raw HTML
      • Sharing Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • More (Comment, Invitee)
      • Publishing
        Everyone on the web can find and read all notes of this public team.
        After the note is published, everyone on the web can find and read this note.
        See all published notes on profile page.
      • Commenting Enable
        Disabled Forbidden Owners Signed-in users Everyone
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Invitee
      • No invitee
    Menu Sharing Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Versions and GitHub Sync Transfer ownership Delete this note
    Export
    Dropbox Google Drive Gist
    Import
    Dropbox Google Drive Gist Clipboard
    Download
    Markdown HTML Raw HTML
    Back
    Sharing
    Sharing Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Note Permission
    Read
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    More (Comment, Invitee)
    Publishing
    Everyone on the web can find and read all notes of this public team.
    After the note is published, everyone on the web can find and read this note.
    See all published notes on profile page.
    More (Comment, Invitee)
    Commenting Enable
    Disabled Forbidden Owners Signed-in users Everyone
    Permission
    Owners
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Invitee
    No invitee
       owned this note    owned this note      
    Published Linked with GitHub
    Like BookmarkBookmarked
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # MPI Variants in conda-forge How are MPI variants best handled in conda-forge? There are a few broad cases: - package requires a specific MPI provider (easy!) - package works with any MPI provider (e.g. mpich, openmpi) - package works with/without MPI ## Building MPI variants: In `conda_build_config.yaml`: ```yaml mpi: - mpich - openmpi ``` In `meta.yaml`: ```yaml requirements: host: - {{ mpi }} ``` And rerender with: conda-smithy rerender -c auto to produce the build matrices. Current builds of both mpi providers have `run_exports` which is equivalent to adding: ```yaml requirements: run: - {{ pin_run_as_build(mpi, min_pin='x.x', max_pin='x.x') }} ``` If you want to do the pinning yourself (i.e. not trust the mpi providers, or pin differently, add): ``` # conda_build_config.yaml pin_run_as_build: mpich: x.x openmpi: x.x # meta.yaml requirements: host: - {{ mpi }} run: - {{ mpi }} ``` ## Including a no-mpi build Some packages (e.g. hdf5) may want a no-mpi build, in addition to the mpi builds. To do this, add `nompi` to the mpi matrix: ```yaml mpi: - nompi - mpich - openmpi ``` and apply the appropriate conditionals in your build: ```yaml requirements: host: - {{ mpi }} # [mpi != 'nompi'] run: - {{ mpi }} # [mpi != 'nompi'] ``` ### Preferring a provider (usually nompi) Up to here, mpi providers have no explicit preference. When choosing an MPI provider, the mutual-exclusivity of the `mpi` metapackage allows picking between mpi providers by installing an mpi provider, e.g. conda install mpich ptscotch or conda install openmpi ptscotch This doesn't extend to `nompi`, because there is no `nompi` variant of the mpi metapackage. And there probably shouldn't be, because some packages built with mpi doesn't preclude other packages in the env that *may* have an mpi variant from using the no-mpi variant of the library (e.g. for a long time, fenics used mpi with no-mpi hdf5 since there was no parallel hdf5 yet. This works fine, though some features may not be available). Typically, if there is a preference it will be packages with a nompi variant, where the serial build is preferred, such that installers/requirers of the package only get the mpi build if explicitly requested. <del> To de-prioritize a build in the solver, it can be given a special `track_features` field: - All builds *other than* the priority build should have a `track_features` field - Build strings can be used to allow downstream packages to make explicit dependencies. - No package should actually *have* the tracked feature. </del> **update:** track_features deprioritization has too high priority in the solver, preventing a package from adopting a variant of a dependency after some builds have already been made. Instead, use a build number offset to apply the preference at a more appropriate level. Here is an example build section: ```yaml {% if mpi == 'nompi' %} # prioritize nompi variant via build number {% set build = build + 100 %} {% endif %} build: number: {{ build }} # add build string so packages can depend on # mpi or nompi variants explicitly: # `pkg * mpi_mpich_*` for mpich # `pkg * mpi_*` for any mpi # `pkg * nompi_*` for no mpi {% if mpi != "nompi" %} {% set mpi_prefix = "mpi_" + mpi %} {% else %} {% set mpi_prefix = "nompi" %} {% endif %} string: "{{ mpi_prefix }}_h{{ PKG_HASH }}_{{ build }}" ``` ***Note:** `{{ PKG_HASH }}` avoids build string collisions on *most* variants, but not on packages that are excluded from the default build string, e.g. Python itself. If the package is built for multiple Python versions, use:* ```yaml string: "{{ mpi_prefix }}_py{{ py }}h{{ PKG_HASH }}_{{ build }}" ``` *as seen in [mpi4py](https://github.com/conda-forge/h5py-feedstock/pull/49/commits/b08ee9307d16864e775f1a7f9dd10f25c83b5974).* This build section creates the following packages: - `pkg-x.y.z-mpi_mpich_h12345_0` - `pkg-x.y.z-mpi_openmpi_h23456_0` - `pkg-x.y.z-nompi_h34567_100` Which has the following consequences: - The `nompi` variant is preferred, and will be installed by default unless an mpi variant is explicitly requested. - mpi variants can be explicitly requested with `pkg=*=mpi_{{ mpi }}_*` - any mpi variant, ignoring provider, can be requested with `pkg=*=mpi_*` - nompi variant can be explicitly requested with `pkg=*=nompi_*` If building with this library creates a runtime dependency on the variant, the build string pinning can be added to `run_exports`. For example, if building against the nompi variant will work with any installed version, but building with a given mpi provider requires running with that mpi: ```yaml build: ... {% if mpi != 'nompi' %} run_exports: - {{ name }} * {{ mpi_prefix }}_* {% endif %} ``` Remove the `if mpi...` condition if all variants should create a strict runtime dependency based on the variant chosen at build time (i.e. if the nompi build cannot be run against the mpich build). ## Complete example Combining all of the above, here is a complete recipe, with: - nompi, mpich, openmpi variants - run-exports to apply mpi choice made at build time to runtime where nompi builds can be run with mpi, but not vice versa. - nompi variant is preferred by default - only build nompi on Windows This matches what is done [in hdf5](https://github.com/conda-forge/hdf5-feedstock/pull/90). ```yaml # conda_build_config.yaml mpi: - nompi - mpich # [not win] - openmpi # [not win] ``` ```yaml # meta.yaml {% set name = 'pkg' %} {% set build = 1000 %} # ensure mpi is defined (needed for conda-smithy recipe-lint) {% set mpi = mpi or 'nompi' %} {% if mpi == 'nompi' %} # prioritize nompi variant via build number {% set build = build + 100 %} {% endif %} build: number: {{ build }} # add build string so packages can depend on # mpi or nompi variants explicitly: # `pkg * mpi_mpich_*` for mpich # `pkg * mpi_*` for any mpi # `pkg * nompi_*` for no mpi {% if mpi != 'nompi' %} {% set mpi_prefix = "mpi_" + mpi %} {% else %} {% set mpi_prefix = "nompi" %} {% endif %} string: "{{ mpi_prefix }}_h{{ PKG_HASH }}_{{ build }}" {% if mpi != 'nompi' %} run_exports: - {{ name }} * {{ mpi_prefix }}_* {% endif %} requirements: host: - {{ mpi }} # [mpi != 'nompi'] run: - {{ mpi }} # [mpi != 'nompi'] ``` And then a package that depends on this one can explicitly pick the appropriate mpi builds: ```yaml # meta.yaml requirements: host: - {{ mpi }} # [mpi != 'nompi'] - pkg - pkg * mpi_{{ mpi }}_* # [mpi != 'nompi'] run: - {{ mpi }} # [mpi != 'nompi'] - pkg * mpi_{{ mpi }}_* # [mpi != 'nompi'] ``` mpi-metapackage exclusivity allows `mpi_*` to resolve the same as `mpi_{{ mpi }}_*` if `{{ mpi }}` is also a direct dependency, though it's probably nicer to be explicit. ## Just mpi example Without a preferred `nompi` variant, recipes that require mpi are much simpler. This is all that is needed: ```yaml # conda_build_config.yaml mpi: - mpich - openmpi ``` ```yaml # meta.yaml requirements: host: - {{ mpi }} run: - {{ mpi }} ```

    Import from clipboard

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lost their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template is not available.


    Upgrade

    All
    • All
    • Team
    No template found.

    Create custom template


    Upgrade

    Delete template

    Do you really want to delete this template?

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in via Google

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Tutorials

    Book Mode Tutorial

    Slide Mode Tutorial

    YAML Metadata

    Contacts

    Facebook

    Twitter

    Feedback

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions

    Versions and GitHub Sync

    Sign in to link this note to GitHub Learn more
    This note is not linked with GitHub Learn more
     
    Add badge Pull Push GitHub Link Settings
    Upgrade now

    Version named by    

    More Less
    • Edit
    • Delete

    Note content is identical to the latest version.
    Compare with
      Choose a version
      No search result
      Version not found

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub

        Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

         Sign in to GitHub

        HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Available push count

        Upgrade

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Upgrade

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully