Commit b5748f99 authored by kuhnm's avatar kuhnm

added o1 to Makefile, changed float to int in daxpy

parent 7a50c629
......@@ -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
#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); */
}
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