GoPar: Automatic Loop Parallelization of Go Programs
Go C C++ Shell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.

GoPar: Automatic Loop Parallelization of Go Programs

Ian Wetherbee

  • University of Illinois at Urbana-Champaign
  • Senior Thesis, Computer Engineering
  • Adviser: Wen-Mei Hwu, IMPACT Research Group


Parallel computation hardware has achieved widespread consumer adoption, but software developers still need to manually exploit parallelism. Popular parallelization techniques require developers to make one or more program modifications, including source annotations, separate parallel kernel languages, manual data marshalling code, and framework-specific data containers. This additional burden forms a barrier to widespread adoption of parallel programming, and makes programs more verbose and difficult to analyze and modify. To solve these problems, this thesis introduces GoPar, an automatic loop-parallelizing compiler for the Go language that targets multicore CPUs. It aims to require no extra work from the developer to exploit parallelism and supports transforming many of Go's language features that enable compact and expressive code. GoPar is based on a new multi-pass compiler architecture containing analysis and transformation passes for detecting parallelizable loops and outputting transformed code. GoPar removes the developer barrier to exploiting parallel hardware without sacrificing maintainable code.

Read full thesis


Recognize parallel for loops and automatically paralleize them. Supports range loops with slices or arrays as arguments. Slice values can be any type that does not contain pointers (so no interfaces, but structures are supported). Supports interprocedural analysis and imported packages (including the standard Go packages).

a := make([]..., N)
for i, v := range a {
    a[i] = ...

Compiler output will explain why a loop could not be parallelized:

Can't parallelize loop at /home/ian/gopar/src/nbody_shootout/nbody.go:71:2
-> px.ReadWrite is accessed by all iterations


git clone git://
cd gopar
go install gopar


Replace go install pkg with gopar install pkg to build your project.

GOPATH=<project root>
gopar install project


cd gopar
./ [nbody_shootout|stencil_bench]
# run benchmarks on original and GOMAXPROCS={1,2,4,8}
./ [nbody_shootout|stencil_bench]


See GitHub issues, all contributions are welcome!