Hyperobject defined

Hyperobject defined

I know this may be elementary for someone who knows c++ (I have a limited understanding of C++),but I am unsure exactly what a hyperobject is.

Please define.


4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

A hyperobject is not a C++ concept. It's implemented in a way that looks like a C++ class, but its semantics are defined in parallel terms.

The general idea is that if you have parallel operations that access the same variable at the same address, and at least one of them is writing, you lose your deterministic outcome. A hyperobject changes the semantics of the variable, however, so that the named variable actually resolves to different addresses for the different workers. Semantically, this means there is now something between the variable name and the address in memoryto which it refers. This "in between" thing is a "view." Thus, a hyperobject differs from a normal variable in that each worker gets its own "view" of the underlying object.

A reducer is a kind of hyperobject. Specifically, it is one that, as workers begin to access them, views are created using an identity function, and as workers meet at a cilk_sync the views are merged in a consistent way. If you write your own reducer, you can define the identity function and merge operation. But there are pre-written libraries that ship with Cilk++, as well.

I see and each variable has several views which are unique variable values (of the same variable) at different addresses. Now in the end this all has to be put back together,for addition, I guess that is easy.

But what if it is something more compicated? How do you put that back together? You just cannot sum all the variable values (views) then. So what do you do?


As you say, "Sum" is not always the right answer. Perhaps you want "product" or"max" or "list concatenate" or some such. The reducermechanism provides a general solution to the problem by allowing you to define what happens at a merge. Reducer classes/structs need to have a reduce() method that defines the operation. The manual tells you how to write a reducer, but some of the examples also have simple ones, and the include directory has some that are more generic (complicated code, but general).

Leave a Comment

Please sign in to add a comment. Not a member? Join today