Question: You need to re - write the assembly code, which you build in the previous exercise, using the RISC - V V extension. Before you
You need to rewrite the assembly code, which you build in the previous exercise, using the RISCV V
extension. Before you write the code, you are suggested to study the RISCV V extension document from p
to p and p to get familiar with the concept of RISCV vector programming. After you write thevectorized program, you should collect the performance data and derive related performance statistics as you
did in the previous exercise.
As shown in the improvedversion function, you are responsible for writing the assembly for the forloop in C: 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 The vectorized version would improve the execution
efficiency, thanks to the parallel computations done in the vector computation engine.
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 and the efficiency of your developed code against the serial version in the previous exercise.
The values of seven counters.
addcnt
subcnt
mulcnt
divcnt
lwcnt
swcnt
otherscnt
The total cycle count improvedversioncyclecount
The CPU time improvedversioncputime
Achieved speedup.
If speedup, you get pt
If speedup you get pt
If speedup you get pt
If speedup you get pt
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 Write your code in this file:
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;
FILE fp;
fp fopenimprovedversioncputime.txtw;
fprintffpf improvedversioncputime;
fclosefp;
float speedup ;
FILE fp;
fp fopenarraymulbaselinecputime.txtr;
fscanffpf &speedup;
fclosefp;
speedup speedup improvedversioncputime;
printfThe V extension version is f times faster than the baseline
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
