problem in writing reducer

problem in writing reducer

Hi all,

I'm attaching the example of writing the reducer for linked list. The problem is that i get an error at compile time as follows:

test1.cpp(81): error: class "cilk::reducer<IntListMonoid>" has no member "add_value"
        list->add_value(i); // "list->" accesses the view

test1.cpp(84): error: class "cilk::reducer<IntListMonoid>" has no member "get_value"
  return list->get_value(); // "list->" accesses the view

It does not allow me to access the view class members even though i have made "IntListMonoid" a friend class in "IntListView" class. So please anybody can help me out of this?

--Abdul Jabbar--

Downloadapplication/pdf how-to-write-a-reducer.pdf146.77 KB
9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

  I see an attachment which is the guide to writing reducers, but not test1.cpp?  

I was able to copy the entire last example and compile without any errors.  Which compiler are you using, and what flags did you pass in to compile the program?


i'm using intel cilk plus compiler (icpc). and below is the compilation command:

icpc test1.cpp -I. -I/opt/cilkutil/include -DTIMES_TO_RUN=1 -DCILKM_RTS=1 -o test1

i'm also attaching test1.cpp file so you can see that as well by compiling it.


Downloadtext/x-c++src test1.cpp1.8 KB

In the attached test program, "list" is declared as a pointer to a reducer.
        cilk::reducer<IntListMonoid> *list;

In the example in the documentation, the reducer is declared as:
        cilk::reducer<IntListMonoid> list;



it is still not working . Now it is giving me error that expression (list->addvalue(i)) must have pointer type. And when I use dot instead of arrow in the expression then it gives me previous error. I still don't know what I'm missing.

Hm... that is odd...  What does "icpc -V" return, i.e., which version string does it return?

If you use "icc -H", does it bring in the reducer.h file that you think it should be including?  What does your copy of "reducer_list.h" look like?

This question is likely unrelated, but why do you have the preprocessor flags of "-DTIMES_TO_RUN=1 -DCILKM_RTS=1" specified?


icpc version is 12.1.3 (gcc version 4.1.2). Is this problem could be because of older version of gcc?

And yes, icc -H or icpc -H do bring the reducer.h file.

Ah.  You have an older version of the compiler, which has an older version of the header files for reducers.
In the old syntax for reducers, the way to access the reducer view used to be to use "operator ()", i.e., to write:


In the newer syntax, you use the dereference operator:

The newer header files are backwards compatible --- they will still take the old syntax, although we consider that syntax to be deprecated.
But the reducer guide was written recently, and uses the newer syntax.

There are probably several ways to fix your problem.  You could (1) update your compiler to the latest 12.1 version, which comes with updated header files, (2) use the old deprecated syntax, or (3) try to patch the reducer.h file to the new syntax.

Is there any difficulty with updating your compiler for your project?  The first option would be the one I would recommend, as the other two are asking for trouble down the line...



Thanks Jim. The older version syntax worked.


Abdul Jabbar

Leave a Comment

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