Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs164
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
recolic-hust
cs164
Commits
f975bbbb
There was an error fetching the commit references. Please try again later.
Unverified
Commit
f975bbbb
authored
6 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
hw6 done
parent
7dce92d2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hw6/hw6.pdf
+0
-0
0 additions, 0 deletions
hw6/hw6.pdf
hw6/hw6.txt
+105
-0
105 additions, 0 deletions
hw6/hw6.txt
submit
+1
-1
1 addition, 1 deletion
submit
with
106 additions
and
1 deletion
hw6/hw6.pdf
0 → 100644
+
0
−
0
View file @
f975bbbb
File added
This diff is collapsed.
Click to expand it.
hw6/hw6.txt
0 → 100644
+
105
−
0
View file @
f975bbbb
HW #6 Solutions
1. C Program:
//arg begin, size
//
//using zero = 0
//sum = counter = 0
//
//do {
// sum += *(begin + 4 * counter)
// ++counter
//} while(counter < size);
//
//return sum
//
int32_t f(int32_t *begin, int32_t size) {
const int32_t zero = 0;
int32_t sum = zero;
for(int32_t counter = zero; counter < size; ++counter) {
sum += begin[counter];
}
return sum;
}
2. RISC V Code:
lw a1, 0(ti)
lw a2, 4(d)
mul a0, a1, a2
lw a1, 0(tj)
lw a2, 8(d)
mul a1, a1, a2
add a0, a0, a1
lw a0, 0(d)
add a1, a1, a0
lw a0, 0(a1)
; now register a0 contains `A[i,j]`
3
a.
(V0+j*S2, S1)
b.
(V0, S2, S1)
c.
(V0+N*S1+M*S2, -S1, -S2)
5.
a.
b-d. [Just show the final result. Here is the original, if you want to
use it (please erase it if you don't).]
Entry:
i := 0 #1
goto L6 #2
L1:
j := 0 #3
goto L5 #4
L2:
k := 0 #5
goto L4 #6
L3:
t1 := 4 * n #7
t2 := t1 * i #8
t3 := 4 * j #9
t4 := t2 + t3 #10
t5 := *(t4 + c) #11
t6 := 4 * n #12
t7 := t6 * i #13
t8 := 4 * k #14
t9 := t7 + t8 #15
t10 := *(t9 + a) #16
t11 := 4 * n #17
t12 := t11 * k #18
t13 := 4 * j #19
t14 := t12 + t13 #20
t15 := *(t14 + b) #21
t16 := t10 * t15 #22
t17 := t5 + t16 #23
t18 := 4 * n #24
t19 := t18 * i #25
t20 := 4 * j #26
t21 := t19 + t20 #27
*(t21+c) := t17 #28
k := k + 1 #29
L4:
if k < n: goto L3 #30
j := j + 1 #31
L5:
if j < n: goto L2 #32
i := i + 1 #33
L6:
if i < n: goto L1 #34
Exit:
This diff is collapsed.
Click to expand it.
submit
@
582b88d4
Subproject commit
ba138cb82ad9d9e296006b14a25cb0d3dd632064
Subproject commit
582b88d4736458efe0837ca19461a4ccf41a4dcc
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment