Commit 691ed21c authored by kuhnm's avatar kuhnm

blatt 2 daxpy

parent 34064cae
# Blatt 2
## Aufgabe 1
``` build/ARM/gem5.opt --debug-flags=O3PipeView --debug-start=1 --debug-file=trace.out configs/example/se.py --cpu-type=detailed --caches -c ~/advanced_computer_architecture/exercises/blatt02/exec/daxpy ```
all:
arm-linux-gnueabihf-gcc -static daxpy.c -o daxpy
clean:
rm daxpy
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
// 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;
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.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
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