Skip to content

Add Intel SHMEM Python Bindings#18

Draft
BenBrock wants to merge 8 commits intooneapi-src:mainfrom
BenBrock:ishmem4py-mvp
Draft

Add Intel SHMEM Python Bindings#18
BenBrock wants to merge 8 commits intooneapi-src:mainfrom
BenBrock:ishmem4py-mvp

Conversation

@BenBrock
Copy link

Summary

This is a draft PR for an initial in-tree ishmem4py implementation. If Python bindings are enabled with -DBUILD_PYTHON_BINDINGS=ON, it will build a small shared object shim layer. The built Python package can then be installed from the build directory.

This draft currently only has basic functionality

  • CPU-initiated communication
  • basic init/finalize APIs
  • shmem_malloc / shmem_free
  • putmem / getmem
  • simple examples and smoke tests

Architecture

The binding layer is built around a small in-tree runtime shim, _ishmem4py_runtime.so, rather than trying to bind directly to a stock Intel SHMEM install. If Intel SHMEM later adds a shared library build, we would likely use that directly.

The shim:

  • is built as part of the normal ishmem CMake build
  • links against ishmem-static
  • exposes a stable extern "C" ABI for Python
  • keeps the Python layer isolated from Intel SHMEM’s C++/template-heavy public interface

On the Python side, ishmem4py is currently a thin ctypes wrapper over that shim. For standard installs, the built runtime .so is bundled into the Python package; for editable/dev installs, the runtime can be overridden with ISHMEM4PY_RUNTIME_LIBRARY.

Building the bindings

The build should be performed as described in README.md, with the -DBUILD_PYTHON_BINDINGS=ON added. On my Ubuntu 24.04 system, I also needed -DENABLE_AOT_COMPILATION=OFF due to an outdated intel-ocloc package.

Then, it's usually easiest to install the Python package inside a conda environment. I also show the torch+xpu package install below. This is not strictly necessary, but the bindings will likely integrate with torch in the future.

conda create -n ishmem4py python=3.11 pip setuptools wheel

conda activate ishmem4py

# Recommended: install torch+xpu
python -m pip install torch --no-deps --index-url https://download.pytorch.org/whl/xpu

# Install the ishmem4py Python package built as part of Intel SHMEM.
python -m pip install --no-build-isolation $HOME/pkg/ishmem-2026-03-11-src/build/ishmem4py/python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant