Question: You need to modify the assembly code, which you developed in the previous exercise, with the RISC - V V extension. It is important to
You need to modify the assembly code, which you developed in the previous exercise, with the RISCV V
extension. It is important to note that the specification of the vector engine of our virtual RISCV ie
vlen elen is different from the one used in the previous exercise ie vlen elen
Specifically, you are asked to achieve the same speed up as arraymulimprovedversionc in the
previous exercise. In other words, to get familiar with the design of the vector engine, the performance
improvement of this assignment against the baseline version in array multiplication should be the same as
the performance improvement achieved in Array multiplication a vectorized version with the V extension,
improvedversion Besides, you should do the same as to collect performance data and derive related
performance statistics.
As shown in the improvedversion function, you are responsible for writing the assembly for the
forloop code: for yi hi xi c;
NOTE: You should put your assembly code within the arraymulimprovedversionc file, as
indicated in asm volatile #include "arraymulimprovedversionc : hr
ph; within the improvedversion function in exercisec
Your code should use the RISCV V Extension and run with Spike simulator using the specific
configurations ie vlen elen
NOTE: Please do not modify the rest of the header file.
VariablesConstants defined in the header files used in this exercise.
Var.Cons Name Definition
x Input array in arraymul.h
h Input array in arraymul.h
y Output array in arraymul.h
improvedversioncyclecount
Clock cycle in vectorsumimprovedversionc you need
to calculate
cycletime
The given clock cycle time of the target RISCV processor
running at GHz
improvedversioncputime
The CPU time in vectorsumimprovedversionc you
need to calculate
arrsize Size of the arrays used in this exercise
studentid
studentid yourstudentid
ig F:
studentid
Your obtained scores of this exercise is determined by the correctness of your reported performance
data.
Achieved speedup.
As described above, the printed out speedup number should be
The improvedversion function in exercisec is as follows.
The code snippet for improvedversion in exercisec
void improvedversion
short int ph h;
short int px x;
short int py y;
short int id studentid; id yourstudentid ;
original C code
for int i ; i arrsize; i
pyi phi pxi id;
asm volatile
#include "arraymulimprovedversionc
: hrphxrpxyrpyaddcntraddcnt
subcntrsubcntmulcntrmulcntdivcntrdivcnt
lwcntrlwcntswcntrswcntotherscntrotherscnt
: idridarrsizerarrsize
: tvvv
;
printf
Question
;
printfoutput: ;
for int i ; i arrsize; i
printfd yi;
printf
;
printfadd counter used: d
addcnt;
printfsub counter used: d
subcnt;
printfmul counter used: d
mulcnt;
printfdiv counter used: d
divcnt;
printflw counter used: d
lwcnt;
printfsw counter used: d
swcnt;
printfothers counter used: d
otherscnt;
macroimprovedversioncyclecount
printfThe total cycle count in this program: f
improvedversioncyclecount;
macroimprovedversioncputime
printfCPU time f us
improvedversioncputime;
float speedup ;
FILE fp;
fp fopenimprovedversioncputime.txtr;
fscanffpf &speedup;
fclosefp;
speedup speedup improvedversioncputime;
printfThe enhanced V extension version is f times faster than the baseline
vectorized version
speedup;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
