Clang UPC pointer to shared in LLVM IR
The goal of this project is to allow UPC pointers-to-shared (or some other remote pointer) to be expressed in the LLVM IR and to in turn gain the benefits of LLVM optimizations that operate on memory references.
Clang UPC IR uses the following approach:
- A Remote Pointer consisting of a thread number and offset in the thread’s shared address space is defined. It is represented by the regular LLVM 64 bit pointer with 20 bits allocated for the thread number by default (configurable). The rest (44 bits) of the pointer is allocated for the thread’s shared address space offset.
- The LLVM assembly language (IR) has no knowledge of the UPC language and its semantics (shared variables, shared array layout, ,,,). Instead, UPC pointer-to-shared accesses (put,get) are converted into the IR accesses (store,load) with the Remote Pointer being the target of the access.
- Special address space (15 by default) is used to label all IR accesses that use Remote Pointers.
- Additionally, SequentiallyConsistent atomics are also used to label the UPC strict accesses.
- An extra LLVM IR transform pass converts IR accesses with Remote Pointers to runtime access calls.
More information on the approach and some of the alternatives can be found in the short design document. Note that this document might change.
Getting Clang UPC with UPC IR Support
Source Code on upc-ir branch
All the work on this project is done on the upc-ir branch. Follow general instructions on configuring Clang UPC but checkout the upc-ir branch before running cmake/make.
cd llvm; git checkout upc-ir cd llvm/tools/clang; git checkout upc-ir
The following configuration options have been added:
UPC Remote Pointer representation. Number of bits in thread and address must add to 64.
LLVM address space for UPC Remote Pointer. 16 by default.
The following compile time option has been added:
Generate UPC Remote Pointer access routines in LLVM. It is enabled by default. If disabled (-fno-upc-ir), the old fashion function calls to the runtime are generated by the Clang.
All the work done on this project is on a special upc-ir branch.
01/02/2015 - Add support to autoconf tools
12/23/2014 - upc-ir branch was merged into the master
10/15/2014 - Majority of UPC tests passes - both packed and struct UPC pointer-to-shared representation
09/15/2014 - Added transform pass to convert IR load/store with Remote Pointers into appropriate calls to the UPC runtime.
08/15/2014 - Added appropriate hooks to Clang to emit IR load/store with Remote Pointers
- Clang UPC pointer-to-shared in LLVM IR
Short design document describing various approaches.