Question: You need to write the assembly code for the C - based array multiplication, as shown in exercise 1 _ 2 . c , using
You need to write the assembly code for the Cbased array multiplication, as shown in exercisec using
the RVI ISA. Besides, you should do the same as pi calculation to collect performance data and derive
related performance statistics.
As shown in the arraymulbaseline 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 arraymulbaseline.c file, as indicated in
asm volatile #include "arraymulbaseline.c : hrph; within the
arraymulbaseline function in exercisec
The header file arraymul.h specifies the constantsvariables used in this assignment. You are
allowed to change arrsize array size in arraymul.h to meet the exercise requirements.
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
arraymulbaselinecyclecount Clock cycle in arraymulbaseline.c you need to calculate
cycletime
The given clock cycle time of the target RISCV processor
running at GHz
arraymulbaselinecputime
The CPU time in arraymulbaseline.c you need to
calculate
arrsize Size of the array
Your obtained scores of this exercise is determined by the correctness of your reported performance
data.
The values of seven counters.
addcnt
subcnt
mulcnt
divcnt
lwcnt
swcnt
otherscnt
The total cycle count arraymulbaselinecyclecount
The CPU time arraymulbaselinecputime
Choose any arrsize but log~~arrsize must be a integer and answer the question: Is this
program a CPU bound or Memory bound program?
The arraymulbaseline function in exercisec is as follows.
The code snippet for arraymulbaseline in exercisec
void arraymulbaseline
short int ph h;
short int px x;
short int py y;
short int id studentid; id should be yourstudentid please check
the header file, arraymul.h
original C code
for int i ; i arrsize; i
pyi phi pxi id;
asm volatile
#include "arraymulbaseline.c
: hrphxrpxyrpyaddcntraddcnt
subcntrsubcntmulcntrmulcntdivcntrdivcnt
lwcntrlwcntswcntrswcntotherscntrotherscnt
: idridarrsizerarrsize
: tt
;
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;
macroarraymulbaselinecyclecount
printfThe total cycle count in this program: f
arraymulbaselinecyclecount;
macroarraymulbaselinecputime
printfCPU time f us
arraymulbaselinecputime;
macrocalcarraymulbaselineratio
ifarraymulbaselineratio
printfThis program is a CPU bound task.
;
else
printfThis program is a Memory bound task.
;
record the cpu time
FILE fp;
fp fopenarraymulbaselinecputime.txtw;
fprintffpf arraymulbaselinecputime;
fclosefp;
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
