Skip to content

Commit 5d91fe5

Browse files
authored
Merge pull request vortexgpgpu#211 from MichaelJSr/riscv-vector-isa-simx-clean
Vector extension simx with fallbacks for testcases and clean history
2 parents 18ae57c + 5891a1e commit 5d91fe5

File tree

27 files changed

+5738
-112
lines changed

27 files changed

+5738
-112
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
strategy:
118118
fail-fast: false
119119
matrix:
120-
name: [regression, opencl, cache, config1, config2, debug, scope, stress, synthesis, vm]
120+
name: [regression, opencl, cache, config1, config2, debug, scope, stress, synthesis, vm, vector]
121121
xlen: [32, 64]
122122

123123
steps:

ci/regression.sh.in

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,20 @@ synthesis()
390390
echo "synthesis tests done!"
391391
}
392392

393+
vector()
394+
{
395+
echo "begin vector tests..."
396+
397+
make -C sim/simx
398+
TOOLDIR=@TOOLDIR@ XLEN=@XLEN@ VLEN=256 REG_TESTS=1 ./tests/riscv/riscv-vector-tests/run-test.sh
399+
400+
echo "vector tests done!"
401+
}
402+
393403
show_usage()
394404
{
395405
echo "Vortex Regression Test"
396-
echo "Usage: $0 [--clean] [--unittest] [--isa] [--kernel] [--regression] [--opencl] [--cache] [--config1] [--config2] [--debug] [--scope] [--stress] [--synthesis] [--all] [--h|--help]"
406+
echo "Usage: $0 [--clean] [--unittest] [--isa] [--kernel] [--regression] [--opencl] [--cache] [--config1] [--config2] [--debug] [--scope] [--stress] [--synthesis] [--vector] [--all] [--h|--help]"
397407
}
398408

399409
declare -a tests=()
@@ -443,6 +453,9 @@ while [ "$1" != "" ]; do
443453
--synthesis )
444454
tests+=("synthesis")
445455
;;
456+
--vector )
457+
tests+=("vector")
458+
;;
446459
--all )
447460
tests=()
448461
tests+=("unittest")
@@ -458,6 +471,7 @@ while [ "$1" != "" ]; do
458471
tests+=("scope")
459472
tests+=("stress")
460473
tests+=("synthesis")
474+
tests+=("vector")
461475
;;
462476
-h | --help )
463477
show_usage

hw/rtl/VX_config.vh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
`endif
8686
`endif
8787

88+
`ifndef VLEN
89+
`define VLEN 256
90+
`endif
91+
8892
`ifndef NUM_CLUSTERS
8993
`define NUM_CLUSTERS 1
9094
`endif

hw/rtl/VX_types.vh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@
188188
`define VX_CSR_MIMPID 12'hF13
189189
`define VX_CSR_MHARTID 12'hF14
190190

191+
// Vector CSRs
192+
193+
`define VX_CSR_VSTART 12'h008
194+
`define VX_CSR_VXSAT 12'h009
195+
`define VX_CSR_VXRM 12'h00A
196+
`define VX_CSR_VCSR 12'h00F
197+
`define VX_CSR_VL 12'hC20
198+
`define VX_CSR_VTYPE 12'hC21
199+
`define VX_CSR_VLENB 12'hC22
200+
`define VX_CSR_VCYCLE 12'hC00
201+
`define VX_CSR_VTIME 12'hC01
202+
`define VX_CSR_VINSTRET 12'hC02
203+
191204
// GPGU CSRs
192205

193206
`define VX_CSR_THREAD_ID 12'hCC0

perf/cache/cache_perf.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
CONFIGS=-DNUM_CLUSTERS=1 -DNUM_CORES=1 -DNUM_WARPS=2 -DNUM_THREADS=2 -DPERF_ENABLE -DICACHE_NUM_WAYS=1
22
running: CONFIGS=-DNUM_CLUSTERS=1 -DNUM_CORES=1 -DNUM_WARPS=2 -DNUM_THREADS=2 -DPERF_ENABLE -DICACHE_NUM_WAYS=1 make -C ./ci/../driver/rtlsim
3-
verilator --build --exe --cc Vortex --top-module Vortex --language 1800-2009 --assert -Wall -Wpedantic -Wno-DECLFILENAME -Wno-REDEFMACRO --x-initial unique --x-assign unique verilator.vlt -I../../hw/rtl -I../../hw/dpi -I../../hw/rtl/libs -I../../hw/rtl/interfaces -I../../hw/rtl/cache -I../../hw/rtl/simulate -I../../hw/rtl/fp_cores -I../../third_party/fpnew/src/common_cells/include -I../../third_party/fpnew/src/common_cells/src -I../../third_party/fpnew/src/fpu_div_sqrt_mvp/hdl -I../../third_party/fpnew/src -I../../hw/rtl/tex_unit -I../../hw/rtl/raster_unit -I../../hw/rtl/rop_unit -DNUM_CLUSTERS=1 -DNUM_CORES=1 -DNUM_WARPS=2 -DNUM_THREADS=2 -DPERF_ENABLE -DICACHE_NUM_WAYS=1 -j 64 -DNDEBUG -DIMUL_DPI -DIDIV_DPI -DFPU_DPI ../common/util.cpp ../common/mem.cpp ../common/rvfloats.cpp ../../hw/dpi/util_dpi.cpp ../../hw/dpi/float_dpi.cpp processor.cpp -CFLAGS '-std=c++11 -Wall -Wextra -Wfatal-errors -Wno-array-bounds -fPIC -Wno-maybe-uninitialized -I../../../hw -I../../common -I../../../third_party/softfloat/source/include -I../../../third_party -DNUM_CLUSTERS=1 -DNUM_CORES=1 -DNUM_WARPS=2 -DNUM_THREADS=2 -DPERF_ENABLE -DICACHE_NUM_WAYS=1 -O2 -DNDEBUG' -LDFLAGS '-shared ../../../third_party/softfloat/build/Linux-x86_64-GCC/softfloat.a -L../../../third_party/ramulator -lramulator' -o ../../../driver/rtlsim/librtlsim.so
3+
verilator --build --exe --cc Vortex --top-module Vortex --language 1800-2009 --assert -Wall -Wpedantic -Wno-DECLFILENAME -Wno-REDEFMACRO --x-initial unique --x-assign unique verilator.vlt -I../../hw/rtl -I../../hw/dpi -I../../hw/rtl/libs -I../../hw/rtl/interfaces -I../../hw/rtl/cache -I../../hw/rtl/simulate -I../../hw/rtl/fp_cores -I../../third_party/fpnew/src/common_cells/include -I../../third_party/fpnew/src/common_cells/src -I../../third_party/fpnew/src/fpu_div_sqrt_mvp/hdl -I../../third_party/fpnew/src -I../../hw/rtl/tex_unit -I../../hw/rtl/raster_unit -I../../hw/rtl/rop_unit -DNUM_CLUSTERS=1 -DNUM_CORES=1 -DNUM_WARPS=2 -DNUM_THREADS=2 -DPERF_ENABLE -DICACHE_NUM_WAYS=1 -j 64 -DNDEBUG -DIMUL_DPI -DIDIV_DPI -DFPU_DPI ../common/util.cpp ../common/mem.cpp ../common/softfloat_ext.cpp ../common/rvfloats.cpp ../../hw/dpi/util_dpi.cpp ../../hw/dpi/float_dpi.cpp processor.cpp -CFLAGS '-std=c++11 -Wall -Wextra -Wfatal-errors -Wno-array-bounds -fPIC -Wno-maybe-uninitialized -I../../../hw -I../../common -I../../../third_party/softfloat/source/include -I../../../third_party -DNUM_CLUSTERS=1 -DNUM_CORES=1 -DNUM_WARPS=2 -DNUM_THREADS=2 -DPERF_ENABLE -DICACHE_NUM_WAYS=1 -O2 -DNDEBUG' -LDFLAGS '-shared ../../../third_party/softfloat/build/Linux-x86_64-GCC/softfloat.a -L../../../third_party/ramulator -lramulator' -o ../../../driver/rtlsim/librtlsim.so

sim/common/rvfloats.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313

1414
#include "rvfloats.h"
15+
#include "softfloat_ext.h"
1516
#include <stdio.h>
1617

1718
extern "C" {
@@ -158,6 +159,34 @@ uint64_t rv_fdiv_d(uint64_t a, uint64_t b, uint32_t frm, uint32_t* fflags) {
158159
return from_float64_t(r);
159160
}
160161

162+
uint32_t rv_frecip7_s(uint32_t a, uint32_t frm, uint32_t* fflags) {
163+
softfloat_roundingMode = frm;
164+
auto r = f32_recip7(to_float32_t(a));
165+
if (fflags) { *fflags = softfloat_exceptionFlags; }
166+
return from_float32_t(r);
167+
}
168+
169+
uint64_t rv_frecip7_d(uint64_t a, uint32_t frm, uint32_t* fflags) {
170+
softfloat_roundingMode = frm;
171+
auto r = f64_recip7(to_float64_t(a));
172+
if (fflags) { *fflags = softfloat_exceptionFlags; }
173+
return from_float64_t(r);
174+
}
175+
176+
uint32_t rv_frsqrt7_s(uint32_t a, uint32_t frm, uint32_t* fflags) {
177+
softfloat_roundingMode = frm;
178+
auto r = f32_rsqrte7(to_float32_t(a));
179+
if (fflags) { *fflags =softfloat_exceptionFlags; }
180+
return from_float32_t(r);
181+
}
182+
183+
uint64_t rv_frsqrt7_d(uint64_t a, uint32_t frm, uint32_t* fflags) {
184+
softfloat_roundingMode = frm;
185+
auto r = f64_rsqrte7(to_float64_t(a));
186+
if (fflags) { *fflags = softfloat_exceptionFlags; }
187+
return from_float64_t(r);
188+
}
189+
161190
uint32_t rv_fsqrt_s(uint32_t a, uint32_t frm, uint32_t* fflags) {
162191
rv_init(frm);
163192
auto r = f32_sqrt(to_float32_t(a));
@@ -486,6 +515,11 @@ uint64_t rv_fsgnjx_d(uint64_t a, uint64_t b) {
486515
return r;
487516
}
488517

518+
uint32_t rv_dtof_r(uint64_t a, uint32_t frm) {
519+
rv_init(frm);
520+
return rv_dtof(a);
521+
}
522+
489523
uint32_t rv_dtof(uint64_t a) {
490524
auto r = f64_to_f32(to_float64_t(a));
491525
return from_float32_t(r);

sim/common/rvfloats.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ uint32_t rv_fnmadd_s(uint32_t a, uint32_t b, uint32_t c, uint32_t frm, uint32_t*
2828
uint32_t rv_fnmsub_s(uint32_t a, uint32_t b, uint32_t c, uint32_t frm, uint32_t* fflags);
2929
uint32_t rv_fdiv_s(uint32_t a, uint32_t b, uint32_t frm, uint32_t* fflags);
3030
uint32_t rv_fsqrt_s(uint32_t a, uint32_t frm, uint32_t* fflags);
31+
uint32_t rv_frecip7_s(uint32_t a, uint32_t frm, uint32_t* fflags);
32+
uint32_t rv_frsqrt7_s(uint32_t a, uint32_t frm, uint32_t* fflags);
3133

3234
uint32_t rv_ftoi_s(uint32_t a, uint32_t frm, uint32_t* fflags);
3335
uint32_t rv_ftou_s(uint32_t a, uint32_t frm, uint32_t* fflags);
@@ -58,6 +60,8 @@ uint64_t rv_fsub_d(uint64_t a, uint64_t b, uint32_t frm, uint32_t* fflags);
5860
uint64_t rv_fmul_d(uint64_t a, uint64_t b, uint32_t frm, uint32_t* fflags);
5961
uint64_t rv_fdiv_d(uint64_t a, uint64_t b, uint32_t frm, uint32_t* fflags);
6062
uint64_t rv_fsqrt_d(uint64_t a, uint32_t frm, uint32_t* fflags);
63+
uint64_t rv_frecip7_d(uint64_t a, uint32_t frm, uint32_t* fflags);
64+
uint64_t rv_frsqrt7_d(uint64_t a, uint32_t frm, uint32_t* fflags);
6165

6266
uint64_t rv_fmadd_d(uint64_t a, uint64_t b, uint64_t c, uint32_t frm, uint32_t* fflags);
6367
uint64_t rv_fmsub_d(uint64_t a, uint64_t b, uint64_t c, uint32_t frm, uint32_t* fflags);
@@ -85,6 +89,7 @@ uint64_t rv_fmin_d(uint64_t a, uint64_t b, uint32_t* fflags);
8589
uint64_t rv_fmax_d(uint64_t a, uint64_t b, uint32_t* fflags);
8690

8791
uint32_t rv_dtof(uint64_t a);
92+
uint32_t rv_dtof_r(uint64_t a, uint32_t frm);
8893
uint64_t rv_ftod(uint32_t a);
8994

9095
#ifdef __cplusplus

0 commit comments

Comments
 (0)