<p>The hardware is the same either way, and the execution models are the same. It's the underlying execution model and hardware that creates this effect. So they will be the same for OpenGL compute shaders and OpenCL.</p>

CC BY-SA 4.0
2022-11-02T14:39:53.920Z
so using 32x1x1 invocation per workgroup should be faster than using 1x1x1invocations
Thomas
CC BY-SA 4.0
2022-11-02T14:26:22.100Z
2022-11-02T14:26:22.100Z
Nicol Bolas
<p>I've read, that OpenCL kernels are grouped like OpenGL compute shaders. That means, that you can define how many invocations should be executed within a workgroup. These invocations which are in the same workgroup, can communicate with so called <code>shared</code> variables.</p>
<p>In OpenCL there is the CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE also called warp size. Which is 32 for my GPU. That means, when allocating less than 32 invocations per workgroup (OpenCL), your GPU is not fully used. As far as I understood, it has to do with hardware specifications. Where 32 cores on my GPU are grouped together as a warp and also executed together. When allocating less than 32 invocations, the rest of the cores within that hardware group are not used or idle.</p>
<p>Do I have the same restrictions on OpenGL compute shaders? My GPU has 3072 shader units, when executing a post processing algorithm on OpenGL compute shader, does it make sense to allocate the workgroup size to be a multiple of 32? Even, when no interaction between neighboring pixels exists?</p>
<p>For example we have a 1024 x 1024 rgb32f image, and we only want to apply some calculation to it ... we could define workgroup size to be x,y,z = 1. and execute 1024 x 1024 x 1 workgroups. Or, we can define workgroup size to be x = 32 and y,z = 1 and execute 32 x 1024 x 1 workgroups.</p>
<p>maybe your answer is: Yes of cause, it is hardware specified... but I also think about the shader compiler... maybe it is trying to perfectly spread the work to the cores.</p>

CC BY-SA 4.0
2022-11-02T14:48:17.893Z
Here is a link that has some nice perf tips. It is AMD specific, but many of the other vendors have similar tips (specific to compute shaders not the entire guide) The compute recommendations are near the bottom of the page. https://gpuopen.com/performance/
pmw1234
<opengl><compute-shader>
OpenCL WorkGroupSize compared to OpenGL compute shader WorkGroupSize
Thomas
# OpenCL WorkGroupSize compared to OpenGL compute shader WorkGroupSize

(Asked by: username_0 on 2022-11-02)

I've read, that OpenCL kernels are grouped like OpenGL compute shaders. That means, that you can define how many invocations should be executed within a workgroup. These invocations which are in the same workgroup, can communicate with so called `shared` variables.

In OpenCL there is the CL\_KERNEL\_PREFERRED\_WORK\_GROUP\_SIZE\_MULTIPLE also called warp size. Which is 32 for my GPU. That means, when allocating less than 32 invocations per workgroup (OpenCL), your GPU is not fully used. As far as I understood, it has to do with hardware specifications. Where 32 cores on my GPU are grouped together as a warp and also executed together. When allocating less than 32 invocations, the rest of the cores within that hardware group are not used or idle.

Do I have the same restrictions on OpenGL compute shaders? My GPU has 3072 shader units, when executing a post processing algorithm on OpenGL compute shader, does it make sense to allocate the workgroup size to be a multiple of 32? Even, when no interaction between neighboring pixels exists?

For example we have a 1024 x 1024 rgb32f image, and we only want to apply some calculation to it ... we could define workgroup size to be x,y,z = 1. and execute 1024 x 1024 x 1 workgroups. Or, we can define workgroup size to be x = 32 and y,z = 1 and execute 32 x 1024 x 1 workgroups.

maybe your answer is: Yes of cause, it is hardware specified... but I also think about the shader compiler... maybe it is trying to perfectly spread the work to the cores.

**Tags:** opengl, compute-shader

> **Comments:**
> **username_1**: Here is a link that has some nice perf tips. It is AMD specific, but many of the other vendors have similar tips (specific to compute shaders not the entire guide) The compute recommendations are near the bottom of the page. https://gpuopen.com/performance/  

---

## 1 answers

### Answer by username_2 on 2022-11-02. Score: 1 | Accepted answer

The hardware is the same either way, and the execution models are the same. It's the underlying execution model and hardware that creates this effect. So they will be the same for OpenGL compute shaders and OpenCL.

> **Comments:**
> **username_0**: so using 32x1x1 invocation per workgroup should be faster than using 1x1x1invocations  

---

