From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42663 invoked by alias); 3 Jan 2019 16:20:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 42649 invoked by uid 89); 3 Jan 2019 16:20:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=Master, lane, H*M:9256, dim X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Jan 2019 16:20:42 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 517C0AE6B; Thu, 3 Jan 2019 16:20:40 +0000 (UTC) Subject: Re: [nvptx] vector length patch series From: Tom de Vries To: "Schwinge, Thomas" Cc: "gcc-patches@gcc.gnu.org" References: <2ece5d7b-3675-84ab-f255-3c56a2ffd7dc@suse.de> <91b927af-d854-2865-7cbd-9a9a835ab5cc@codesourcery.com> <1394d89c-896e-f6a3-5f9a-78e98b16e85c@suse.de> Message-ID: Date: Thu, 03 Jan 2019 16:20:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <1394d89c-896e-f6a3-5f9a-78e98b16e85c@suse.de> Content-Type: multipart/mixed; boundary="------------22652AB373EA1E7B04CDB186" X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00114.txt.bz2 This is a multi-part message in MIME format. --------------22652AB373EA1E7B04CDB186 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 2319 On 14-12-18 20:58, Tom de Vries wrote: > 0012-nvptx-Add-axis_dim.patch > diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c > index 74a0d4b04d9..02ecf12bd84 100644 > --- a/gcc/config/nvptx/nvptx.c > +++ b/gcc/config/nvptx/nvptx.c > @@ -2885,6 +2885,23 @@ struct offload_attrs > int max_workers; > }; > > +/* Define entries for cfun->machine->axis_dim. */ > + > +#define MACH_VECTOR_LENGTH 0 > +#define MACH_MAX_WORKERS 1 > + > +static int ATTRIBUTE_UNUSED > +nvptx_mach_max_workers () > +{ > + return cfun->machine->axis_dim[MACH_MAX_WORKERS]; > +} > + > +static int ATTRIBUTE_UNUSED > +nvptx_mach_vector_length () > +{ > + return cfun->machine->axis_dim[MACH_VECTOR_LENGTH]; > +} > + > /* Loop structure of the function. The entire function is described as > a NULL loop. */ > > @@ -4832,6 +4849,9 @@ nvptx_reorg (void) > > populate_offload_attrs (&oa); > > + cfun->machine->axis_dim[MACH_VECTOR_LENGTH] = oa.vector_length; > + cfun->machine->axis_dim[MACH_MAX_WORKERS] = oa.max_workers; > + This initialization here is done during pass_machine_reorg , but the data is needed earlier, making it necessary there to call populate_offload_attrs again, instead of using nvptx_mach_vector_length/nvptx_mach_max_workers. I've made the initialization lazy, which fixes that problem. > /* If there is worker neutering, there must be vector > neutering. Otherwise the hardware will fail. */ > gcc_assert (!(oa.mask & GOMP_DIM_MASK (GOMP_DIM_WORKER)) > diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h > index a2fe8b68b22..4059691a609 100644 > --- a/gcc/config/nvptx/nvptx.h > +++ b/gcc/config/nvptx/nvptx.h > @@ -218,6 +218,8 @@ struct GTY(()) machine_function > int return_mode; /* Return mode of current fn. > (machine_mode not defined yet.) */ > rtx axis_predicate[2]; /* Neutering predicates. */ > + int axis_dim[2]; /* Maximum number of threads on each axis, dim[0] is > + vector_length, dim[1] is num_workers. */ > rtx unisimt_master; /* 'Master lane index' for -muniform-simt. */ > rtx unisimt_predicate; /* Predicate for -muniform-simt. */ > rtx unisimt_location; /* Mask location for -muniform-simt. */ > -- > 2.17.2 Committed as attached. Thanks, - Tom --------------22652AB373EA1E7B04CDB186 Content-Type: text/x-patch; name="0004-nvptx-Add-nvptx_mach_vector_length-nvptx_mach_max_workers.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0004-nvptx-Add-nvptx_mach_vector_length-nvptx_mach_max_worke"; filename*1="rs.patch" Content-length: 2621 [nvptx] Add nvptx_mach_vector_length, nvptx_mach_max_workers The vector length and maximum number of workers are known compile-time. Make these easily available during code generation via new functions. 2019-01-03 Tom de Vries * config/nvptx/nvptx.c (MACH_VECTOR_LENGTH, MACH_MAX_WORKERS): Define. (init_axis_dim, nvptx_mach_max_workers, nvptx_mach_vector_length): New function. * config/nvptx/nvptx.h (struct machine_function): Add axis_dims. --- gcc/config/nvptx/nvptx.c | 41 +++++++++++++++++++++++++++++++++++++++++ gcc/config/nvptx/nvptx.h | 3 +++ 2 files changed, 44 insertions(+) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index f527429ce2d..52cbac957ce 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -2883,6 +2883,47 @@ struct offload_attrs int vector_length; }; +/* Define entries for cfun->machine->axis_dim. */ + +#define MACH_VECTOR_LENGTH 0 +#define MACH_MAX_WORKERS 1 + +static void populate_offload_attrs (offload_attrs *oa); + +static void +init_axis_dim (void) +{ + offload_attrs oa; + int max_workers; + + populate_offload_attrs (&oa); + + if (oa.num_workers == 0) + max_workers = PTX_CTA_SIZE / oa.vector_length; + else + max_workers = oa.num_workers; + + cfun->machine->axis_dim[MACH_VECTOR_LENGTH] = oa.vector_length; + cfun->machine->axis_dim[MACH_MAX_WORKERS] = max_workers; + cfun->machine->axis_dim_init_p = true; +} + +static int ATTRIBUTE_UNUSED +nvptx_mach_max_workers () +{ + if (!cfun->machine->axis_dim_init_p) + init_axis_dim (); + return cfun->machine->axis_dim[MACH_MAX_WORKERS]; +} + +static int ATTRIBUTE_UNUSED +nvptx_mach_vector_length () +{ + if (!cfun->machine->axis_dim_init_p) + init_axis_dim (); + return cfun->machine->axis_dim[MACH_VECTOR_LENGTH]; +} + /* Loop structure of the function. The entire function is described as a NULL loop. */ diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h index a2fe8b68b22..cb4404504c5 100644 --- a/gcc/config/nvptx/nvptx.h +++ b/gcc/config/nvptx/nvptx.h @@ -218,6 +218,9 @@ struct GTY(()) machine_function int return_mode; /* Return mode of current fn. (machine_mode not defined yet.) */ rtx axis_predicate[2]; /* Neutering predicates. */ + int axis_dim[2]; /* Maximum number of threads on each axis, dim[0] is + vector_length, dim[1] is num_workers. */ + bool axis_dim_init_p; rtx unisimt_master; /* 'Master lane index' for -muniform-simt. */ rtx unisimt_predicate; /* Predicate for -muniform-simt. */ rtx unisimt_location; /* Mask location for -muniform-simt. */ --------------22652AB373EA1E7B04CDB186--