This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Issue with _Cilk_for


On Wed, Jan 29, 2014 at 10:58:55PM +0000, Iyer, Balaji V wrote:
> This is the testcase I am using:
> 
> _Cilk_for (vector<int>::iterator iter = array.begin(); iter != array.end();
>           iter++)
> {
>    if (*iter  == 6)
>      *iter = 13;
> }

> ======================================================================================
>      try
>         {
>           #pragma omp parallel schedule(cilk-for,0) if(__gnu_cxx::operator-<int*, std::vector<int> > ((const struct __normal_iterator &) (const struct __normal_iterator *) &TARGET_EXPR <D.28395, std::vector<int>::end (&array)>, (const struct __normal_iterator &) (const struct __normal_iterator *) &iter))
>             {
>               {
>                 {
>                   struct iterator iter;
>                   difference_type D.28409;
>                   difference_type D.28410;
> 
>                                     struct iterator iter;
>                   <<cleanup_point <<< Unknown tree: expr_stmt
>   (void) (iter = TARGET_EXPR <D.28366, std::vector<int>::begin (&array)>) >>>>>;
>                                     difference_type D.28409;
>                                     difference_type D.28410;
>                    grainsize = 0 if(__gnu_cxx::operator-<int*, std::vector<int> > ((const struct __normal_iterator &) (const struct __normal_iterator *) &TARGET_EXPR <D.28395, std::vector<int>::end (&array)>, (const struct __normal_iterator &) (const struct __normal_iterator *) &iter))
>                     {
>                       <<cleanup_point <<< Unknown tree: expr_stmt
>   (void) (D.28410 = 0) >>>>>
>                       _Cilk_for (D.28409 = 0; D.28409 != <<cleanup_point __gnu_cxx::operator-<int*, std::vector<int> > ((const struct __normal_iterator &) (const struct __normal_iterator *) &TARGET_EXPR <D.28395, std::vector<int>::end (&array)>, (const struct __normal_iterator &) (const struct __normal_iterator *) &iter)>>; D.28409 = D.28409 + 1)

Can you explain why you emit anything in between the parallel and _Cilk_for? 
I don't see why it should be needed.
Depending on what the Cilk+ standard allows you to do (can array.begin ()
be evaluated multiple times or not, and if not, can you invoke say a copy
constructor on it), you should just emit an EXPR_STMT that initializes
an artificial scalar (say get_temp_regvar created) to
(array.end () - array.begin ()) before you add the parallel, or,
if array.begin () can't be evaluated multiple times, then construct some
temporary before the parallel with array.begin () as initializer
and then do the subtraction between array.end () and that temporary.

Then the parallel, with _Cilk_for immediately in it and just another
temporary scalar as loop iterator there, and only inside of _Cilk_for
declare the iterator var and construct (if it has been declared in _Cilk_for, otherwise
just initialize it) to, depending on what Cilk+ requires, either to
array.begin () and then operator+ it to the corresponding value, or
construct already to array.begin () + scalariv.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]