> -----Original Message----- > From: Jakub Jelinek [mailto:ja...@redhat.com] > Sent: Wednesday, December 18, 2013 1:58 AM > To: Iyer, Balaji V > Cc: Jason Merrill (ja...@redhat.com); 'gcc@gcc.gnu.org' > Subject: Re: Question about omp-low.c > > 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. >
I think we are talking two different things or I am not understanding you. I am using OMP's iterator handling mechanism, but the question I have is about the pre-body. It is pre-gimplifying the condition and the initial value and storing it in pre_body. The prebody is then pushed into the child function. I want the pre-body to be pushed into main function. Is it possible for me to do that? > 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. > Grain is a value that user specifies that is passed directly to the runtime that tells it how to divide the work (different from step-size, please see cilk_for_grain.c in my patch). It is very Cilk runtime specific. Loop-count I need it because I need it to pass into the cilk runtime function call (along with grain) to tell the loop count. I calculate this value way ahead before the gimplification of the condition, intial value and the step-size. Now, if I can some-how find a way to make GCC move the pre-body to the parent function instead of the child function, I can try to eliminate this field from the structure. > Jakub