summaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorCesar Philippidis <cesar@codesourcery.com>2018-07-26 04:42:29 -0700
committerTom de Vries <vries@gcc.gnu.org>2018-07-26 11:42:29 +0000
commit88a4654d03d0d05047aa168e45967ed2d94cb9ce (patch)
tree228f30ad516a6c3e25c474b2b38e70afb930256c /libgomp
parent0c6c2f5fc239121f70334a587e371aab2c7a60a4 (diff)
downloadgcc-88a4654d03d0d05047aa168e45967ed2d94cb9ce.tar.gz
[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. Co-Authored-By: Tom de Vries <tdevries@suse.de> From-SVN: r262997
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog7
-rw-r--r--libgomp/plugin/plugin-nvptx.c15
2 files changed, 22 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 6c5ff91983d..27ff705e909 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,6 +1,13 @@
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.
+
+2018-07-26 Cesar Philippidis <cesar@codesourcery.com>
+ Tom de Vries <tdevries@suse.de>
+
* plugin/plugin-nvptx.c (struct ptx_device): Add warp_size,
max_threads_per_block and max_threads_per_multiprocessor fields.
(nvptx_open_device): Initialize new fields.
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. */