From: Jakub Jelinek <jakub@redhat.com>
To: "Michael V. Zolotukhin" <michael.v.zolotukhin@gmail.com>
Cc: Kirill Yukhin <kirill.yukhin@gmail.com>,
Richard Henderson <rth@redhat.com>,
gcc@gcc.gnu.org, triegel@redhat.com
Subject: Re: [RFC] Offloading Support in libgomp
Date: Tue, 27 Aug 2013 00:38:00 -0000 [thread overview]
Message-ID: <20130826125116.GE21876@tucnak.zalov.cz> (raw)
In-Reply-To: <20130826115911.GA40923@msticlxl57.ims.intel.com>
On Mon, Aug 26, 2013 at 03:59:11PM +0400, Michael V. Zolotukhin wrote:
> As I currently see it, the given code would be expanded to something like
> this:
>
> // Create two versions of V: for host and for target
> int v;
> int v_target __attribute(target);
>
> // The same for TGT function
> int tgt ()
> {
> .. update v ..
> }
> int tgt_target () __attribute(target)
> {
> .. update v_target ..
> }
Actually, not two versions of those during the compilation, you have
just one v and one tgt, both have __attribute__(("omp declare target"))
on them (note, you can't specify that attribute manually).
And just when streaming into .gnu.target_lto_* sections you only stream
everything that has those attributes and types used by it, but nothing else.
>
> float
> bar (int x, int y, int z)
> {
> float b[1024], c[1024], s = 0;
> int i, j;
> baz (b, c, x);
> // #pragma omp target data map(to: b)
> vec<data_descriptor> data_desc;
> data_desc.push ({&b, 1024*sizeof(float), TO});
> GOMP_target_data (&data_desc);
Nope. It would be:
struct data_descriptor data_desc1[1] = { { &b, 1024*sizeof(float), TO } };
GOMP_target_data (-1, data_desc1, 1);
or so. The compiler always knows how many vector elements it needs, there
is no point in making the vector dynamic, and vec<> is a compiler data
structure, while you want to emit runtime code. The -1 in there stands
for missing device(device-id) clause, otherwise it would be the provided
device-id expression. For the if clause, the question is if we want to pass
it down to the runtime library too (as bool, defaulting to true if missing),
or do something else.
> {
> // #pragma omp target map(tofrom: c) map(from:s)
> data_desc.push ({&c, 1024*sizeof(float), TOFROM});
> data_desc.push ({&s, sizeof(float), FROM});
> GOMP_target_data (&data_desc); // Add mapping for S and C variables,
> // mapping for B shouldn't change
Nope, there is only one target data pragma, so you would use here just:
> GOMP_target (foo1, "foo1", &data_desc); // Call either FOO1 or offloaded
> // FOO1_TARGET with arguments
> // from vector DATA_DESC
struct data_descriptor data_desc2[2] = { ... };
GOMP_target (-1, bar.omp_fn.1, "bar.omp_fn.1", data_desc2, 2);
>
> // #pragma omp target update from(b, v)
> vec<data_descriptor> data_desc_update; // target update pragma require a
> // separate vector
> data_desc_update.push ({&b, 1024*sizeof(float), FROM});
> data_desc_update.push ({&v, sizeof(int), FROM});
> GOMP_target_data (&data_desc_update);
Similarly here.
> }
> return s;
> }
> void
> foo1 (vec<data_descriptor> data_desc)
> {
> float b = *data_desc[0].host_address;
> float c = *data_desc[1].host_address;
> float s = 0;
> int i;
> for (i = 0; i < 1024; i++)
> tgt (), s += b[i] * c[i];
> *data_desc[2].host_address = s;
No, I didn't mean you'd do this. omp-lower.c would simply create
a type here that would have the same layout as what would the runtime
library pass to it.
So it would be:
void
bar.omp_fn.1 (struct omp_target_data *.omp_data_in)
{
int i;
*.omp_data_in->s = 0;
for (i = 0; i < 1024; i++)
tgt (), *.omp_data_in->s += .omp_data_in->b[i] * .omp_data_in->c[i];
}
Just look what omplower pass does for normal OpenMP code, say
#pragma omp parallel, task etc.
Jakub
next prev parent reply other threads:[~2013-08-26 12:51 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-22 22:37 Michael V. Zolotukhin
2013-08-23 0:22 ` Jakub Jelinek
2013-08-23 12:16 ` Michael V. Zolotukhin
2013-08-23 12:37 ` Jakub Jelinek
2013-08-24 6:17 ` Michael V. Zolotukhin
2013-08-25 16:24 ` Jakub Jelinek
2013-08-27 0:36 ` Michael V. Zolotukhin
2013-08-27 0:38 ` Jakub Jelinek [this message]
2013-08-27 6:16 ` Michael V. Zolotukhin
2013-08-27 8:06 ` Jakub Jelinek
2013-08-27 15:47 ` Michael V. Zolotukhin
2013-08-27 16:22 ` Jakub Jelinek
2013-08-27 19:54 ` Michael V. Zolotukhin
2013-08-28 11:21 ` Jakub Jelinek
2013-08-29 10:44 ` Michael V. Zolotukhin
2013-09-10 15:02 ` Michael V. Zolotukhin
2013-09-10 15:15 ` Jakub Jelinek
2013-09-10 15:31 ` Michael V. Zolotukhin
2013-09-10 15:36 ` Jakub Jelinek
2013-09-10 15:38 ` Michael V. Zolotukhin
2013-09-13 11:30 ` Michael V. Zolotukhin
2013-09-13 12:36 ` Jakub Jelinek
2013-09-13 13:11 ` Michael V. Zolotukhin
2013-09-13 13:16 ` Jakub Jelinek
2013-09-13 15:09 ` Ilya Tocar
2013-09-13 15:34 ` Jakub Jelinek
2014-07-17 7:52 ` Thomas Schwinge
2014-07-17 12:30 ` Ilya Verbin
2014-07-17 12:37 ` Jakub Jelinek
2014-07-17 12:58 ` Thomas Schwinge
2014-07-17 13:09 ` Thomas Schwinge
2014-07-17 13:35 ` Jakub Jelinek
2014-07-17 14:37 ` Thomas Schwinge
2013-09-13 9:35 ` Michael Zolotukhin
2013-09-13 10:52 ` Kirill Yukhin
2013-09-13 11:04 ` Nathan Sidwell
2013-09-13 11:21 ` Michael V. Zolotukhin
2013-09-16 9:35 ` Jakub Jelinek
2013-09-17 12:05 ` Michael V. Zolotukhin
2013-09-17 12:30 ` Jakub Jelinek
2013-10-28 10:43 ` Ilya Verbin
2013-10-29 8:04 ` Jakub Jelinek
2014-01-31 18:03 ` Ilya Verbin
2014-01-31 19:43 ` Jakub Jelinek
2014-02-14 15:24 ` Ilya Verbin
2014-02-14 15:43 ` Jakub Jelinek
2014-02-14 18:54 ` Richard Henderson
2014-02-17 15:59 ` Ilya Verbin
2014-02-17 16:03 ` Jakub Jelinek
2013-08-28 12:56 ` Richard Biener
2013-08-28 15:26 ` Jakub Jelinek
2013-08-28 17:03 ` Richard Biener
2013-08-28 17:15 ` Jakub Jelinek
2013-08-29 21:09 ` Richard Biener
2013-08-28 18:54 ` Torvald Riegel
2013-08-28 18:43 ` Torvald Riegel
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=20130826125116.GE21876@tucnak.zalov.cz \
--to=jakub@redhat.com \
--cc=gcc@gcc.gnu.org \
--cc=kirill.yukhin@gmail.com \
--cc=michael.v.zolotukhin@gmail.com \
--cc=rth@redhat.com \
--cc=triegel@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).