apache / apache/tvm

[Bug] [RISC-V RVV] floor operator performance regression

Open
#18,565 0 comments 0 reactions 0 assignees View on GitHub
needs-triage type: bug
Dominant language
Python
Stars
13.7k
Forks
4k
Avg merge
2d 1h
Merged PRs (30d)
112

Description

### Issue: [RISC-V RVV] floor operator performance regression

#### Description
The floor operator shows performance degradation with the RISC‑V Vector (RVV) extension, achieving only 0.521× the performance of the scalar implementation. This suggests inefficient vectorization for the floor operation.

#### Steps to Reproduce
1. Generate the floor operator with the following configuration:
```python
params = {
"dtype": "float32",
"batch": 14,
"channels": 23,
"input_height": 67,
"input_width": 99
}
```

2. Export the operator to two targets:
- **RV target** (scalar, without vector extension):
```
llvm -mtriple=riscv64-linux-gnu -mcpu=generic-rv64 -mabi=lp64d -mattr=+64bit,+m,+a,+f,+d,+c
```
- **RVV target** (with vector extension):
```
llvm -mtriple=riscv64-linux-gnu -mcpu=generic-rv64 -mabi=lp64d -mattr=+64bit,+m,+a,+f,+d,+c,+v
```

3. Run performance measurement on both targets.

Operator definition code:
```python
def export_floor(params, set_dir=None, platform="rv"):
data = relay.var("data",
shape=(params["batch"], params["channels"],
params["input_height"], params["input_width"]),
dtype=params["dtype"])
floor_op = relay.floor(data)
export_op(floor_op, params["op_name"], [data], params, set_dir=set_dir)
```

#### Performance Data
- **RV execution time**: 8.891440 ms
- **RVV execution time**: 17.061200 ms
- **Acceleration ratio (RV/RVV)**: 0.521 (RVV is ~1.9× slower)

#### Environment Information
- **TVM version**: 0.19.0
- **LLVM version**: [Please provide: `llvm-config --version`]
- **Hardware**: Spacemit K1‑X bit‑brick board
- **CPU**: Spacemit X60 (8 cores, 1.6 GHz)
- **ISA**: rv64imafdcv (with vector extensions)
- **Memory**: 7.6 GB
- **OS**: Bianbu 2.2, Linux kernel 6.6.63
- **Operation**: Elementwise floor on ~1.7M elements

#### Expected Behavior
RVV vectorization should provide a performance improvement over the scalar RV baseline for elementwise operations like floor.

#### Additional Context
- The floor operation is applied elementwise to a tensor of ~1.7M elements.
- While the regression is less severe than for other operators (sum, log, etc.), it still represents a significant performance degradation for a simple arithmetic operation.
- This suggests that the current RVV implementation of floor may be using suboptimal vector instructions or inefficient vector length management.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided export_floor definition and reproduce the floor operator using the RV and RVV LLVM target configurations on the Spacemit K1-X board. Compare the reported 8.891440 ms and 17.061200 ms timings, and obtain the missing LLVM version with llvm-config --version. Done means identifying and addressing the RVV performance regression, then confirming that RVV no longer trails the scalar baseline.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, python
Domain
compilers, operating-systems, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.