Skip to content

Instantly share code, notes, and snippets.

@rcthomas
rcthomas / clone-jupyter-kernelspec.py
Last active April 22, 2022 17:07
Clone jupyter kernelspec from sys.prefix
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from pathlib import Path
import shutil
import sys
from textwrap import dedent
from jupyter_client.kernelspec import _list_kernels_in, jupyter_data_dir
def main():
path = Path(sys.prefix) / "share/jupyter/kernels"
@rcthomas
rcthomas / example-allocate-shared.py
Created August 10, 2017 19:40
Use mpi4py Win_Allocate_shared
from mpi4py import MPI
import numpy as np
world_comm = MPI.COMM_WORLD
node_comm = world_comm.Split_type(MPI.COMM_TYPE_SHARED)
size = 1000
disp_unit = MPI.DOUBLE.Get_size()
win = MPI.Win.Allocate_shared(size * disp_unit if node_comm.rank == 0 else 0,
disp_unit, comm = node_comm)