Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
advanced_computer_architecture
exercises
Commits
b5748f99
Commit
b5748f99
authored
Apr 21, 2016
by
kuhnm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added o1 to Makefile, changed float to int in daxpy
parent
7a50c629
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
19 deletions
+66
-19
aufgaben/blatt02/exec/Makefile
aufgaben/blatt02/exec/Makefile
+4
-1
aufgaben/blatt02/exec/daxpy
aufgaben/blatt02/exec/daxpy
+0
-0
aufgaben/blatt02/exec/daxpy.c
aufgaben/blatt02/exec/daxpy.c
+18
-18
aufgaben/blatt02/exec/daxpy_float.c
aufgaben/blatt02/exec/daxpy_float.c
+44
-0
No files found.
aufgaben/blatt02/exec/Makefile
View file @
b5748f99
...
...
@@ -2,5 +2,8 @@
all
:
arm-linux-gnueabihf-gcc
-static
-O3
daxpy.c
-o
daxpy
o1
:
arm-linux-gnueabihf-gcc
-static
-O1
daxpy.c
-o
daxpy
clean
:
rm
daxpy
rm
daxpy
daxpy.s
aufgaben/blatt02/exec/daxpy
View file @
b5748f99
No preview for this file type
aufgaben/blatt02/exec/daxpy.c
View file @
b5748f99
#include<stdio.h>
#define N
8
// size of vector
#define R 1
0
// number of repetitions
/*
#include<stdio.h>
*/
#define N
1000
// size of vector
#define R 1 // number of repetitions
// daxpy: Y = aX + Y (n size vector, a constant, X,Y vectors)
void
daxpy
(
double
*
x
,
double
*
y
,
double
a
,
int
n
)
void
daxpy
(
int
*
x
,
int
*
y
,
int
a
,
int
n
)
{
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
...
...
@@ -13,32 +13,32 @@ void daxpy(double* x, double* y, double a, int n)
}
// pretty print vector
void
print_vector
(
double
*
vec
,
int
n
)
{
int
i
;
for
(
i
=
0
;
i
<
n
-
1
;
i
++
)
{
printf
(
"%f,
\t
"
,
vec
[
i
]);
}
printf
(
"%f"
,
vec
[
n
-
1
]);
printf
(
"
\n
"
);
}
/*
void print_vector(double* vec, int n)
*/
/* { */
/*
int i;
*/
/*
for (i=0; i<n-1; i++) {
*/
/*
printf("%f,\t",vec[i]);
*/
/* } */
/*
printf("%f",vec[n-1]);
*/
/*
printf("\n");
*/
/* } */
void
main
()
{
static
double
x
[
N
],
y
[
N
];
double
a
=
5
.
5
;
static
int
x
[
N
],
y
[
N
];
int
a
=
5
;
int
i
;
for
(
i
=
0
;
i
<
N
;
i
++
)
{
x
[
i
]
=
7
.
833667
;
x
[
i
]
=
7
+
i
;
y
[
i
]
=
0
;
}
print_vector
(
y
,
N
);
/*
print_vector(y, N);
*/
for
(
i
=
0
;
i
<
R
;
i
++
)
{
daxpy
(
x
,
y
,
a
,
N
);
}
print_vector
(
y
,
N
);
/*
print_vector(y,N);
*/
}
aufgaben/blatt02/exec/daxpy_float.c
0 → 100644
View file @
b5748f99
/* #include<stdio.h> */
#define N 1000 // size of vector
#define R 1 // number of repetitions
// daxpy: Y = aX + Y (n size vector, a constant, X,Y vectors)
void
daxpy
(
double
*
x
,
double
*
y
,
double
a
,
int
n
)
{
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
y
[
i
]
=
a
*
x
[
i
]
+
y
[
i
];
}
}
// pretty print vector
/* void print_vector(double* vec, int n) */
/* { */
/* int i; */
/* for (i=0; i<n-1; i++) { */
/* printf("%f,\t",vec[i]); */
/* } */
/* printf("%f",vec[n-1]); */
/* printf("\n"); */
/* } */
void
main
()
{
static
double
x
[
N
],
y
[
N
];
double
a
=
5
.
5
;
int
i
;
for
(
i
=
0
;
i
<
N
;
i
++
)
{
x
[
i
]
=
7
.
833667
+
i
;
y
[
i
]
=
0
;
}
/* print_vector(y, N); */
for
(
i
=
0
;
i
<
R
;
i
++
)
{
daxpy
(
x
,
y
,
a
,
N
);
}
/* print_vector(y,N); */
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment