On Wed, Dec 18, 2013 at 04:46:40AM +0000, Iyer, Balaji V wrote: > I have a question regarding the parallel for implementation. I am > implementing _Cilk_for based on the routines in omp-low.c and I would like to > create a child function but would like to move the items that > gimplify_omp_for inserts in for_pre_body in the top-level function. I need to > do this because in _Cilk_for, we insert the body of the function into a child > function and then we call a builtin CilkPlus function called > __cilkrts_cilk_for_64 and pass in the child function's name, data pointer, > loop-count and grain. > > The loop count computation gets to be an issue in C++ when we use > iterator. > > For example, if we have something like this: > Vector <int> array; > For (vector<int>::iterator iter = array.begin(); iter != array.end (); > iter++)
OpenMP also supports C++ iterators, so I don't see why you don't follow that. The iterators are lowered already by the C++ FE, what the middle-end sees is an integral iterator. Just look at one of the several libgomp/testsuite/libgomp.c++/for-* testcases. By following what we do for OpenMP here, I'd hope you can get rid of the loop_count you've added to the gimple structure, what is grain, is that specific to each of the collapsed trees, or does Cilk+ support only collapse(1), and if so or if it is global for the _Cilk_for and not for each iterator, just add a clause for it instead. Jakub