Is there a way to know the number of kernels that a GPU has?

That’s for tuning the number of kernels in ComputeShader.Dispatch.

First I thought you are asking for the number of #pragma kernel lines in a compute shader.
Then I thought, you are asking for the thread group size of a kernel as it’s defined in the shader.
But, now I’m thinking, you would like to know what the best thread group size is to choose.

I’m not aware that there is a way to query that with any API. The usual recommendation is to use a power-of-two size between 64 and 256. If you don’t use group-shared memory, it’s usually better to use a smaller number. If you do use group-shared memory, it’s usually better to use a bigger number. But it depends on the shader, so you have to experiment.

This has already been answered many times before:

https://www.intel.com/content/www/us/en/develop/documentation/iocl-opg/top/optimizing-opencl-usage-with-intel-processor-graphics/work-group-size-recommendations-summary.html
https://www.reddit.com/r/vulkan/comments/u3i6we/what_does_the_local_workgroup_size_in_compute/

Oh thanks, I was afraid of using too many threads with 64 on Xe but that seems to be the sweet spot.