Commit d51a4cf2 authored by Christoph Gerum's avatar Christoph Gerum

Merge branch 'master' of...

Merge branch 'master' of atreus.informatik.uni-tuebingen.de:advanced_computer_architecture/exercises
parents b4bbdc12 2cdbcee2
all:
arm-linux-gnueabihf-gcc -static daxpy.c -o daxpy
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
FILE1 = basicmath_small.c rad2deg.c cubic.c isqrt.c
FILE2 = basicmath_large.c rad2deg.c cubic.c isqrt.c
all: basicmath_small basicmath_large
basicmath_small: ${FILE1} Makefile
arm-linux-gnueabihf-gcc -static -O3 ${FILE1} -o basicmath_small -lm
basicmath_large: ${FILE2} Makefile
arm-linux-gnueabihf-gcc -static -O3 ${FILE2} -o basicmath_large -lm
clean:
rm -rf basicmath_small basicmath_large output*
#include<stdio.h>
#define N 8 // size of vector
#define R 10 // 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); */
}
/* #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); */
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment