Files
composable_kernel/example/ck_tile/tutorial
2025-05-18 18:34:17 +08:00
..
2025-05-18 17:24:14 +08:00
2025-05-18 17:24:14 +08:00
2025-05-18 18:34:17 +08:00
2025-05-18 17:24:14 +08:00
2025-05-18 18:21:11 +08:00

CK_TILE Tutorial Example

This folder demonstrates the examples implemented using ck_tile

Build Instructions

Follow these steps to build the examples:

cd composable_kernel
mkdir build
cd build

cmake -D CMAKE_PREFIX_PATH=/opt/rocm \
      -D CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc \
      -D CMAKE_BUILD_TYPE=Release \
      -D GPU_TARGETS="gfx942" \
      -Dkernel=N ..

Compile Examples

Basic Add Example

make -j add_basic

Elementwise Add Example

make -j add

GEMM Example

make -j basic_gemm

Flash Attention Forward Example

make -j basic_flash_attention_fwd

Running Examples

Basic Add Example

./bin/add_basic

Elementwise Add

./bin/add

GEMM Example

./bin/basic_gemm 1

Flash Attention Forward Example

./bin/basic_flash_attention_fwd 1 1

Advanced part

GEMM Example

Follow these steps to build and run the different kernels:

cd composable_kernel
mkdir build
cd build

# for naive kernel
cmake -D CMAKE_PREFIX_PATH=/opt/rocm -D CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc -D CMAKE_BUILD_TYPE=Release -D GPU_TARGETS="gfx942" -Dkernel=N .. && make -j basic_gemm

# for kernel A
cmake -D CMAKE_PREFIX_PATH=/opt/rocm -D CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc -D CMAKE_BUILD_TYPE=Release -D GPU_TARGETS="gfx942" -Dkernel=A .. && make -j basic_gemm

# for kernel B
cmake -D CMAKE_PREFIX_PATH=/opt/rocm -D CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc -D CMAKE_BUILD_TYPE=Release -D GPU_TARGETS="gfx942" -Dkernel=B .. && make -j basic_gemm

...

# for kernel H
cmake -D CMAKE_PREFIX_PATH=/opt/rocm -D CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc -D CMAKE_BUILD_TYPE=Release -D GPU_TARGETS="gfx942" -Dkernel=H .. && make -j basic_gemm

./bin/basic_gemm 1

Flash Attention Forward Example

Follow these steps to build the kernels
# for naive kernel
cmake -D CMAKE_PREFIX_PATH=/opt/rocm -D CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc -D CMAKE_BUILD_TYPE=Release -D GPU_TARGETS="gfx942" .. && make -j basic_flash_attention_fwd

# for optimized kernel
cmake -D CMAKE_PREFIX_PATH=/opt/rocm -D CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc -D CMAKE_BUILD_TYPE=Release -D GPU_TARGETS="gfx942" -DENABLE_TOY_FA_FWD_OPT=ON .. && make -j basic_flash_attention_fwd
./bin/basic_flash_attention_fwd 1 1
Follow these steps to build and run the codegen instances
mkdir build
cd build
../script/cmake-ck-release.sh .. gfx942
make -j codegen_basic_flash_attention_fwd
./bin/codegen_basic_flash_attention_fwd 1 1 64 16384 16384 128 128