Skip to main content
Riya Bisht

Systems Research at Berkeley Lab

A systems research draft #

This summer I got an incredible opportunity to attend Berkeley Lab Computing Sciences Area program. During this time, I worked as an affiliate under Dr. Wim Lavrijsen(Systems Engineer at Berkeley Lab) as a part of Scientific Data Division(SDD) Lab. This post is intended to provide a summary or a brief overview of my systems research work at Berkeley Lab. A more detailed analysis will be posted soon with a link to the research poster.

Abstract #

Cppyy is an automatic Python-C++ bindings generator that leverages the Cling C++ interpreter to enable seamless interoperability between Python and C++. Recent developments have added initial support for Cppyy to interface with the Numba high-performance Python compiler, allowing Numba to compile Python looped code containing C++ objects and functions into efficient machine code. This research explores extending cppyy's Numba integration to enable CUDA compilation of the generated LLVM IR, allowing Python users to seamlessly mix Python with bound CUDA C++ in GPU kernels. This unique capability differentiates it from other approaches that provide access to CUDA from Python, as it enables the free mixing of Python and C++ code in GPU kernels without compromising performance.

Background info #

Cppyy enables practitioners to leverage the extensive functionalities provided by C++ libraries through a Python interface, allowing them to program in their preferred environment, whether that is Python or C++, regardless of the libraries and tooling that are optimal for their work. This makes cppyy a valuable tool across various domains. In scientific computing, for example, Cppyy facilitates efficient and accurate automatic Python bindings to C++ libraries.

LLVM + Python

LLVM + Python

This is highly beneficial, as performance-critical tasks are often implemented in C++, while Python is used for rapid prototyping and data analysis. By bridging the gap between these two languages, cppyy allows researchers to utilize the strengths of both in their workflows. Numba can JIT compile a subset of Python code into optimized machine code using the LLVM compiler library.

Research Questions #

Methodology #

Cppyy architecture

Cppyy- Python/C++ Binding Generator Architecture

Cling CUDA support in Cppyy

Cppyy Cling CUDA support

Cppyy-Numba workflow

Cppyy Numba(Python JIT Compiler) workflow

Results #

Few sample code snippets:

  1. Python bounded C++ code
cppyy.cppdef(‘’’
 float foo(float a){
	return std::fabs(a);
}
’’’)
  1. Python bounded C++ Device(that can run on GPUs) code
cppyy.cudadef(‘’’
 __device__ float foo(float a){
	return fabs(a);
}
‘’’)
  1. JITed python code runs on GPU
@cuda.jit()
def abs_kernel(x,out):
     pos = cuda.grid(1)
     if pos < x.size:
	out[pos] =cppyy.gbl.foo(x[pos])
 	

Conclusion #

The CUDA support in the Python ecosystem through Cppyy and Numba can help accelerate the research and development in Scientific Computing domains like Data analysis(ROOT), Machine Learning, and computational sciences like simulating genetic code, protein structures, etc that rely on both C++ and Python languages.

ROOT(Data Analysis Framework at CERN)

ROOT(CERN)

Challenges #

Future Scope #

References #

Acknowledgements #

A heartfelt thanks to all the mentors for their invaluable support throughout the project, including Dr. Wim Lavrijsen from LBL, Dr. Vassil Vassilev and Mr. Aaron Jomy from the Compiler Research Team affiliated with Princeton University and CERN.

Affiliations

Affiliations