From: Andrew Stubbs <ams@codesourcery.com>
To: Tobias Burnus <tobias@codesourcery.com>,
gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: Re: [Patch] libgomp/gcn: Prepare for reverse-offload callback handling
Date: Thu, 29 Sep 2022 17:24:14 +0100 [thread overview]
Message-ID: <02ec5f29-953b-63dd-7d44-04f9af36a114@codesourcery.com> (raw)
In-Reply-To: <55dacdd3-4a82-8087-fdba-824d9910e186@codesourcery.com>
On 27/09/2022 14:16, Tobias Burnus wrote:
> @@ -422,6 +428,12 @@ struct agent_info
> if it has been. */
> bool initialized;
>
> + /* Flag whether the HSA program that consists of all the modules has been
> + finalized. */
> + bool prog_finalized;
> + /* Flag whether the HSA OpenMP's requires_reverse_offload has been used. */
> + bool has_reverse_offload;
> +
> /* The instruction set architecture of the device. */
> gcn_isa device_isa;
> /* Name of the agent. */
> @@ -456,9 +468,6 @@ struct agent_info
> thread should have locked agent->module_rwlock for reading before
> acquiring it. */
> pthread_mutex_t prog_mutex;
> - /* Flag whether the HSA program that consists of all the modules has been
> - finalized. */
> - bool prog_finalized;
> /* HSA executable - the finalized program that is used to locate kernels. */
> hsa_executable_t executable;
> };
Why has prog_finalized been moved?
> Andrew did suggest a while back to piggyback on the console_output handling,
> avoiding another atomic access. - If this is still wanted, I like to have some
> guidance regarding how to actually implement it.
The console output ring buffer has the following type:
struct output {
int return_value;
unsigned int next_output;
struct printf_data {
int written;
char msg[128];
int type;
union {
int64_t ivalue;
double dvalue;
char text[128];
};
} queue[1024];
unsigned int consumed;
} output_data;
That is, for each entry in the buffer there is a 128-byte message
string, an integer argument-type identifier, and a 128-byte argument
field. Before we had printf we had functions that could print
string+int (gomp_print_integer, type==0), string+double
(gomp_print_double, type==1) and string+string (gomp_print_string,
type==2). The string conversion could then be done on the host to keep
the target code simple. These would still be useful functions if you
want to dump debug quickly without affecting performance so much, but I
don't think they ever got upstreamed because somebody (who should have
known better!) created an unrelated function upstream with the same name
(gomp_print_string) and we already had working printf by then so the
effort to fix it wasn't worth it.
The current printf implementation (actually the write syscall), uses
type==3 to print 256-bytes of output, per packet, with no implied newline.
The point is that you can use the "msg" and "text" fields for whatever
data you want, as long as you invent a new value for "type".
The current loop has:
switch (data->type)
{
case 0: printf ("%.128s%ld\n", data->msg, data->ivalue); break;
case 1: printf ("%.128s%f\n", data->msg, data->dvalue); break;
case 2: printf ("%.128s%.128s\n", data->msg, data->text); break;
case 3: printf ("%.128s%.128s", data->msg, data->text); break;
default: printf ("GCN print buffer error!\n"); break;
}
You can make "case 4" do whatever you want. There are enough bytes for 4
pointers, and you could use multiple packets (although it's not safe to
assume they're contiguous or already arrived; maybe "case 4" for part 1,
"case 5" for part 2). It's possible to change this structure, of course,
but the target implementation is in newlib so versioning becomes a problem.
Reusing this would remove the need for has_reverse_offload, since the
console output is scanned anyway, and also eliminate rev_ptr, rev_data,
and means that, hypothetically, the device can queue up reverse offload
requests asynchronously in the ring buffer (you'd need to ensure
multi-part packets don't get interleaved though).
Andrew
next prev parent reply other threads:[~2022-09-29 16:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 13:15 Tobias Burnus
2022-09-27 13:16 ` Tobias Burnus
2022-09-29 16:24 ` Andrew Stubbs [this message]
2022-10-12 14:29 ` Tobias Burnus
2022-10-12 17:09 ` Andrew Stubbs
2022-10-12 17:25 ` Tobias Burnus
2022-11-18 17:41 ` Tobias Burnus
2022-11-18 17:56 ` Andrew Stubbs
2022-11-21 13:40 ` [Patch] libgomp/gcn: fix/improve struct output (was: [Patch] libgomp/gcn: Prepare for reverse-offload callback handling) Tobias Burnus
2022-11-21 14:19 ` Andrew Stubbs
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=02ec5f29-953b-63dd-7d44-04f9af36a114@codesourcery.com \
--to=ams@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=tobias@codesourcery.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).