You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int main() {
int a[N] = {1, 2, 3, 4, 5, 6, 7, 8};
int b[N] = {8, 7, 6, 5, 4, 3, 2, 1};
int c[N];
// Read the initial cycle count
vector_addition(a, b, c, N);
// Output the results
for (int i = 0; i < N; i++) {
printf("%d ", c[i]);
}
printf("\n");
return 0;
}
The output expected is {9,9,9,9,9,9,9,9}, a vector with 8 9's in it. But the actual output I am getting is {9,9,9,9,0,0,0,}. Why is the output coming like this?
The text was updated successfully, but these errors were encountered:
I am trying to add two vectors of length 8. The following is the C code with inline assembly I am using:
#include <stdio.h>
#define N 8 // Size of vectors
void vector_addition(int *a, int *b, int *c, int n) {
//unsigned long start_cycle, end_cycle, elapsed_cycles;
// asm volatile("csrr %0, cycle" : "=r"(start_cycle));
//for (int i = 0; i < n; i++) {
// c[i] = a[i] + b[i];
// }
}
int main() {
int a[N] = {1, 2, 3, 4, 5, 6, 7, 8};
int b[N] = {8, 7, 6, 5, 4, 3, 2, 1};
int c[N];
}
The output expected is {9,9,9,9,9,9,9,9}, a vector with 8 9's in it. But the actual output I am getting is {9,9,9,9,0,0,0,}. Why is the output coming like this?
The text was updated successfully, but these errors were encountered: