gallium: add PIPE_COMPUTE_CAP_SUBGROUP_SIZE
authorGrigori Goronzy <greg@chown.ath.cx>
Thu, 28 May 2015 10:40:29 +0000 (12:40 +0200)
committerGrigori Goronzy <greg@chown.ath.cx>
Mon, 29 Jun 2015 11:24:22 +0000 (13:24 +0200)
We need this to implement OpenCL's
CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/gallium/docs/source/screen.rst
src/gallium/drivers/ilo/ilo_screen.c
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/include/pipe/p_defines.h

index 8f64817fe5fd37e7cf627b97f1dca6963e216e8f..74636207d06fdb4fe7871893109908b038ee8d6a 100644 (file)
@@ -384,6 +384,8 @@ pipe_screen::get_compute_param.
   Value type: ``uint32_t``
 * ``PIPE_COMPUTE_CAP_IMAGES_SUPPORTED``: Whether images are supported
   non-zero means yes, zero means no. Value type: ``uint32_t``
+* ``PIPE_COMPUTE_CAP_SUBGROUP_SIZE``: The size of a basic execution unit in
+  threads. Also known as wavefront size, warp size or SIMD width.
 
 .. _pipe_bind:
 
index 94105559b80d3e1bacf537406d85a5add7ccb2c5..faebb9279b3376c02cfd0fbca3ca23d198b98277 100644 (file)
@@ -193,6 +193,7 @@ ilo_get_compute_param(struct pipe_screen *screen,
       uint32_t max_clock_frequency;
       uint32_t max_compute_units;
       uint32_t images_supported;
+      uint32_t subgroup_size;
    } val;
    const void *ptr;
    int size;
@@ -284,6 +285,13 @@ ilo_get_compute_param(struct pipe_screen *screen,
       ptr = &val.images_supported;
       size = sizeof(val.images_supported);
       break;
+   case PIPE_COMPUTE_CAP_SUBGROUP_SIZE:
+      /* best case is actually SIMD32 */
+      val.subgroup_size = 16;
+
+      ptr = &val.subgroup_size;
+      size = sizeof(val.subgroup_size);
+      break;
    default:
       ptr = NULL;
       size = 0;
index 56c230e42fc2b2cc50a0d7c31cb84e9536f55113..4c53106289ce128d3a6a3bb1b18887a8d8898b52 100644 (file)
@@ -341,6 +341,7 @@ nvc0_screen_get_compute_param(struct pipe_screen *pscreen,
                               enum pipe_compute_cap param, void *data)
 {
    uint64_t *data64 = (uint64_t *)data;
+   uint32_t *data32 = (uint32_t *)data;
    const uint16_t obj_class = nvc0_screen(pscreen)->compute->oclass;
 
    switch (param) {
@@ -372,6 +373,9 @@ nvc0_screen_get_compute_param(struct pipe_screen *pscreen,
    case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE: /* c[], arbitrary limit */
       data64[0] = 4096;
       return 8;
+   case PIPE_COMPUTE_CAP_SUBGROUP_SIZE:
+      data32[0] = 32;
+      return 4;
    default:
       return 0;
    }
index 3def44468823557cea70140ec50c9e7da037fe2a..775cf53ba88aaaf53e02abf7f0332fa910b5a4d8 100644 (file)
@@ -636,6 +636,12 @@ static int r600_get_compute_param(struct pipe_screen *screen,
                return sizeof(uint32_t);
        case PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE:
                break; /* unused */
+       case PIPE_COMPUTE_CAP_SUBGROUP_SIZE:
+               if (ret) {
+                       uint32_t *subgroup_size = ret;
+                       *subgroup_size = r600_wavefront_size(rscreen->family);
+               }
+               return sizeof(uint32_t);
        }
 
         fprintf(stderr, "unknown PIPE_COMPUTE_CAP %d\n", param);
index 6ce81d33ddd087fbf03bd5e6a884fdb4f4ccb2a5..51fd016229ca061759cd3766a638dfa3ec58a42b 100644 (file)
@@ -570,6 +570,26 @@ static inline unsigned r600_tex_aniso_filter(unsigned filter)
         /* else */        return 4;
 }
 
+static inline unsigned r600_wavefront_size(enum radeon_family family)
+{
+       switch (family) {
+       case CHIP_RV610:
+       case CHIP_RS780:
+       case CHIP_RV620:
+       case CHIP_RS880:
+               return 16;
+       case CHIP_RV630:
+       case CHIP_RV635:
+       case CHIP_RV730:
+       case CHIP_RV710:
+       case CHIP_PALM:
+       case CHIP_CEDAR:
+               return 32;
+       default:
+               return 64;
+       }
+}
+
 #define COMPUTE_DBG(rscreen, fmt, args...) \
        do { \
                if ((rscreen->b.debug_flags & DBG_COMPUTE)) fprintf(stderr, fmt, ##args); \
index 88b7b7699c1719353c4f5a69016c6037808d4a31..153897af7545370c688bab7136a850c8aa0b600f 100644 (file)
@@ -700,7 +700,8 @@ enum pipe_compute_cap
    PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE,
    PIPE_COMPUTE_CAP_MAX_CLOCK_FREQUENCY,
    PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS,
-   PIPE_COMPUTE_CAP_IMAGES_SUPPORTED
+   PIPE_COMPUTE_CAP_IMAGES_SUPPORTED,
+   PIPE_COMPUTE_CAP_SUBGROUP_SIZE
 };
 
 /**