Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pintos_forked_resit
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s2-alsaloumi
Pintos_forked_resit
Commits
2b83665f
Commit
2b83665f
authored
1 year ago
by
h2-addad
Browse files
Options
Downloads
Patches
Plain Diff
Update
parent
aa798576
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/examples/matmult.c
+57
-0
57 additions, 0 deletions
src/examples/matmult.c
with
57 additions
and
0 deletions
src/examples/matmult.c
0 → 100644
+
57
−
0
View file @
2b83665f
/* matmult.c
Test program to do matrix multiplication on large arrays.
Intended to stress virtual memory system.
Ideally, we could read the matrices off of the file system,
and store the result back to the file system!
*/
#include
<stdio.h>
#include
<syscall.h>
/* You should define DIM to be large enough that the arrays
don't fit in physical memory.
Dim Memory
------ --------
16 3 kB
64 48 kB
128 192 kB
256 768 kB
512 3,072 kB
1,024 12,288 kB
2,048 49,152 kB
4,096 196,608 kB
8,192 786,432 kB
16,384 3,145,728 kB */
#define DIM 128
int
A
[
DIM
][
DIM
];
int
B
[
DIM
][
DIM
];
int
C
[
DIM
][
DIM
];
int
main
(
void
)
{
int
i
,
j
,
k
;
/* Initialize the matrices. */
for
(
i
=
0
;
i
<
DIM
;
i
++
)
for
(
j
=
0
;
j
<
DIM
;
j
++
)
{
A
[
i
][
j
]
=
i
;
B
[
i
][
j
]
=
j
;
C
[
i
][
j
]
=
0
;
}
/* Multiply matrices. */
for
(
i
=
0
;
i
<
DIM
;
i
++
)
for
(
j
=
0
;
j
<
DIM
;
j
++
)
for
(
k
=
0
;
k
<
DIM
;
k
++
)
C
[
i
][
j
]
+=
A
[
i
][
k
]
*
B
[
k
][
j
];
/* Done. */
exit
(
C
[
DIM
-
1
][
DIM
-
1
]);
}
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