Skip to content

Commit d150dd9

Browse files
committed
Added RISC-V V extension intrinsics for LLVM
1 parent 454012f commit d150dd9

File tree

13 files changed

+967
-1
lines changed

13 files changed

+967
-1
lines changed

include/tvm/meta_schedule/postproc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ class Postproc : public runtime::ObjectRef {
167167
TVM_DLL static Array<Postproc, void> DefaultLLVM();
168168
/*! \brief Create default postprocessors for x86 (AVX512 and VNNI) */
169169
TVM_DLL static Array<Postproc, void> DefaultCPUTensorization();
170+
/*! \brief Create default postprocessors for RISCV */
171+
TVM_DLL static Array<Postproc, void> DefaultRISCV();
170172
/*! \brief Create default postprocessors for CUDA */
171173
TVM_DLL static Array<Postproc, void> DefaultCUDA();
172174
/*! \brief Create default postprocessors for CUDA with TensorCore */

include/tvm/meta_schedule/schedule_rule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ class ScheduleRule : public runtime::ObjectRef {
302302
TVM_DLL static Array<ScheduleRule, void> DefaultHexagon();
303303
/*! \brief Create default schedule rules for ARM CPU (NEON and DOTPROD) */
304304
TVM_DLL static Array<ScheduleRule, void> DefaultARM(const String& type);
305+
/*! \brief Create default schedule rules for RISCV CPU (RVV) */
306+
TVM_DLL static Array<ScheduleRule, void> DefaultRISCV(int vlen);
305307

306308
TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(ScheduleRule, ObjectRef, ScheduleRuleNode);
307309
};

python/tvm/meta_schedule/tune_context.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ def __init__(
117117
if target is not None:
118118
if not isinstance(target, Target):
119119
target = Target(target)
120+
if "riscv_cpu" in target.keys:
121+
base_features = str(target.attrs["march"]).split("_")[0].replace("rv", "")
122+
if "v" in base_features:
123+
# Because the RVV intrinsics depend on the target, we register them here
124+
# pylint: disable=import-outside-toplevel
125+
from tvm.tir.tensor_intrin.riscv_cpu import register_riscv_tensor_intrinsics
126+
127+
register_riscv_tensor_intrinsics(target)
120128
if space_generator is not None:
121129
if not isinstance(space_generator, SpaceGenerator):
122130
space_generator = SpaceGenerator.create(space_generator)

python/tvm/target/target.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,18 @@ def riscv_cpu(model="sifive-u54", options=None):
637637
"-mabi=lp64d",
638638
# cc: riscv64-unknown-linux-gnu-g++ -march=rv64gc -mabi=lp64d -mcpu=sifive-u74
639639
],
640+
"bpi-f3": [
641+
# "-model=sifive-u74",
642+
"-mtriple=riscv64-unknown-linux-gnu",
643+
"-mcpu=generic",
644+
# "-march=rv64gcv_zvl256b",
645+
# "-mcpu=generic-rv64",
646+
"-mfloat-abi=hard",
647+
"-num-cores=8",
648+
"-mabi=lp64d",
649+
"-mattr=+v,+zvl256b",
650+
# cc: riscv64-unknown-linux-gnu-g++ -march=rv64gc -mabi=lp64d -mcpu=generic -mattr=+v
651+
],
640652
}
641653
pre_defined_opt = trans_table.get(model, ["-model=%s" % model])
642654

python/tvm/tir/tensor_intrin/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
from . import cuda
2121

2222
if enabled("llvm"):
23-
from . import arm_cpu, x86, rocm, hexagon
23+
from . import arm_cpu, x86, rocm, hexagon, riscv_cpu

0 commit comments

Comments
 (0)