Repository navigation
modify some script and test and add build_llvm script #4
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # Default to downloading llvm-project in the parent directory of rocDSL | ||
| BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| LLVM_SRC_DIR="$BASE_DIR/llvm-project" | ||
| LLVM_BUILD_DIR="$LLVM_SRC_DIR/build" | ||
|
|
||
| echo "Base directory: $BASE_DIR" | ||
| echo "LLVM Source: $LLVM_SRC_DIR" | ||
| echo "LLVM Build: $LLVM_BUILD_DIR" | ||
|
|
||
| # 1. Clone LLVM | ||
| if [ ! -d "$LLVM_SRC_DIR" ]; then | ||
| echo "Cloning llvm-project (branch: release/19.x)..." | ||
| # Use release/19.x branch, generally stable and recent | ||
| git clone --depth 1 -b release/19.x https://github.com/llvm/llvm-project.git "$LLVM_SRC_DIR" | ||
| else | ||
| echo "llvm-project directory already exists. Skipping clone." | ||
| fi | ||
|
|
||
| # 2. Create Build Directory | ||
| mkdir -p "$LLVM_BUILD_DIR" | ||
| cd "$LLVM_BUILD_DIR" | ||
|
|
||
| # 3. Configure CMake | ||
| echo "Configuring LLVM..." | ||
|
|
||
| # Check for ninja | ||
| GENERATOR="Unix Makefiles" | ||
| if command -v ninja &> /dev/null; then | ||
| GENERATOR="Ninja" | ||
| echo "Using Ninja generator." | ||
| else | ||
| echo "Ninja not found. Using Unix Makefiles (this might be slower)." | ||
| fi | ||
|
|
||
| # Build only MLIR and necessary Clang tools, targeting native architecture, in Release mode | ||
| cmake -G "$GENERATOR" \ | ||
| -S "$LLVM_SRC_DIR/llvm" \ | ||
| -B "$LLVM_BUILD_DIR" \ | ||
| -DLLVM_ENABLE_PROJECTS="mlir;clang" \ | ||
| -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DLLVM_ENABLE_ASSERTIONS=ON \ | ||
| -DLLVM_INSTALL_UTILS=ON | ||
|
|
||
| # 4. Build | ||
| echo "Starting build with $(nproc) parallel jobs..." | ||
| cmake --build . --target check-mlir -j$(nproc) || echo "MLIR tests failed, but build might be okay for use." | ||
| cmake --build . -j$(nproc) | ||
|
|
||
| echo "==============================================" | ||
| echo "LLVM/MLIR build completed successfully!" | ||
| echo "" | ||
| echo "To configure rocDSL, use:" | ||
| echo "cmake .. -DMLIR_DIR=$LLVM_BUILD_DIR/lib/cmake/mlir" | ||
| echo "==============================================" |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,27 @@ | |||||
| """ | ||||||
|
|
||||||
| from mlir.dialects.rocdl import * | ||||||
| from mlir.ir import Operation, IntegerType | ||||||
| from mlir.dialects import arith | ||||||
|
|
||||||
| # Polyfills for missing operations in standard bindings | ||||||
| if "wavefrontsize" not in globals(): | ||||||
| def wavefrontsize(result_type): | ||||||
| return Operation.create("rocdl.wavefrontsize", results=[result_type]).results[0] | ||||||
|
|
||||||
| if "s_waitcnt" not in globals(): | ||||||
| def s_waitcnt(simm16): | ||||||
| if isinstance(simm16, int): | ||||||
| simm16 = arith.ConstantOp(IntegerType.get_signless(32), simm16).result | ||||||
| return Operation.create("rocdl.waitcnt", operands=[simm16]).results | ||||||
|
||||||
| return Operation.create("rocdl.waitcnt", operands=[simm16]).results | |
| return Operation.create("rocdl.waitcnt", operands=[simm16]).results[0] |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |||||
| IndexType, | ||||||
| IntegerAttr, | ||||||
| IntegerType, | ||||||
| Operation, | ||||||
| ) | ||||||
|
|
||||||
| # Import generated ops | ||||||
|
|
@@ -237,8 +238,14 @@ def crd2idx(coord: Value, layout: Value, loc: Optional[Location] = None, ip: Opt | |||||
| loc = _get_location(loc) | ||||||
| result_type = IndexType.get() | ||||||
|
|
||||||
| with ip or InsertionPoint.current: | ||||||
| op = rocir_ops.Crd2IdxOp(_unwrap_value(coord), _unwrap_value(layout), results=[result_type], loc=loc, ip=ip) | ||||||
| with ip or InsertionPoint.current as insertion_point: | ||||||
|
||||||
| with ip or InsertionPoint.current as insertion_point: | |
| with ip or InsertionPoint.current: |
Copilot
AI
Dec 1, 2025
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 commented-out line insertion_point.insert(op) suggests uncertainty about whether manual insertion is needed. When using Operation.create() within an active InsertionPoint context (from the with statement), the operation is automatically inserted. The comment should be removed for clarity, or if there was a specific reason to keep it commented, that reason should be documented.
| # insertion_point.insert(op) |
Copilot
AI
Dec 1, 2025
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 insertion_point variable captured from the with statement is unused. Consider either removing the variable name (use just with ip or InsertionPoint.current:), or document why it's captured if there's a specific reason.
Copilot
AI
Dec 1, 2025
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 insertion_point variable captured from the with statement is unused. Consider either removing the variable name (use just with ip or InsertionPoint.current:), or document why it's captured if there's a specific reason.
Copilot
AI
Dec 1, 2025
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 insertion_point variable captured from the with statement is unused. Consider either removing the variable name (use just with ip or InsertionPoint.current:), or document why it's captured if there's a specific reason.
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 path contains a double slash
//which is incorrect. Should be-DMLIR_DIR=$MLIR_PATH/lib/cmake/mlirwith only a single slash separator.