Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ struct MXFlatmmPipelineAgBgCrPolicy : UniversalFlatmmPipelineAgBgCrPolicy
sequence<1>>{});
else
return make_static_tile_distribution(
tile_distribution_encoding< //
tile_distribution_encoding<
sequence<NWarps>,
tuple<sequence<MWarps, MXdlPack, MPerXdl>,
sequence<K_Thread / AK1, K_Lane, AK1 / APackedSize>>,
Expand Down
4 changes: 0 additions & 4 deletions include/ck_tile/ops/reduce/block/block_reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,4 @@ struct BlockReduce2D
InDataType reduce_init;
};

// deduction guide
template <typename T>
CK_TILE_HOST_DEVICE_EXTERN BlockReduce2D(const T&, const typename T::DataType&) -> BlockReduce2D<T>;

} // namespace ck_tile
2 changes: 1 addition & 1 deletion include/ck_tile/ops/softmax/block/block_softmax_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct BlockSoftmax2D
#endif

// compute row max
auto reduce_row_max = BlockReduce2D{x, -numeric<DataType>::infinity()};
auto reduce_row_max = BlockReduce2D<decltype(x)>{x, -numeric<DataType>::infinity()};
#if _BLOCK_SOFTMAX_USE_UNPACK2
auto row_max = reduce_row_max(f_max3, f_max, sequence<1, 2>{});
#else
Expand Down
143 changes: 143 additions & 0 deletions script/tools/ck-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/bin/bash
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier: MIT

# CK Build - Build Composable Kernel targets in Docker

set -e
set -o pipefail

# Find script directory and load common utilities
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/common.sh"

# Initialize configuration
PROJECT_ROOT=$(get_project_root "${SCRIPT_DIR}")
CONTAINER_NAME=$(get_container_name "${PROJECT_ROOT}")

# Help message
show_help() {
cat << EOF
CK Build - Build Composable Kernel targets in Docker

Usage: ck-build [options] [target...]

Options:
-h, --help Show this help message
--name <name> Specify container name
--reconfigure Reconfigure CMake before building
-j <N> Parallel jobs (passed to ninja)
--clean Clean before building

Arguments:
target Target(s) to build (default: all)

Environment:
CK_CONTAINER_NAME - Override default container name
GPU_TARGET - Override GPU target detection (e.g., gfx950, gfx942)

Examples:
ck-build # Build all targets
ck-build test_amdgcn_mma # Build specific target
ck-build test_amdgcn_mma test_gemm # Build multiple targets
ck-build --reconfigure # Reconfigure CMake and build all
ck-build --clean test_amdgcn_mma # Clean and build target
ck-build -j 8 test_amdgcn_mma # Build with 8 parallel jobs

EOF
}

# Parse arguments
targets=()
reconfigure=false
clean=false
parallel_jobs=""

while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_help
exit 0
;;
--name)
CONTAINER_NAME="$2"
shift 2
;;
--reconfigure)
reconfigure=true
shift
;;
--clean)
clean=true
shift
;;
-j)
parallel_jobs="-j $2"
shift 2
;;
*)
targets+=("$1")
shift
;;
esac
done

# Ensure container is running
if ! container_is_running "${CONTAINER_NAME}"; then
echo "Container '${CONTAINER_NAME}' not running. Starting..."
"${SCRIPT_DIR}/ck-start" "${CONTAINER_NAME}"
echo ""
fi

# Configure CMake if needed or requested
if [ "$reconfigure" = true ] || ! docker exec "${CONTAINER_NAME}" test -f /workspace/build/build.ninja 2>/dev/null; then
echo "Detecting GPU target..."
GPU_TARGET_DETECTED=$(detect_gpu_target "${CONTAINER_NAME}")

if [ "$reconfigure" = true ]; then
echo "Reconfiguring CMake from scratch for GPU target: ${GPU_TARGET_DETECTED}"
else
echo "Configuring build with CMake for GPU target: ${GPU_TARGET_DETECTED}"
fi

docker exec "${CONTAINER_NAME}" bash -c "
cd /workspace || exit 1
rm -rf /workspace/build
mkdir /workspace/build
cd /workspace/build || exit 1
cmake .. -GNinja \
-DGPU_TARGETS=${GPU_TARGET_DETECTED} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ \
-DBUILD_TESTING=ON 2>&1 | tail -30
"
echo ""
fi

# Clean if requested
if [ "$clean" = true ]; then
echo "Cleaning build directory..."
docker exec "${CONTAINER_NAME}" bash -c "
cd /workspace/build || exit 1
ninja clean
"
echo ""
fi

# Build targets
if [ ${#targets[@]} -eq 0 ]; then
echo "Building all configured targets..."
docker exec "${CONTAINER_NAME}" bash -c "
cd /workspace/build || exit 1
ninja ${parallel_jobs} 2>&1
"
else
echo "Building targets: ${targets[*]}"
docker exec "${CONTAINER_NAME}" bash -c "
cd /workspace/build || exit 1
ninja ${parallel_jobs} ${targets[*]} 2>&1
"
fi

echo ""
echo "Build complete ✓"
113 changes: 113 additions & 0 deletions script/tools/ck-clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/bash
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier: MIT

# CK Clean - Clean build artifacts in Docker container

set -e
set -o pipefail

# Find script directory and load common utilities
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/common.sh"

# Initialize configuration
PROJECT_ROOT=$(get_project_root "${SCRIPT_DIR}")
CONTAINER_NAME=$(get_container_name "${PROJECT_ROOT}")

# Help message
show_help() {
cat << EOF
CK Clean - Clean build artifacts in Docker container

Usage: ck-clean [options]

Options:
-h, --help Show this help message
--name <name> Specify container name
--all Remove entire build directory
-f, --force Force without confirmation

Environment:
CK_CONTAINER_NAME - Override default container name

Examples:
ck-clean # Clean build artifacts (ninja clean)
ck-clean --all # Remove entire build directory
ck-clean --force --all # Remove build directory without confirmation

EOF
}

# Parse arguments
remove_all=false
force=false

while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_help
exit 0
;;
--name)
CONTAINER_NAME="$2"
shift 2
;;
--all)
remove_all=true
shift
;;
-f|--force)
force=true
shift
;;
*)
echo "Unknown option: $1"
show_help
exit 1
;;
esac
done

# Check if container is running
if ! container_is_running "${CONTAINER_NAME}"; then
echo "Container '${CONTAINER_NAME}' not running"
echo "Start with: ck-start"
exit 1
fi

# Check if build directory exists
if ! docker exec "${CONTAINER_NAME}" test -d /workspace/build 2>/dev/null; then
echo "Build directory does not exist"
exit 0
fi

if [ "$remove_all" = true ]; then
# Remove entire build directory
if [ "$force" = false ]; then
read -p "Remove entire build directory? (y/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Cancelled"
exit 0
fi
fi

echo "Removing build directory..."
docker exec "${CONTAINER_NAME}" bash -c "rm -rf /workspace/build"
echo "Build directory removed ✓"
else
# Clean with ninja
if ! docker exec "${CONTAINER_NAME}" test -f /workspace/build/build.ninja 2>/dev/null; then
echo "Build not configured (build.ninja not found)"
echo "Use --all to remove build directory"
exit 1
fi

echo "Cleaning build artifacts..."
docker exec "${CONTAINER_NAME}" bash -c "
cd /workspace/build || exit 1
ninja clean
"
echo "Build artifacts cleaned ✓"
fi
111 changes: 111 additions & 0 deletions script/tools/ck-exec
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/bash
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier: MIT

# CK Exec - Execute arbitrary commands in Docker container

set -e
set -o pipefail

# Find script directory and load common utilities
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/common.sh"

# Initialize configuration
PROJECT_ROOT=$(get_project_root "${SCRIPT_DIR}")
CONTAINER_NAME=$(get_container_name "${PROJECT_ROOT}")

# Help message
show_help() {
cat << EOF
CK Exec - Execute arbitrary commands in Docker container

Usage: ck-exec [options] <command> [args...]

Options:
-h, --help Show this help message
--name <name> Specify container name
-w <dir> Working directory (default: /workspace)
-i, --interactive Interactive mode (allocate TTY)

Arguments:
command Command to execute (required)
args Arguments to the command

Environment:
CK_CONTAINER_NAME - Override default container name

Examples:
ck-exec rocm-smi # Run rocm-smi
ck-exec rocminfo # Run rocminfo
ck-exec ls -la build/bin # List build binaries
ck-exec -w /workspace/build ninja -t commands # Run ninja commands
ck-exec --interactive python3 # Interactive Python session

Common Commands:
ck-exec rocm-smi # Check GPU status
ck-exec rocminfo \| grep gfx # Check GPU architecture
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pipe character should not be escaped in the comment. It should be '|' instead of '|'.

Suggested change
ck-exec rocminfo \| grep gfx # Check GPU architecture
ck-exec rocminfo | grep gfx # Check GPU architecture

Copilot uses AI. Check for mistakes.
ck-exec hipcc --version # Check HIP compiler version
ck-exec cmake --version # Check CMake version
ck-exec ninja -C build -t targets # List all build targets

EOF
}

# Parse arguments
workdir="/workspace"
interactive=false
command_args=()

while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_help
exit 0
;;
--name)
CONTAINER_NAME="$2"
shift 2
;;
-w)
workdir="$2"
shift 2
;;
-i|--interactive)
interactive=true
shift
;;
*)
command_args+=("$1")
shift
;;
esac
done

# Validate command
if [ ${#command_args[@]} -eq 0 ]; then
echo "Error: command required"
echo ""
show_help
exit 1
fi

# Ensure container is running
if ! container_is_running "${CONTAINER_NAME}"; then
echo "Container '${CONTAINER_NAME}' not running. Starting..."
"${SCRIPT_DIR}/ck-start" "${CONTAINER_NAME}"
echo ""
fi

# Build command string
cmd_string=""
for arg in "${command_args[@]}"; do
cmd_string="${cmd_string} $(printf '%q' "$arg")"
done

# Execute command
if [ "$interactive" = true ]; then
docker exec -it -w "${workdir}" "${CONTAINER_NAME}" bash -c "${cmd_string}"
else
docker exec -w "${workdir}" "${CONTAINER_NAME}" bash -c "${cmd_string}"
fi
Loading