Skip to content

Commit

Permalink
Add initial compiler-research projects on InterOp and Clad (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronj0 authored Feb 7, 2025
1 parent c0330b0 commit 1d12a67
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
43 changes: 43 additions & 0 deletions _gsocproposals/2025/proposal_Clad-ImproveTape.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: Implement and improve an efficient, layered tape with prefetching capabilities
layout: gsoc_proposal
project: Clad
year: 2025
difficulty: medium
duration: 350
mentor_avail: June-October
organization:
- CompRes
---

## Description

In mathematics and computer algebra, automatic differentiation (AD) is a set of techniques to numerically evaluate the derivative of a function specified by a computer program. Automatic differentiation is an alternative technique to Symbolic differentiation and Numerical differentiation (the method of finite differences). Clad is based on Clang which provides the necessary facilities for code transformation. The AD library can differentiate non-trivial functions, to find a partial derivative for trivial cases and has good unit test coverage.

The most heavily used entity in AD is a stack-like data structure called a tape. For example, the first-in last-out access pattern, which naturally occurs in the storage of intermediate values for reverse mode AD, lends itself towards asynchronous storage. Asynchronous prefetching of values during the reverse pass allows checkpoints deeper in the stack to be stored furthest away in the memory hierarchy. Checkpointing provides a mechanism to parallelize segments of a function that can be executed on independent cores. Inserting checkpoints in these segments using separate tapes enables keeping the memory local and not sharing memory between cores. We will research techniques for local parallelization of the gradient reverse pass, and extend it to achieve better scalability and/or lower constant overheads on CPUs and potentially accelerators. We will evaluate techniques for efficient memory use, such as multi-level checkpointing support. Combining already developed techniques will allow executing gradient segments across different cores or in heterogeneous computing systems. These techniques must be robust and user-friendly, and minimize required application code and build system changes.

This project aims to improve the efficiency of the clad tape and generalize it into a tool-agnostic facility that could be used outside of clad as well.

## Expected Results

* Optimize the current tape by avoiding re-allocating on resize in favor of using connected slabs of array
* Enhance existing benchmarks demonstrating the efficiency of the new tape
* Add the tape thread safety
* Implement multilayer tape being stored in memory and on disk
* [Stretch goal] Support cpu-gpu transfer of the tape
* [Stretch goal] Add infrastructure to enable checkpointing offload to the new tape
* [Stretch goal] Performance benchmarks


## Requirements

* Automatic differentiation
* C++ programming
* Clang frontend

## Mentors
* **[Vassil Vassilev](mailto:[email protected])**
* [David Lange](mailto:[email protected])

## Links
* [Repo](https://github.com/vgvassilev/clad)
40 changes: 40 additions & 0 deletions _gsocproposals/2025/proposal_CppInterop-API-ExposeMemory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: Implement CppInterOp API exposing memory, ownership and thread safety information
layout: gsoc_proposal
project: Cppyy
year: 2025
difficulty: medium
duration: 350
mentor_avail: June-October
organization:
- CompRes
---

## Description

Incremental compilation pipelines process code chunk-by-chunk by building an ever-growing translation unit. Code is then lowered into the LLVM IR and subsequently run by the LLVM JIT. Such a pipeline allows creation of efficient interpreters. The interpreter enables interactive exploration and makes the C++ language more user friendly. The incremental compilation mode is used by the interactive C++ interpreter, Cling, initially developed to enable interactive high-energy physics analysis in a C++ environment.

Clang and LLVM provide access to C++ from other programming languages, but currently only exposes the declared public interfaces of such C++ code even when it has parsed implementation details directly. Both the high-level and the low-level program representation has enough information to capture and expose more of such details to improve language interoperability. Examples include details of memory management, ownership transfer, thread safety, externalized side-effects, etc. For example, if memory is allocated and returned, the caller needs to take ownership; if a function is pure, it can be elided; if a call provides access to a data member, it can be reduced to an address lookup. The goal of this project is to develop API for CppInterOp which are capable of extracting and exposing such information AST or from JIT-ed code and use it in cppyy (Python-C++ language bindings) as an exemplar. If time permits, extend the work to persistify this information across translation units and use it on code compiled with Clang.

## Project Milestones

* Collect and categorize possible exposed interop information kinds
* Write one or more facilities to extract necessary implementation details
* Design a language-independent interface to expose this information
* Integrate the work in clang-repl and Cling
* Implement and demonstrate its use in cppyy as an exemplar
* Present the work at the relevant meetings and conferences.

## Requirements

* C++ programming
* Python programming
* Knowledge of Clang and LLVM

## Mentors
* **[Vassil Vassilev](mailto:[email protected])**
* [Aaron Jomy](mailto:[email protected])
* [David Lange](mailto:[email protected])

## Links
* [Repo](https://github.com/compiler-research/CppInterOp)

0 comments on commit 1d12a67

Please sign in to comment.