-
Notifications
You must be signed in to change notification settings - Fork 270
Solve the staging compiler regression and enhance the docker container execution in script/tools #3634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Solve the staging compiler regression and enhance the docker container execution in script/tools #3634
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ✓" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 '|'.