# portableKernelWorkContract

A portable kernel work contract record carrying rank, globalDimensions, localDimensions, boundsPolicy, localMemoryBytes, and related state.

Last updated: 2026-09-09

Package: compute.kernels | Status: source-declared

Tags: compute, compute.kernels, cpu, kernels, method, source-example, thing, yeho

Describe reusable compute kernels and their workload contracts.

```yh
external thing portableKernelWorkContract
```

- int rank: Stores rank as int.
- list of int globalDimensions: Stores global dimensions as list of int.
- list of int localDimensions: Stores local dimensions as list of int.
- text boundsPolicy: Stores bounds policy as text.
- int localMemoryBytes: Stores local memory bytes as int.
- int barrierCount: Stores barrier count as int.
- text barrierPolicy: Stores barrier policy as text.
- text reductionKind: Stores reduction kind as text.
- text reductionOrder: Stores reduction order as text.
- portableKernelWorkContract(int rank, list of int globalDimensions, list of int localDimensions, text boundsPolicy, int localMemoryBytes, int barrierCount, text barrierPolicy, text reductionKind, text reductionOrder): Portable kernel work contract.
- WorkItemCount() returns int: Work item count.
- DimensionValidationIssue() returns text: Dimension validation issue.
- MemoryAndBarrierValidationIssue(int localMemoryLimitBytes) returns text: Memory and barrier validation issue.
- ReductionValidationIssue() returns text: Reduction validation issue.
- ValidationIssue(int localMemoryLimitBytes) returns text: Validation issue.
- Describe() returns text: Describe.

## Use portableKernelWorkContract

A complete small caller. Values are illustrative; check the returned result and package requirements before connecting live resources.

Verification: type checked

```yh
using compute.kernels

// Describe reusable compute kernels and their workload contracts.
portableKernelWorkContract sample = portableKernelWorkContract(1, [], [], "bounds Policy", 4, 1, "barrier Policy", "reduction Kind", "reduction Order")
Console.Log(Text.From(sample.rank))

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.compute_kernels__portablekernelworkcontract"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

[[dependencies]]
package = "compute.kernels"
version = "0.1.0"
path = "../../../yeho/packages/compute/kernels"

[[dependencies]]
package = "compute.tensor"
version = "0.1.0"
path = "../../../yeho/packages/compute/tensor"

[[dependencies]]
package = "console"
version = "0.1.0"
path = "../../../yeho/packages/console"

[[dependencies]]
package = "diagnostics"
version = "0.1.0"
path = "../../../yeho/packages/diagnostics"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/compute.kernels--portableKernelWorkContract/usage --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


## portableKernelWorkContract.WorkItemCount

A complete caller for this public method. Sample inputs are illustrative; native resources require their owning lifecycle.

Verification: type checked

```yh
using compute.kernels

// Work item count.
portableKernelWorkContract instance = portableKernelWorkContract(1, [], [], "bounds Policy", 4, 1, "barrier Policy", "reduction Kind", "reduction Order")
int result = instance.WorkItemCount()
Console.Log(Text.From(result))

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.compute_kernels__portablekernelworkcontract"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

[[dependencies]]
package = "compute.kernels"
version = "0.1.0"
path = "../../../yeho/packages/compute/kernels"

[[dependencies]]
package = "compute.tensor"
version = "0.1.0"
path = "../../../yeho/packages/compute/tensor"

[[dependencies]]
package = "console"
version = "0.1.0"
path = "../../../yeho/packages/console"

[[dependencies]]
package = "diagnostics"
version = "0.1.0"
path = "../../../yeho/packages/diagnostics"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/compute.kernels--portableKernelWorkContract/method-WorkItemCount-10 --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


## portableKernelWorkContract.DimensionValidationIssue

A complete caller for this public method. Sample inputs are illustrative; native resources require their owning lifecycle.

Verification: type checked

```yh
using compute.kernels

// Dimension validation issue.
portableKernelWorkContract instance = portableKernelWorkContract(1, [], [], "bounds Policy", 4, 1, "barrier Policy", "reduction Kind", "reduction Order")
text result = instance.DimensionValidationIssue()
Console.Log(Text.From(result))

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.compute_kernels__portablekernelworkcontract"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

[[dependencies]]
package = "compute.kernels"
version = "0.1.0"
path = "../../../yeho/packages/compute/kernels"

[[dependencies]]
package = "compute.tensor"
version = "0.1.0"
path = "../../../yeho/packages/compute/tensor"

[[dependencies]]
package = "console"
version = "0.1.0"
path = "../../../yeho/packages/console"

[[dependencies]]
package = "diagnostics"
version = "0.1.0"
path = "../../../yeho/packages/diagnostics"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/compute.kernels--portableKernelWorkContract/method-DimensionValidationIssue-11 --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


## portableKernelWorkContract.MemoryAndBarrierValidationIssue

A complete caller for this public method. Sample inputs are illustrative; native resources require their owning lifecycle.

Verification: type checked

```yh
using compute.kernels

// Memory and barrier validation issue.
portableKernelWorkContract instance = portableKernelWorkContract(1, [], [], "bounds Policy", 4, 1, "barrier Policy", "reduction Kind", "reduction Order")
int argument_localMemoryLimitBytes = 4
text result = instance.MemoryAndBarrierValidationIssue(argument_localMemoryLimitBytes)
Console.Log(Text.From(result))

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.compute_kernels__portablekernelworkcontract"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

[[dependencies]]
package = "compute.kernels"
version = "0.1.0"
path = "../../../yeho/packages/compute/kernels"

[[dependencies]]
package = "compute.tensor"
version = "0.1.0"
path = "../../../yeho/packages/compute/tensor"

[[dependencies]]
package = "console"
version = "0.1.0"
path = "../../../yeho/packages/console"

[[dependencies]]
package = "diagnostics"
version = "0.1.0"
path = "../../../yeho/packages/diagnostics"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/compute.kernels--portableKernelWorkContract/method-MemoryAndBarrierValidationIssue-12 --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


## portableKernelWorkContract.ReductionValidationIssue

A complete caller for this public method. Sample inputs are illustrative; native resources require their owning lifecycle.

Verification: type checked

```yh
using compute.kernels

// Reduction validation issue.
portableKernelWorkContract instance = portableKernelWorkContract(1, [], [], "bounds Policy", 4, 1, "barrier Policy", "reduction Kind", "reduction Order")
text result = instance.ReductionValidationIssue()
Console.Log(Text.From(result))

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.compute_kernels__portablekernelworkcontract"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

[[dependencies]]
package = "compute.kernels"
version = "0.1.0"
path = "../../../yeho/packages/compute/kernels"

[[dependencies]]
package = "compute.tensor"
version = "0.1.0"
path = "../../../yeho/packages/compute/tensor"

[[dependencies]]
package = "console"
version = "0.1.0"
path = "../../../yeho/packages/console"

[[dependencies]]
package = "diagnostics"
version = "0.1.0"
path = "../../../yeho/packages/diagnostics"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/compute.kernels--portableKernelWorkContract/method-ReductionValidationIssue-13 --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


## portableKernelWorkContract.ValidationIssue

A complete caller for this public method. Sample inputs are illustrative; native resources require their owning lifecycle.

Verification: type checked

```yh
using compute.kernels

// Validation issue.
portableKernelWorkContract instance = portableKernelWorkContract(1, [], [], "bounds Policy", 4, 1, "barrier Policy", "reduction Kind", "reduction Order")
int argument_localMemoryLimitBytes = 4
text result = instance.ValidationIssue(argument_localMemoryLimitBytes)
Console.Log(Text.From(result))

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.compute_kernels__portablekernelworkcontract"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

[[dependencies]]
package = "compute.kernels"
version = "0.1.0"
path = "../../../yeho/packages/compute/kernels"

[[dependencies]]
package = "compute.tensor"
version = "0.1.0"
path = "../../../yeho/packages/compute/tensor"

[[dependencies]]
package = "console"
version = "0.1.0"
path = "../../../yeho/packages/console"

[[dependencies]]
package = "diagnostics"
version = "0.1.0"
path = "../../../yeho/packages/diagnostics"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/compute.kernels--portableKernelWorkContract/method-ValidationIssue-14 --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


## portableKernelWorkContract.Describe

A complete caller for this public method. Sample inputs are illustrative; native resources require their owning lifecycle.

Verification: type checked

```yh
using compute.kernels

// Describe.
portableKernelWorkContract instance = portableKernelWorkContract(1, [], [], "bounds Policy", 4, 1, "barrier Policy", "reduction Kind", "reduction Order")
text result = instance.Describe()
Console.Log(Text.From(result))

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.compute_kernels__portablekernelworkcontract"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

[[dependencies]]
package = "compute.kernels"
version = "0.1.0"
path = "../../../yeho/packages/compute/kernels"

[[dependencies]]
package = "compute.tensor"
version = "0.1.0"
path = "../../../yeho/packages/compute/tensor"

[[dependencies]]
package = "console"
version = "0.1.0"
path = "../../../yeho/packages/console"

[[dependencies]]
package = "diagnostics"
version = "0.1.0"
path = "../../../yeho/packages/diagnostics"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/compute.kernels--portableKernelWorkContract/method-Describe-15 --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Package presence and a declaration do not establish support on every host. Host services need their platform and lifecycle setup.

Source: yeho/packages/compute/kernels/portable_contract.yh

AI training permission: https://demonhunterlabs.com/ai-use
