---
title: "workgroup_size: TypeShade 언어 참조에 실린 어트리뷰트 이름과 그 시그니처"
description: "workgroup_size (어트리뷰트), TypeShade 언어 참조 항목입니다. Optionally states the workgroup size of each loop that does not reduce in a kernel function…"
url: https://typeshade.dev/ko/reference/attributes/workgroup_size/
language: ko
---

# `@workgroup_size`

어트리뷰트

Optionally states the workgroup size of each loop that does not reduce in a kernel function, an exported function that takes an array with no size or a 2D storage texture, as one extent: `@workgroup_size([128]) export function scale(xs: array<f32>) { … }`.

`@workgroup_size([n])`은 표시한 커널 함수의 루프가 WebGPU에서 실행될 워크그룹 크기를 정합니다.

## 예제 비교

기본값으로 도는 루프, 128로 도는 루프, 리덕션을 하는 루프를 비교합니다. 리덕션을 하는 루프는 무엇을 적든 256으로 실행됩니다.

**예제 프로그램**`@workgroup_size([128]) export function scale(xs: array<f32>): void { for (let i = 0; i < xs.length; i++) { xs[i] = xs[i] * 2.; } }`

**예제 1`@workgroup_size 없음`**

**결과**

`64`

**예제 2`@workgroup_size([128])`**

**결과**

`128`

**예제 3`리덕션을 하는 루프`**

**결과**

`256`

예제는 설명용 계산 모델이며 GPU를 실행하지 않습니다. 속성의 문법은 아래 컴파일러 참고 자료에서 설명합니다. 소수 결과는 표시할 때 반올림했습니다. 각 예제는 명시한 전제를 따릅니다. 실제 셰이더의 결과는 대상 언어의 정밀도와 실행 규칙에 따릅니다.

## 활용

커널 함수의 루프를 기본값 64가 아닌 크기의 워크그룹으로 실행해야 할 때 사용합니다.

## 입력 범위와 주의사항

축 크기는 하나만 받으며, 커널 함수에만 쓸 수 있습니다. 리덕션을 하는 루프가 있는 커널 함수는 이 속성을 거부합니다(TS8077).

셰이더의 입력 규칙과 정밀도는 [WGSL](https://www.w3.org/TR/WGSL/)과 [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf)에서 규정합니다.

## 관련 속성

- [`@compute`](https://typeshade.dev/ko/reference/attributes/compute/)

시그니처와 이름 아래 문장, 컴파일러 메시지는 커밋 af54ddad5의 컴파일러가 쓴 영어 원문입니다.

## 구문

```ts
declare function workgroup_size(size: readonly [x: number]): (target: Function, context?: unknown) => void
```

## 매개변수

- `size` `readonly [x: number]`

선언에는 TypeScript 데코레이터 런타임이 넘겨주는 `target`과 `context`도 적혀 있습니다. 호출에서는 둘 다 쓰지 않습니다.

## 설명

Without it the compiler chooses the size, and a loop that reduces runs at 256 whatever is written. An entry takes its size as `@compute([128])`.

## 함께 보기

- [어트리뷰트](https://typeshade.dev/ko/reference/attributes/)
