From: Tom de Vries <tdevries@suse.de>
To: Cesar Philippidis <cesar@codesourcery.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
Jakub Jelinek <jakub@redhat.com>,
Thomas Schwinge <thomas@codesourcery.com>
Subject: Re: [patch] adjust default nvptx launch geometry for OpenACC offloaded regions
Date: Thu, 26 Jul 2018 12:45:00 -0000 [thread overview]
Message-ID: <e79cb066-01ce-7c77-a630-8315294ce971@suse.de> (raw)
In-Reply-To: <5c0b9b2d-bbe3-dfd9-1ae5-a164a4079e0c@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]
>> Right, in fact there are two separate things you're trying to address
>> here: launch failure and occupancy heuristic, so split the patch.
> That hunk was small, so I included it with this patch. Although if you
> insist, I can remove it.
Please, for future reference, always assume that I insist instead of
asking me, unless you have an argument to present why that is not a good
idea. And just to be clear here: "small" is not such an argument.
Please keep in mind ( https://gcc.gnu.org/contribute.html#patches ):
...
Don't mix together changes made for different reasons. Send them
individually.
...
> + /* Check if the accelerator has sufficient hardware resources to
> + launch the offloaded kernel. */
> + if (dims[GOMP_DIM_WORKER] * dims[GOMP_DIM_VECTOR]
> + > targ_fn->max_threads_per_block)
> + GOMP_PLUGIN_fatal ("The Nvidia accelerator has insufficient resources to"
> + " launch '%s' with num_workers = %d and vector_length ="
> + " %d; recompile the program with 'num_workers = x and"
> + " vector_length = y' on that offloaded region or "
> + "'-fopenacc-dim=-:x:y' where x * y <= %d.\n",
> + targ_fn->launch->fn, dims[GOMP_DIM_WORKER],
> + dims[GOMP_DIM_VECTOR], targ_fn->max_threads_per_block);
> +
This is copied from the state on an openacc branch where vector-length
is variable, and the error message text doesn't make sense on current
trunk for that reason. Also, it suggests a syntax for fopenacc-dim
that's not supported on trunk.
Committed as attached.
Thanks,
- Tom
[-- Attachment #2: 0002-libgomp-nvptx-Add-error-with-recompilation-hint-for-launch-failure.patch --]
[-- Type: text/x-patch, Size: 1866 bytes --]
[libgomp, nvptx] Add error with recompilation hint for launch failure
Currently, when a kernel is lauched with too many workers, it results in a cuda
launch failure. This is triggered f.i. for parallel-loop-1.c at -O0 on a Quadro
M1200.
This patch detects this situation, and errors out with a hint on how to fix it.
Build and reg-tested on x86_64 with nvptx accelerator.
2018-07-26 Cesar Philippidis <cesar@codesourcery.com>
Tom de Vries <tdevries@suse.de>
* plugin/plugin-nvptx.c (nvptx_exec): Error if the hardware doesn't have
sufficient resources to launch a kernel, and give a hint on how to fix
it.
---
libgomp/plugin/plugin-nvptx.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index 5d9b5151e95..3a4077a1315 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -1204,6 +1204,21 @@ nvptx_exec (void (*fn), size_t mapnum, void **hostaddrs, void **devaddrs,
dims[i] = default_dims[i];
}
+ /* Check if the accelerator has sufficient hardware resources to
+ launch the offloaded kernel. */
+ if (dims[GOMP_DIM_WORKER] * dims[GOMP_DIM_VECTOR]
+ > targ_fn->max_threads_per_block)
+ {
+ int suggest_workers
+ = targ_fn->max_threads_per_block / dims[GOMP_DIM_VECTOR];
+ GOMP_PLUGIN_fatal ("The Nvidia accelerator has insufficient resources to"
+ " launch '%s' with num_workers = %d; recompile the"
+ " program with 'num_workers = %d' on that offloaded"
+ " region or '-fopenacc-dim=:%d'",
+ targ_fn->launch->fn, dims[GOMP_DIM_WORKER],
+ suggest_workers, suggest_workers);
+ }
+
/* This reserves a chunk of a pre-allocated page of memory mapped on both
the host and the device. HP is a host pointer to the new chunk, and DP is
the corresponding device pointer. */
next prev parent reply other threads:[~2018-07-26 12:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 21:59 Cesar Philippidis
2018-06-20 22:16 ` Tom de Vries
2018-06-21 13:58 ` Cesar Philippidis
2018-07-02 14:14 ` Tom de Vries
2018-07-02 14:39 ` Cesar Philippidis
2018-07-11 19:13 ` Cesar Philippidis
2018-07-26 11:58 ` Tom de Vries
2018-07-26 12:13 ` [libgomp, nvptx] Move device property sampling from nvptx_exec to nvptx_open Tom de Vries
2018-07-26 12:45 ` Tom de Vries [this message]
2018-07-26 14:27 ` [patch] adjust default nvptx launch geometry for OpenACC offloaded regions Cesar Philippidis
2018-07-26 15:18 ` Tom de Vries
2018-07-30 10:16 ` Tom de Vries
2018-06-29 17:16 ` Cesar Philippidis
2018-06-30 11:36 ` Cesar Philippidis
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=e79cb066-01ce-7c77-a630-8315294ce971@suse.de \
--to=tdevries@suse.de \
--cc=cesar@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=thomas@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).