Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    有关编译c内联矢量指令时,unknown register name ‘v1’ in ‘asm’的问题

    MR Series
    3
    18
    5485
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      zny666 LV 3 last edited by whycan

      系统是D1-H上搭载的Ubuntu系统,用的gcc编译器是apt install上的,目前编译出现了问题,
      fdd0ed54-b97d-41cb-b951-ae6476948f16-image.png
      其中testv.c文件的内容如下

      #include <unistd.h>
      #include <stdio.h>
      //#include <riscv-vector.h>
       
      void test_v(void)
      {
        float a[]={1.0,2.0,3.0,4.0};
        float b[]={1.0,2.0,3.0,4.0};
        float c[]={0.0,0.0,0.0,0.0};
        int len=4;
        int i=0;
        //inline assembly for RVV 0.7.1
        //for(i=0; i<len; i++){c[i]=a[i]+b[i];}
        asm volatile(
                     "mv         t4,   %[LEN]       \n\t"
                     "mv         t1,   %[PA]        \n\t"
                     "mv         t2,   %[PB]        \n\t"
                     "mv         t3,   %[PC]        \n\t"
                     "LOOP1:                        \n\t"
                     "vsetvli    t0,   t4,   e32,m1 \n\t"
                     "sub        t4,   t4,   t0     \n\t"
                     "slli       t0,   t0,   2      \n\t" //Multiply number done by 4 bytes
                     "vle.v      v0,   (t1)         \n\t"
                     "add        t1,   t1,   t0     \n\t"
                     "vle.v      v1,   (t2)         \n\t"
                     "add        t2,   t2,   t0     \n\t"
                     "vfadd.vv   v2,   v0,   v1     \n\t"
                     "vse.v      v2,   (t3)         \n\t"
                     "add        t3,   t3,   t0     \n\t"
                     "bnez       t4,   LOOP1        \n\t"
                     :
                     :[LEN]"r"(len), [PA]"r"(a),[PB]"r"(b),[PC]"r"(c)
                     :"cc","memory", "t0", "t1", "t2", "t3", "t4",
                      "v0", "v1", "v2"
                     );
      
                    for(i=0; i<len; i++){
                                  printf("\n");
                                  printf("%f\n",c[i]);
                                  printf("\n");
                     }
      }
      int main(){
      
      
      test_v();
      
      
      return 0;
      }
      

      请问各位大大这是出现了什么问题,谢谢!

      whycan 1 Reply Last reply Reply Quote Share 0
      • Z
        zny666 LV 3 last edited by

        刚刚使用了tina的交叉编译器,能够成功编译出可执行文件tmp3,但是在板子上无法执行,
        7924651d-97d1-4248-8c6e-3b962f21b029-image.png

        whycan KunYi 2 Replies Last reply Reply Quote Share 0
        • Z
          zny666 LV 3 last edited by

          刚刚又尝试了在tinalinux上跑交叉编译出的文件,结果如下
          3c07049d-7dd1-4156-8c82-b111a1769de2-image.png
          还是无法正常运行,现在在tina和ubuntu上都无法运行,请大佬帮忙,如果过于麻烦,可以有偿

          1 Reply Last reply Reply Quote Share 0
          • whycan
            whycan晕哥 LV 9 @zny666 last edited by

            @zny666 在 有关编译c内联矢量指令时,unknown register name ‘v1’ in ‘asm’的问题 中说:

            但是在板子上无法执行

            编译命令行加 -static

            1 Reply Last reply Reply Quote Share 0
            • whycan
              whycan晕哥 LV 9 @zny666 last edited by

              @zny666 在 有关编译c内联矢量指令时,unknown register name ‘v1’ in ‘asm’的问题 中说:

              目前编译出现了问题

              可能gcc功能不全,或者这个版本不支持这个语法。

              Z 1 Reply Last reply Reply Quote Share 0
              • KunYi
                KunYi LV 8 @zny666 last edited by

                @zny666
                first try
                chmod a+x ./tmp3
                then run
                sudo ./tmp3

                Z 1 Reply Last reply Reply Quote Share 0
                • Z
                  zny666 LV 3 @whycan last edited by

                  @whycan
                  a8bc6e9d-ee57-443d-bcdc-17b116f4538e-image.png
                  目前是这样的

                  whycan 1 Reply Last reply Reply Quote Share 0
                  • Z
                    zny666 LV 3 @KunYi last edited by

                    @kunyi
                    569f5f3f-594d-4cbf-b25d-4c6e2546ddf1-image.png
                    thank you,but now it still cannot run.

                    KunYi 1 Reply Last reply Reply Quote Share 0
                    • whycan
                      whycan晕哥 LV 9 @zny666 last edited by whycan

                      @zny666 在 有关编译c内联矢量指令时,unknown register name ‘v1’ in ‘asm’的问题 中说:

                      目前是这样的

                      电脑ubuntu的命令行最后加上 -static

                      Z 1 Reply Last reply Reply Quote Share 0
                      • KunYi
                        KunYi LV 8 @zny666 last edited by

                        @zny666
                        Which filesystem fat or ext4 on SDCARD?
                        maybe try copy ./tmp3 on ext4 filesystem to verify again,

                        cp -vf tmp3 /tmp && chmod a+x /tmp/tmp3 && /tmp/tmp3

                        1 Reply Last reply Reply Quote Share 0
                        • Z
                          zny666 LV 3 @whycan last edited by

                          @whycan
                          cac1be0a-1fe6-4519-977e-20eb2d93561b-image.png
                          添加过了,但是还是报错

                          whycan 1 Reply Last reply Reply Quote Share 0
                          • whycan
                            whycan晕哥 LV 9 @zny666 last edited by

                            @zny666
                            不应该是 riscv64***-gcc 命令吗?

                            Z 3 Replies Last reply Reply Quote Share 1
                            • Z
                              zny666 LV 3 @whycan last edited by

                              @whycan
                              刚刚的截图是我在D1上运行的ubuntu系统,系统中带有riscv版本的gcc编译器,所以我直接在板子的ubuntu系统上运行了gcc。
                              下面我又使用了tina的交叉编译工具链,不管加不加static都能够编译成功,
                              5cf7252d-d3da-4cb6-b7a5-62c495fc4316-image.png
                              之后我将生成的tmp5传到板子上运行,出现了以下问题
                              f8c75f0c-88d7-432a-87cb-141ed1c642ce-image.png
                              这个问题是因为编译出的指令集不支持吗

                              1 Reply Last reply Reply Quote Share 0
                              • Z
                                zny666 LV 3 @whycan last edited by

                                @whycan
                                刚刚我又使用了官网上提供的其他工具链,如果使用官网最新的下图中工具链,
                                68ecc4a4-a388-4c42-8b8e-c1cd4283af86-image.png
                                会出现以下问题,
                                4e17e1c7-d34d-4163-94fd-7b8986d62958-RR8C%P2CZB519030K$D1{IY.png
                                然后如果按照原教程提供的2021年的工具链,能够编译成功,如下图
                                abd6d9d6-763e-486a-811d-92823771454c-image.png
                                但是在板子上运行时,会出现下面的报错(是在板子的ubuntu上运行)
                                5b056f85-c82b-4c35-9981-f460113eb6d4-image.png

                                1 Reply Last reply Reply Quote Share 0
                                • Z
                                  zny666 LV 3 @whycan last edited by

                                  @whycan 所以是不是我的板子没有开启rvv指令的支持?如果是这个原因的话,请问应该怎么打开呢

                                  whycan 1 Reply Last reply Reply Quote Share 0
                                  • whycan
                                    whycan晕哥 LV 9 @zny666 last edited by

                                    @zny666

                                    建议先用官方SDK包

                                    Z 1 Reply Last reply Reply Quote Share 0
                                    • Z
                                      zny666 LV 3 @whycan last edited by

                                      @whycan 后面用的交叉编译工具都是使用的官方工具,但是没办法在Ubuntu上正常执行,如果在tina linux上运行,则如下图
                                      48694966-e3eb-472c-8949-8ce9a84c2650-image.png
                                      在板载的ubuntu上运行则是报illegal instruction的错误。

                                      whycan 1 Reply Last reply Reply Quote Share 0
                                      • whycan
                                        whycan晕哥 LV 9 @zny666 last edited by

                                        @zny666
                                        可能里面有不支持的指令。

                                        1 Reply Last reply Reply Quote Share 0
                                        • 1 / 1
                                        • First post
                                          Last post

                                        Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

                                        行为准则 | 用户协议 | 隐私权政策