Skip to the content.

The goal of this project is to release the developer from the burden to deal with constructs for parallelism such as threads, tasks and processes and their respective synchronization mechanism such as locks, messages, futures etc. We provide a programming model that is free of new abstractions but still allows the compiler and runtime system to exploit the inherent parallelism in your program.

So, what is your programming model then?

The heart of our programming model is the concept of a stateful function, that is a function that may use some additional state to compute a result, very similar to methods in object oriented languages.

– What?! That’s not new, I do that all the time when I write code!

struct State {
    already_greeted: Vec<String>
}

impl State {
    pub fn new() -> State {
        State {
            already_greeted : Vec::new()
        }
    }

    fn greetings(&mut self, name:String) -> String {
        let ag = self.already_greeted.join(", ");
        let greeting = format!("Hello {}\nI already greeted all these guys: [{}]\n", name, ag);
        self.already_greeted.push(name);
        greeting
    }
}
Snippet source code on GitHub
class State {
    private List<String> _alreadyGreeted = new LinkedList<>();

    public static State create() {
        return new State();
    }

    String greetings(String name){
        String greeting = "Hello " + name + "\nI already greeted all these guys: " + _alreadyGreeted;
        _alreadyGreeted.add(name);
        return greeting;
    }
}
Snippet source code on GitHub

You can now use it like a regular method in an algorithm.

let state = State::new();
for friend in friends {
  let greeting = state.greetings(friend);
  print(greetings);
}
var state = State.create();
for (String friend : friends) {
  var greeting = greetings(friend);
  printToStdOut(greeting);
}

Just as you would in any object oriented language you first initialize the state and then operate on it. Ohua makes sure that, even though we run your program implicitly parallel, that state access is efficiently synchronized and safe. The reason we call it “stateful function” and not method, is that you are not restricted to methods. You can freely choose the pairing of function and state. Of the function is a method, the state is its object, if its not, it simply receives it as an additional first argument.

In our example the state allows us to gather all the friends in _alreadyGreeted. For a list of friends containing Java, Rust and JavaScript, the program would print the following to standard out:

--> Hello Java, I already greeted all these guys: []
--> Hello Rust, I already greeted all these guys: [Java]
--> Hello JavaScript, I already greeted all these guys: [Java, Rust]

– Ok, I got that but show me some parallelism already!

Well, that’s about it. You won’t see any parallelism in the code. That’s the whole point of Ohua. You don’t have to worry about it, the compiler and runtime system will do that for you! In the above code, Ohua finds the pipeline parallelism between greetings and printToStdOut and tells the runtime system to compute the next greeting in parallel to printing the current one.

Show me Code!

You can also visit the Ohua Development Organization. The Ohua core library, compiler and backends are developed under this umbrella.

Publications

If you are looking for an overview of the ideas and concepts that underpin Ohua then have a look at this presentation.

Here we list the papers we have published about Ohua and its applications.

For a more extensive and structured view see the bibliography.