]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[nvptx] Add nvptx_mach_vector_length, nvptx_mach_max_workers
authorvries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Jan 2019 15:08:36 +0000 (15:08 +0000)
committervries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Jan 2019 15:08:36 +0000 (15:08 +0000)
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  <tdevries@suse.de>

* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267558 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/nvptx/nvptx.c
gcc/config/nvptx/nvptx.h

index 1b57031801ba30137323aa84bd32f7beabe35102..40b1fdf22ddabed67f44b370c46c102bcc928089 100644 (file)
@@ -1,3 +1,10 @@
+2019-01-03  Tom de Vries  <tdevries@suse.de>
+
+       * 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.
+
 2019-01-03  Tom de Vries  <tdevries@suse.de>
 
        * config/nvptx/nvptx.c (struct offload_attrs): New.
index 15425337939088444e042ea5907cdd4fe0f22fe4..5d0bab65d076f0f73bf636e035f0deaa21a0e5ee 100644 (file)
@@ -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.  */
 
index 64134d461284e16a1e0e5afb5bab73641b94185a..a05ff7ec9bec9d8b4e21314b2f7286ef268b9465 100644 (file)
@@ -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.  */