8000 Issue with Vector addition · Issue #397 · riscv/riscv-crypto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Issue with Vector addition #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers 8000 and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TVS2004Chaitanya opened this issue Feb 28, 2025 · 1 comment
Closed

Issue with Vector addition #397

TVS2004Chaitanya opened this issue Feb 28, 2025 · 1 comment

Comments

@TVS2004Chaitanya
Copy link

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];
// }

asm volatile(
	"vsetvli t0, %[size], e32, m1\n\t"
    "vle32.v v0, (%[x])\n\t"
    "vle32.v v1, (%[y])\n\t"
    "vadd.vv v2, v0, v1\n\t"
    "vse32.v v2, (%[z])\n\t"
    : 
    : [z] "r" (c), [x] "r" (a), [y] "r" (b), [size] "r" (n)
    : "t0", "v0", "v1", "v2", "memory"
);

}

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?

@nibrunieAtSi5
Copy link
Contributor

@TVS2004Chaitanya , how is this related to RISC-V crypto specification ?

it is not clear where you are decrementing you vl (result of vsetvli)) from your AVL (n) and implementing the loop stripmining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0