public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Iyer, Balaji V" <balaji.v.iyer@intel.com>
To: 'Jakub Jelinek' <jakub@redhat.com>
Cc: 'Jason Merrill' <jason@redhat.com>, 'Jeff Law' <law@redhat.com>,
	"'Aldy Hernandez'" <aldyh@redhat.com>,
	"'gcc-patches@gcc.gnu.org'"	<gcc-patches@gcc.gnu.org>,
	"'rth@redhat.com'" <rth@redhat.com>
Subject: RE: [PING] [PATCH] _Cilk_for for C and C++
Date: Tue, 28 Jan 2014 16:55:00 -0000	[thread overview]
Message-ID: <BF230D13CA30DD48930C31D4099330003A4C8E1C@FMSMSX101.amr.corp.intel.com> (raw)
In-Reply-To: <BF230D13CA30DD48930C31D4099330003A4C8892@FMSMSX101.amr.corp.intel.com>



> -----Original Message-----
> From: Iyer, Balaji V
> Sent: Monday, January 27, 2014 4:36 PM
> To: Jakub Jelinek
> Cc: Jason Merrill; 'Jeff Law'; 'Aldy Hernandez'; 'gcc-patches@gcc.gnu.org';
> 'rth@redhat.com'
> Subject: RE: [PING] [PATCH] _Cilk_for for C and C++
> 
> > -----Original Message-----
> > From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
> > owner@gcc.gnu.org] On Behalf Of Jakub Jelinek
> > Sent: Monday, January 27, 2014 3:50 PM
> > To: Iyer, Balaji V
> > Cc: Jason Merrill; 'Jeff Law'; 'Aldy Hernandez';
> > 'gcc-patches@gcc.gnu.org'; 'rth@redhat.com'
> > Subject: Re: [PING] [PATCH] _Cilk_for for C and C++
> >
> > On Mon, Jan 27, 2014 at 08:41:14PM +0000, Iyer, Balaji V wrote:
> > > 	Did you get a chance to look at this _Cilk_for patch?
> >
> > IMHO it is not as much work as you are fearing, at most a few hours of
> > work to get it right, and well worth doing.  So, please at least try
> > it out and if you get stuck with it, explain why.
> 
> Hi Jakub,
> 	I tried it that way in the original patch submission for C
> (http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01369.html), but it hit a
> dead-end when I was trying to get STL iterators working for C++. This is why I
> re-structured things this way to get them both working.
> 
> Thanks,
> 
> Balaji V. Iyer.
> 

Hi Jakub,
	I thought about it a bit more, and the main issue here is that we need access to the _Cilk_for loop's components both inside the child function and the parent function.

	So, at the moment, I have modelled the _Cilk_for as something like this:

#pragma omp for  schedule (runtime: grain)
_Cilk-for (vector<int>::iterator ii = array.begin (); ii != array.end (); ii++)
#pragma omp parallel 
{
	<body>
}

From what I understand, you feel this is a bit ugly and you want this to be modelled something like this?

#pragma omp parallel for schedule (runtime: grain)
_Cilk_for (vector<int>::iterator ii = array.begin (); ii != array.end(); ii++)
{
	<body>
}

Am I right?

As it stands, doing it the way you suggested did not work when we have iterators since iterator expansion pushed inside the child function and its expanded variables are not accessible outside the child function by gimplify_omp_for. That is, the expansion is put after #pragma omp parallel for and that is all pulled into the child function and thus the information to compute the count is lost for the parent function.

There is a hack that I think may get around this. This is a bit ugly and really is not the way I would think of _Cilk_fors. I am OK with trying this if you will accept it.
 
If I do something like this:
     
#pragma omp parallel for schedule (runtime:grain) if ((array.end() - array.begin ())/1)
_Cilk_for (vector <int>::iterator ii = array.begin (); ii != array.end (); ii++)
{
	<body>
}

The new addition is if clause where "if ((<end> - <start>) / <step>)"

Then, in the expand_parallel_task, I can extract the if (...) clause and then pass the expression as a parameter for the loop-count. Yes, it's bit ugly but if you are willing to accept it, I can try to implement this.

Please let me know.

Thanks,

Balaji V. Iyer.

  reply	other threads:[~2014-01-28 16:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-27 20:41 Iyer, Balaji V
2014-01-27 20:53 ` Jakub Jelinek
2014-01-27 21:36   ` Iyer, Balaji V
2014-01-28 16:55     ` Iyer, Balaji V [this message]
2014-01-29 11:31       ` Jakub Jelinek
2014-01-29 15:54         ` Iyer, Balaji V
2014-01-31 15:39           ` Iyer, Balaji V
2014-02-05  5:27         ` Iyer, Balaji V
2014-02-07 14:02           ` Jakub Jelinek
2014-02-07 14:33             ` Iyer, Balaji V
2014-02-07 14:53               ` Jakub Jelinek
2014-02-07 22:14                 ` Iyer, Balaji V
2014-02-10 17:57                   ` Jakub Jelinek
2014-02-10 22:07                     ` Iyer, Balaji V
2014-02-12 14:59                       ` Jakub Jelinek
2014-02-12 15:14                         ` Iyer, Balaji V
2014-02-12 15:28                           ` Jakub Jelinek
2014-02-12 17:05                             ` Iyer, Balaji V
2014-02-12 17:09                               ` Jakub Jelinek
2014-02-12 17:15                                 ` Iyer, Balaji V
2014-02-17  6:42                                 ` Iyer, Balaji V
2014-02-19  4:43                                   ` Iyer, Balaji V
2014-02-19 11:24                                     ` Jakub Jelinek
2014-02-21  4:38                                       ` Iyer, Balaji V
2014-02-24 23:16                                         ` Iyer, Balaji V
     [not found]                                           ` <BF230D13CA30DD48930C31D4099330003A4D2123@FMSMSX101.amr.corp.intel.com>
     [not found]                                             ` <20140306115443.GC22862@tucnak.redhat.com>
2014-03-20 21:19                                               ` FW: " Iyer, Balaji V

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BF230D13CA30DD48930C31D4099330003A4C8E1C@FMSMSX101.amr.corp.intel.com \
    --to=balaji.v.iyer@intel.com \
    --cc=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jason@redhat.com \
    --cc=law@redhat.com \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).