---
title: "TS8077 KERNEL_WORKGROUP_REDUCES: TypeShade 컴파일러의 오류 코드"
description: "TS8077 KERNEL_WORKGROUP_REDUCES, TypeShade 컴파일러의 오류 코드입니다. @workgroup_size가 붙은 커널 함수에 환원하는 루프가 있습니다(규칙 8.22)."
url: https://typeshade.dev/ko/reference/errors/ts8077/
language: ko
---

# `TS8077`

프런트엔드 코드 `KERNEL_WORKGROUP_REDUCES`

`@workgroup_size`가 붙은 커널 함수에 환원하는 루프가 있습니다([규칙 8.22](https://typeshade.dev/ko/reference/rules/8-22/)). 환원은 늘 256 크기의 트리로 실행되므로 다른 크기를 요청하는 속성은 지킬 수 없습니다. 메시지가 함수와 고칠 방법을 알려 줍니다.

레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.

레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

## 예제

example.shade.ts

```ts
"use typeshade"

@workgroup_size([128])
export function total(xs: array<f32>): f32 {
  let s = 0.
  for (let i: u32 = 0; i < xs.length; i++) {
    s += xs[i]
  }
  return s
}
```

빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.

**TS8077** error, 6행: "total" has a loop that reduces, which always runs in workgroups of 256. Declare "total" without workgroup\_size, or put the reduction in a function of its own.

## 고치는 법

같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.

example.shade.ts

```ts
"use typeshade"

export function total(xs: array<f32>): f32 {
  let s = 0.
  for (let i: u32 = 0; i < xs.length; i++) {
    s += xs[i]
  }
  return s
}
```

## 이 코드가 적용하는 규칙

**[규칙 8.22](https://typeshade.dev/ko/reference/rules/8-22/) 테스트**

A kernel function is an exported function that is not an entry point, a function declaration, and takes at least one array with no size (`array<T>`) or one 2D storage texture (`texture_storage_2d<F, A>`, change 0077), or returns an array with no size that its body makes ([Rule 8.23](https://typeshade.dev/ko/reference/rules/8-23/), change 0114, S5); a sampled texture alone does not make one, so an exported helper that reads one stays a helper an entry calls; its candidate loops are the `for` and `for…of` statements at the top level of its body, and no other loop is ever a candidate.

## 함께 보기

- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.

- [`src/compiler/ts/kernel-loops.ts:82`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/kernel-loops.ts#L82)
