Skip to main content

A minimalistic Jupyter kernel for native code execution.

Project description

Minimal Native kernel for Jupyter

The goal of this kernel is to provide a unified frontend for working with native languages from jupyter.

It was started from the jupyter C kernel.

Usage:

C/C++

  • load to load a file to the cell
//%load https://passlab.github.io/CSCE569/resources/axpy.c
//%compiler: gcc
//%cflags: -fopenmp
//%ldflags: -lm
//%args: 1024
  • Set a different compiler, such as clang, using magic keyword //%compiler
//%compiler: clang
//%cflags: -fopenmp

#include <stdio.h>
#include <stdlib.h>
#include <omp.h>

int main (int argc, char** argv) {
    int i;
    #pragma omp parallel for num_threads(6)
    for (i = 0; i < 12; i++)
        printf("Thread: %d, i = %d\n", omp_get_thread_num(), i);
    
    return 0;
    
    
}

Fortran

The Jupyter kernel adds the magic keyword as a comment in the source code. Since the keywords for comment in C/C++ and Fortran are different, we need to specify the magic keywords for Jupyter kernel accordingly. In the following example of Fortran program, we must use the leading magic keyword !!% instead of //%.

!!%compiler: gfortran
!!%cflags: -fopenmp

PROGRAM Parallel_Hello_World
USE OMP_LIB

!$OMP PARALLEL

  PRINT *, "Hello from process: ", OMP_GET_THREAD_NUM()

!$OMP END PARALLEL

END

Setup

Works only on Linux and OS X. Windows is not supported yet. If you want to use this project on Windows, please use Docker.

Make sure you have the following requirements installed:

  • gcc
  • jupyter
  • python 3
  • pip

Install (virtualenv, pip)

This kernel has been uploaded to the official Python package repository. Instead of building from source code, it can be installed directly by pip as follows.

  1. virtualenv -p python3 venv
  2. source venv/bin/activate
  3. pip3 install jupyter-native-kernel
  4. install_native_kernel --user

Install (system)

This installs the kernel at the system level. (Not tested yet.)

  1. git clone <this repo>
  2. sudo pip3 install -e jupyter-native-kernel
  3. sudo install_native_kernel

To install on system folder, do sudo install_native_kernel --sys-prefix

Install (virtualenv)

This installs the kernel within the current virtualenv.

  1. git clone <this repo>
  2. virtualenv -p python3 venv
  3. source venv/bin/activate
  4. pip3 install -e jupyter-native-kernel
  5. install_native_kernel --user

License

This project is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_native_kernel-0.0.9.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyter_native_kernel-0.0.9-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_native_kernel-0.0.9.tar.gz.

File metadata

  • Download URL: jupyter_native_kernel-0.0.9.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.13

File hashes

Hashes for jupyter_native_kernel-0.0.9.tar.gz
Algorithm Hash digest
SHA256 d57757301b33e28b0ff6a3c09dd8fa4748dc6e6e7ae92cef09b695498e79af33
MD5 c2b41b58418a3e9ac60d53e2dfbefb2b
BLAKE2b-256 06b724d34f9b671811932435ae9926eee59eebe430d1fa4e217603615243d4db

See more details on using hashes here.

File details

Details for the file jupyter_native_kernel-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_native_kernel-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 f541585868aa26e28b0b27bbc5ebfb19b2bf7f8944d6bc5ada3f71f2a7b184d9
MD5 f4247f52e3bb9b272394b829fb38a8dc
BLAKE2b-256 b271674e4fad8e215eae2e4943384cdedde73b043a8394f5e31dd4476d1ab0b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page