mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-04-19 22:39:03 +00:00
Solve the CTAD regression & add up the Shell file for the docker management in testing (#3634)
* Finished the work * Fix the pipeline
This commit is contained in:
143
script/tools/ck-build
Executable file
143
script/tools/ck-build
Executable file
@@ -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
script/tools/ck-clean
Executable file
113
script/tools/ck-clean
Executable file
@@ -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
script/tools/ck-exec
Executable file
111
script/tools/ck-exec
Executable file
@@ -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
|
||||
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
|
||||
134
script/tools/ck-logs
Executable file
134
script/tools/ck-logs
Executable file
@@ -0,0 +1,134 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# CK Logs - View container logs and build output
|
||||
|
||||
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 Logs - View container logs and build output
|
||||
|
||||
Usage: ck-logs [options] [container_name]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
--name <name> Specify container name
|
||||
-f, --follow Follow log output
|
||||
-n, --tail <N> Show last N lines (default: 100)
|
||||
--cmake Show CMake configuration log
|
||||
--build Show last build log
|
||||
|
||||
Arguments:
|
||||
container_name Optional container name (default: ck_<username>_<branch>)
|
||||
|
||||
Environment:
|
||||
CK_CONTAINER_NAME - Override default container name
|
||||
|
||||
Examples:
|
||||
ck-logs # Show last 100 lines of container logs
|
||||
ck-logs -f # Follow container logs
|
||||
ck-logs -n 500 # Show last 500 lines
|
||||
ck-logs --cmake # Show CMake configuration
|
||||
ck-logs --build # Show build log
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Parse arguments
|
||||
follow=false
|
||||
tail_lines=100
|
||||
show_cmake=false
|
||||
show_build=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
--name)
|
||||
CONTAINER_NAME="$2"
|
||||
shift 2
|
||||
;;
|
||||
-f|--follow)
|
||||
follow=true
|
||||
shift
|
||||
;;
|
||||
-n|--tail)
|
||||
tail_lines="$2"
|
||||
shift 2
|
||||
;;
|
||||
--cmake)
|
||||
show_cmake=true
|
||||
shift
|
||||
;;
|
||||
--build)
|
||||
show_build=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
CONTAINER_NAME="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if container exists
|
||||
if ! container_exists "${CONTAINER_NAME}"; then
|
||||
echo "Container '${CONTAINER_NAME}' does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Show CMake log
|
||||
if [ "$show_cmake" = true ]; then
|
||||
echo "CMake Configuration Log:"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
|
||||
if docker exec "${CONTAINER_NAME}" test -f /workspace/build/CMakeCache.txt 2>/dev/null; then
|
||||
docker exec "${CONTAINER_NAME}" bash -c "
|
||||
cd /workspace/build
|
||||
echo 'GPU_TARGETS:' \$(grep 'GPU_TARGETS:' CMakeCache.txt | cut -d'=' -f2)
|
||||
echo 'CMAKE_BUILD_TYPE:' \$(grep 'CMAKE_BUILD_TYPE:' CMakeCache.txt | cut -d'=' -f2)
|
||||
echo 'CMAKE_CXX_COMPILER:' \$(grep 'CMAKE_CXX_COMPILER:' CMakeCache.txt | cut -d'=' -f2)
|
||||
echo 'BUILD_TESTING:' \$(grep 'BUILD_TESTING:' CMakeCache.txt | cut -d'=' -f2)
|
||||
"
|
||||
else
|
||||
echo "CMake not configured yet"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Show build log (last build output)
|
||||
if [ "$show_build" = true ]; then
|
||||
echo "Last Build Log:"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
|
||||
if docker exec "${CONTAINER_NAME}" test -f /workspace/build/.ninja_log 2>/dev/null; then
|
||||
docker exec "${CONTAINER_NAME}" bash -c "tail -50 /workspace/build/.ninja_log"
|
||||
else
|
||||
echo "No build log found"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Show container logs
|
||||
echo "Container Logs (${CONTAINER_NAME}):"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
|
||||
if [ "$follow" = true ]; then
|
||||
docker logs -f "${CONTAINER_NAME}"
|
||||
else
|
||||
docker logs --tail "${tail_lines}" "${CONTAINER_NAME}"
|
||||
fi
|
||||
84
script/tools/ck-shell
Executable file
84
script/tools/ck-shell
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# CK Shell - Open interactive shell 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 Shell - Open interactive shell in Docker container
|
||||
|
||||
Usage: ck-shell [options] [container_name]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
--name <name> Specify container name
|
||||
-c <command> Execute command instead of interactive shell
|
||||
|
||||
Arguments:
|
||||
container_name Optional container name (default: ck_<username>_<branch>)
|
||||
|
||||
Environment:
|
||||
CK_CONTAINER_NAME - Override default container name
|
||||
|
||||
Examples:
|
||||
ck-shell # Open interactive shell
|
||||
ck-shell my_container # Open shell in specific container
|
||||
ck-shell -c "rocm-smi" # Execute single command
|
||||
ck-shell -c "cd build && ls bin" # Execute command in build directory
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Parse arguments
|
||||
command=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
--name)
|
||||
CONTAINER_NAME="$2"
|
||||
shift 2
|
||||
;;
|
||||
-c)
|
||||
command="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
CONTAINER_NAME="$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
|
||||
|
||||
# Execute command or open shell
|
||||
if [ -n "$command" ]; then
|
||||
echo "Executing: ${command}"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
docker exec "${CONTAINER_NAME}" bash -c "${command}"
|
||||
else
|
||||
echo "Opening shell in '${CONTAINER_NAME}' (type 'exit' to leave)..."
|
||||
docker exec -it "${CONTAINER_NAME}" bash
|
||||
fi
|
||||
103
script/tools/ck-start
Executable file
103
script/tools/ck-start
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# CK Start - Start Docker container for Composable Kernel testing
|
||||
|
||||
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 Start - Start Docker container for Composable Kernel testing
|
||||
|
||||
Usage: ck-start [options] [container_name]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
--image <image> Specify Docker image (overrides CK_DOCKER_IMAGE)
|
||||
|
||||
Arguments:
|
||||
container_name Optional container name (default: ck_<username>_<branch>)
|
||||
|
||||
Environment:
|
||||
CK_CONTAINER_NAME - Override default container name
|
||||
CK_DOCKER_IMAGE - Override Docker image (default: rocm/composable_kernel:ck_ub24.04_rocm7.0.1)
|
||||
|
||||
Examples:
|
||||
ck-start # Start container with default name
|
||||
ck-start my_ck_container # Start container with custom name
|
||||
ck-start --image rocm/composable_kernel:latest
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
--image)
|
||||
export CK_DOCKER_IMAGE="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
CONTAINER_NAME="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Get Docker image
|
||||
DOCKER_IMAGE=$(get_docker_image)
|
||||
|
||||
# Check if container exists and is running
|
||||
if container_exists "${CONTAINER_NAME}"; then
|
||||
if container_is_running "${CONTAINER_NAME}"; then
|
||||
echo "Container '${CONTAINER_NAME}' is already running"
|
||||
docker exec "${CONTAINER_NAME}" bash -c "echo 'Working directory:' && pwd"
|
||||
exit 0
|
||||
else
|
||||
echo "Starting existing container '${CONTAINER_NAME}'..."
|
||||
docker start "${CONTAINER_NAME}"
|
||||
echo "Container started"
|
||||
docker exec "${CONTAINER_NAME}" bash -c "echo 'Working directory:' && pwd"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create new container
|
||||
echo "Creating new Docker container '${CONTAINER_NAME}'..."
|
||||
echo "Docker image: ${DOCKER_IMAGE}"
|
||||
echo "Project root: ${PROJECT_ROOT}"
|
||||
echo ""
|
||||
|
||||
docker run -d \
|
||||
--name "${CONTAINER_NAME}" \
|
||||
--device=/dev/kfd --device=/dev/dri \
|
||||
--security-opt seccomp=unconfined \
|
||||
--group-add video \
|
||||
-v "${PROJECT_ROOT}":/workspace \
|
||||
-w /workspace \
|
||||
"${DOCKER_IMAGE}" \
|
||||
tail -f /dev/null
|
||||
|
||||
echo ""
|
||||
echo "Container '${CONTAINER_NAME}' started successfully"
|
||||
docker exec "${CONTAINER_NAME}" bash -c "echo 'Working directory:' && pwd"
|
||||
|
||||
# Show GPU info
|
||||
echo ""
|
||||
echo "GPU Information:"
|
||||
docker exec "${CONTAINER_NAME}" bash -c "rocm-smi --showproductname 2>/dev/null | head -5 || echo 'No GPU detected'"
|
||||
153
script/tools/ck-status
Executable file
153
script/tools/ck-status
Executable file
@@ -0,0 +1,153 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# CK Status - Check container status and information
|
||||
|
||||
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 Status - Check container status and information
|
||||
|
||||
Usage: ck-status [options] [container_name]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
--name <name> Specify container name
|
||||
--all Show all CK containers
|
||||
-v, --verbose Show detailed information
|
||||
|
||||
Arguments:
|
||||
container_name Optional container name (default: ck_<username>_<branch>)
|
||||
|
||||
Environment:
|
||||
CK_CONTAINER_NAME - Override default container name
|
||||
|
||||
Examples:
|
||||
ck-status # Check default container status
|
||||
ck-status my_container # Check specific container
|
||||
ck-status --all # Show all CK containers
|
||||
ck-status -v # Show detailed information
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Parse arguments
|
||||
show_all=false
|
||||
verbose=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
--name)
|
||||
CONTAINER_NAME="$2"
|
||||
shift 2
|
||||
;;
|
||||
--all)
|
||||
show_all=true
|
||||
shift
|
||||
;;
|
||||
-v|--verbose)
|
||||
verbose=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
CONTAINER_NAME="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
DOCKER_IMAGE=$(get_docker_image)
|
||||
|
||||
# Show all containers
|
||||
if [ "$show_all" = true ]; then
|
||||
echo "Composable Kernel Docker Containers:"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
|
||||
username=$(get_username)
|
||||
containers=$(docker ps -a --filter "name=ck_${username}_" --format "table {{.Names}}\t{{.Status}}\t{{.CreatedAt}}" 2>/dev/null || echo "")
|
||||
|
||||
if [ -z "$containers" ] || [ "$containers" = "NAMES STATUS CREATED AT" ]; then
|
||||
echo "No CK containers found for user '${username}'"
|
||||
else
|
||||
echo "$containers"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check specific container status
|
||||
echo "Container: ${CONTAINER_NAME}"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
|
||||
if container_is_running "${CONTAINER_NAME}"; then
|
||||
echo "Status: RUNNING ✓"
|
||||
echo ""
|
||||
docker ps --filter "name=^${CONTAINER_NAME}$" --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
|
||||
|
||||
if [ "$verbose" = true ]; then
|
||||
echo ""
|
||||
echo "Container Details:"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
docker inspect "${CONTAINER_NAME}" --format '
|
||||
Image: {{.Config.Image}}
|
||||
Created: {{.Created}}
|
||||
Platform: {{.Platform}}
|
||||
Mounts: {{range .Mounts}}
|
||||
- {{.Source}} -> {{.Destination}}{{end}}
|
||||
'
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "GPU Information:"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
docker exec "${CONTAINER_NAME}" bash -c "rocm-smi --showproductname 2>/dev/null | head -10 || echo 'No GPU detected'"
|
||||
|
||||
if [ "$verbose" = true ]; then
|
||||
echo ""
|
||||
echo "GPU Target:"
|
||||
gpu_target=$(detect_gpu_target "${CONTAINER_NAME}")
|
||||
echo " ${gpu_target}"
|
||||
|
||||
echo ""
|
||||
echo "Build Status:"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
if docker exec "${CONTAINER_NAME}" test -d /workspace/build 2>/dev/null; then
|
||||
if docker exec "${CONTAINER_NAME}" test -f /workspace/build/build.ninja 2>/dev/null; then
|
||||
echo " CMake configured ✓"
|
||||
echo " Build directory: /workspace/build"
|
||||
|
||||
# Count built test binaries
|
||||
bin_count=$(docker exec "${CONTAINER_NAME}" bash -c "ls -1 /workspace/build/bin 2>/dev/null | wc -l" || echo "0")
|
||||
echo " Test binaries: ${bin_count}"
|
||||
else
|
||||
echo " CMake not configured"
|
||||
fi
|
||||
else
|
||||
echo " Build directory not found"
|
||||
fi
|
||||
fi
|
||||
|
||||
elif container_exists "${CONTAINER_NAME}"; then
|
||||
echo "Status: STOPPED"
|
||||
echo ""
|
||||
echo "Start with: ck-start"
|
||||
else
|
||||
echo "Status: DOES NOT EXIST"
|
||||
echo ""
|
||||
echo "Create with: ck-start"
|
||||
fi
|
||||
141
script/tools/ck-stop
Executable file
141
script/tools/ck-stop
Executable file
@@ -0,0 +1,141 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# CK Stop - Stop and remove 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 Stop - Stop and remove Docker container
|
||||
|
||||
Usage: ck-stop [options] [container_name]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
-f, --force Force stop without confirmation
|
||||
--all Stop all CK containers for this user
|
||||
|
||||
Arguments:
|
||||
container_name Optional container name (default: ck_<username>_<branch>)
|
||||
|
||||
Environment:
|
||||
CK_CONTAINER_NAME - Override default container name
|
||||
|
||||
Examples:
|
||||
ck-stop # Stop default container
|
||||
ck-stop my_ck_container # Stop specific container
|
||||
ck-stop --all # Stop all user's CK containers
|
||||
ck-stop --force # Stop without confirmation
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Parse arguments
|
||||
force=false
|
||||
stop_all=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
-f|--force)
|
||||
force=true
|
||||
shift
|
||||
;;
|
||||
--all)
|
||||
stop_all=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
CONTAINER_NAME="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Function to stop a single container
|
||||
stop_container() {
|
||||
local name="$1"
|
||||
|
||||
if ! container_exists "${name}"; then
|
||||
echo "Container '${name}' does not exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Stopping and removing container '${name}'..."
|
||||
docker stop "${name}" 2>/dev/null || true
|
||||
docker rm "${name}" 2>/dev/null || true
|
||||
echo "Container '${name}' stopped and removed"
|
||||
}
|
||||
|
||||
# Stop all user containers
|
||||
if [ "$stop_all" = true ]; then
|
||||
username=$(get_username)
|
||||
containers=$(docker ps -a --filter "name=ck_${username}_" --format '{{.Names}}')
|
||||
|
||||
if [ -z "$containers" ]; then
|
||||
echo "No CK containers found for user '${username}'"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Found CK containers for user '${username}':"
|
||||
echo "$containers"
|
||||
echo ""
|
||||
|
||||
if [ "$force" = false ]; then
|
||||
read -p "Stop and remove all these containers? (y/N) " -n 1 -r
|
||||
echo ""
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Cancelled"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
while IFS= read -r container; do
|
||||
stop_container "$container"
|
||||
done <<< "$containers"
|
||||
|
||||
echo ""
|
||||
echo "All containers stopped and removed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Stop single container
|
||||
if ! container_exists "${CONTAINER_NAME}"; then
|
||||
echo "Container '${CONTAINER_NAME}' does not exist"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Show container info
|
||||
if container_is_running "${CONTAINER_NAME}"; then
|
||||
echo "Container '${CONTAINER_NAME}' is currently running"
|
||||
else
|
||||
echo "Container '${CONTAINER_NAME}' exists but is stopped"
|
||||
fi
|
||||
|
||||
# Confirm if not forced
|
||||
if [ "$force" = false ]; then
|
||||
read -p "Stop and remove container '${CONTAINER_NAME}'? (y/N) " -n 1 -r
|
||||
echo ""
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Cancelled"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
stop_container "${CONTAINER_NAME}"
|
||||
166
script/tools/ck-test
Executable file
166
script/tools/ck-test
Executable file
@@ -0,0 +1,166 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# CK Test - Build and test Composable Kernel 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 Test - Build and test Composable Kernel in Docker
|
||||
|
||||
Usage: ck-test [options] <test_name> [test_options]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
--name <name> Specify container name
|
||||
--reconfigure Reconfigure CMake before building
|
||||
--no-build Skip building, run test directly
|
||||
|
||||
Arguments:
|
||||
test_name Name of test executable (required)
|
||||
test_options Additional options passed to test (e.g., --gtest_filter=*)
|
||||
|
||||
Environment:
|
||||
CK_CONTAINER_NAME - Override default container name
|
||||
GPU_TARGET - Override GPU target detection (e.g., gfx950, gfx942)
|
||||
|
||||
Examples:
|
||||
ck-test test_amdgcn_mma
|
||||
ck-test test_amdgcn_mma --gtest_filter=*Fp16*
|
||||
ck-test --name my_container test_amdgcn_mma
|
||||
ck-test --reconfigure test_amdgcn_mma
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Parse arguments
|
||||
test_name=""
|
||||
reconfigure=false
|
||||
no_build=false
|
||||
test_options=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
--name)
|
||||
CONTAINER_NAME="$2"
|
||||
shift 2
|
||||
;;
|
||||
--reconfigure)
|
||||
reconfigure=true
|
||||
shift
|
||||
;;
|
||||
--no-build)
|
||||
no_build=true
|
||||
shift
|
||||
;;
|
||||
--gtest_*|--help)
|
||||
test_options+=("$1")
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
if [ -z "$test_name" ]; then
|
||||
test_name="$1"
|
||||
else
|
||||
test_options+=("$1")
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate test name
|
||||
if [ -z "$test_name" ]; then
|
||||
echo "Error: test_name 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
|
||||
|
||||
# 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
|
||||
|
||||
# Build test if needed (unless --no-build is specified)
|
||||
if [ "$no_build" = false ]; then
|
||||
if ! docker exec "${CONTAINER_NAME}" test -f "/workspace/build/bin/${test_name}" 2>/dev/null; then
|
||||
echo "Building ${test_name}..."
|
||||
docker exec "${CONTAINER_NAME}" bash -c "
|
||||
cd /workspace/build || exit 1
|
||||
ninja ${test_name} 2>&1
|
||||
"
|
||||
echo ""
|
||||
else
|
||||
echo "Test executable found, rebuilding to ensure latest version..."
|
||||
docker exec "${CONTAINER_NAME}" bash -c "
|
||||
cd /workspace/build || exit 1
|
||||
ninja ${test_name} 2>&1
|
||||
"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run test
|
||||
echo "Running: ${test_name} ${test_options[*]}"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
|
||||
# Build the command with proper quoting
|
||||
cmd="cd /workspace/build && ./bin/${test_name}"
|
||||
for opt in "${test_options[@]}"; do
|
||||
cmd="${cmd} $(printf '%q' "$opt")"
|
||||
done
|
||||
|
||||
docker exec "${CONTAINER_NAME}" bash -c "${cmd}"
|
||||
exit_code=$?
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo "Test completed successfully"
|
||||
else
|
||||
echo "Test failed with exit code: ${exit_code}"
|
||||
fi
|
||||
|
||||
exit $exit_code
|
||||
Reference in New Issue
Block a user