# FindKernel(string)

> Find ComputeShader kernel index.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public int FindKernel(string name)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of kernel function as defined in the compute shader source file.

### Returns

| Type                                                       | Description                                                                                                                   |
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The Kernel index. If the kernel is not found, Unity logs a "FindKernel failed" error message and raises an ArgumentException. |

### Remarks

A single compute shader can contain many "kernels" (functions that do the computation); FindKernel returns kernel index given the name.

Additional Resources: [ComputeShader.Dispatch](/engine/6000.7/script-reference/unityengine/computeshader/dispatch.md).

### Examples

```csharp
using UnityEngine;

public class ComputeShaderExample : MonoBehaviour
{
    public ComputeShader computeShader;

    void Start()
    {
        // Find the kernel named "CSMain" in the compute shader
        int kernelHandle = computeShader.FindKernel("CSMain");

        // Log the kernel index
        Debug.Log($"Kernel 'CSMain' found at index: {kernelHandle}");
    }
}
```
