Hi, Allow PTX_MAX_VECTOR_LENGTH to be defined as larger than PTX_WARP_SIZE in nvptx_goacc_validate_dims_1.
Committed to trunk. Thanks, - Tom [nvptx] Allow larger PTX_MAX_VECTOR_LENGTH in nvptx_goacc_validate_dims_1 2019-01-07 Tom de Vries <tdevr...@suse.de> * config/nvptx/nvptx.c (nvptx_welformed_vector_length_p) (nvptx_apply_dim_limits): New function. (nvptx_goacc_validate_dims_1): Allow PTX_MAX_VECTOR_LENGTH larger than PTX_WARP_SIZE. --- gcc/config/nvptx/nvptx.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 3a4a5a3a159..6df4d02c4c1 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -5267,6 +5267,30 @@ nvptx_simt_vf () return PTX_WARP_SIZE; } +static bool +nvptx_welformed_vector_length_p (int l) +{ + gcc_assert (l > 0); + return l % PTX_WARP_SIZE == 0; +} + +static void +nvptx_apply_dim_limits (int dims[]) +{ + /* Check that the vector_length is not too large. */ + if (dims[GOMP_DIM_VECTOR] > PTX_MAX_VECTOR_LENGTH) + dims[GOMP_DIM_VECTOR] = PTX_MAX_VECTOR_LENGTH; + + /* Check that the number of workers is not too large. */ + if (dims[GOMP_DIM_WORKER] > PTX_WORKER_LENGTH) + dims[GOMP_DIM_WORKER] = PTX_WORKER_LENGTH; + + /* Ensure that num_worker * vector_length <= cta size. */ + if (dims[GOMP_DIM_WORKER] > 0 && dims[GOMP_DIM_VECTOR] > 0 + && dims[GOMP_DIM_WORKER] * dims[GOMP_DIM_VECTOR] > PTX_CTA_SIZE) + dims[GOMP_DIM_VECTOR] = PTX_WARP_SIZE; +} + /* As nvptx_goacc_validate_dims, but does not return bool to indicate whether DIMS has changed. */ @@ -5389,12 +5413,10 @@ nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level) } if (dims[GOMP_DIM_VECTOR] > 0 - && dims[GOMP_DIM_VECTOR] != PTX_WARP_SIZE) + && !nvptx_welformed_vector_length_p (dims[GOMP_DIM_VECTOR])) dims[GOMP_DIM_VECTOR] = PTX_DEFAULT_VECTOR_LENGTH; - /* Check the num workers is not too large. */ - if (dims[GOMP_DIM_WORKER] > PTX_WORKER_LENGTH) - dims[GOMP_DIM_WORKER] = PTX_WORKER_LENGTH; + nvptx_apply_dim_limits (dims); if (dims[GOMP_DIM_VECTOR] != old_dims[GOMP_DIM_VECTOR]) warning_at (decl ? DECL_SOURCE_LOCATION (decl) : UNKNOWN_LOCATION, 0, @@ -5415,6 +5437,7 @@ nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level) dims[GOMP_DIM_WORKER] = PTX_DEFAULT_RUNTIME_DIM; if (dims[GOMP_DIM_GANG] < 0) dims[GOMP_DIM_GANG] = PTX_DEFAULT_RUNTIME_DIM; + nvptx_apply_dim_limits (dims); } }