Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers 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

Test on rvv-intrinsic-doc/examples/rvv_strcpy.c failed #33

Open
QQeg opened this issue Jun 25, 2023 · 0 comments
Open

Test on rvv-intrinsic-doc/examples/rvv_strcpy.c failed #33

QQeg opened this issue Jun 25, 2023 · 0 comments

Comments

@QQeg
Copy link

QQeg commented Jun 25, 2023

你好,
我为了测试gem5 (commit: 2909be3) 而去执行 rvv-intrinsic-doc/examples/rvv_strcpy.c 生成的执行档会得到fail的结果,
然而使用spike去模拟是可以得到pass的,可以请你们看看问题出在什么地方吗?

以下是我的command:

riscv64-unknown-elf-gcc -march=rv64gcv -o rvv_strcpy rvv_strcpy.c
spike --isa=rv64gcv --varch=vlen:256,elen:64 pk rvv_strcpy
gem5.opt se.py -c rvv_strcpy

rvv_strcpy.c:

#include "common.h"
#include <assert.h>
#include <riscv_vector.h>
#include <string.h>

// reference https://github.com/riscv/riscv-v-spec/blob/master/example/strcpy.s
char *strcpy_vec(char *dst, const char *src) {
  char *save = dst;
  size_t vlmax = __riscv_vsetvlmax_e8m8();
  long first_set_bit = -1;
  size_t vl;
  while (first_set_bit < 0) {
    vint8m8_t vec_src = __riscv_vle8ff_v_i8m8(src, &vl, vlmax);

    vbool1_t string_terminate = __riscv_vmseq_vx_i8m8_b1(vec_src, 0, vl);
    vbool1_t mask = __riscv_vmsif_m_b1(string_terminate, vl);

    __riscv_vse8_v_i8m8_m(mask, dst, vec_src, vl);

    src += vl;
    dst += vl;

    first_set_bit = __riscv_vfirst_m_b1(string_terminate, vl);
  }
  return save;
}

int main() {
  const int N = 2000;
  const uint32_t seed = 0xdeadbeef;
  srand(seed);

  // data gen
  char s0[N];
  gen_string(s0, N);

  // compute
  char golden[N], actual[N];
  strcpy(golden, s0);
  strcpy_vec(actual, s0);

  // compare
  puts(strcmp(golden, actual) == 0 ? "pass" : "fail");
}
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

1 participant