使用玄铁 910-VECTOR 核

ICE 芯片内部有三个玄铁910处理器,其中 CPU0与 CPU1为同构处理器,不支持 VECTOR 指令,CPU2支持VECTOR 扩展指令集。在 ICE 芯片中使用 VECTOR 核时,可以通过 U-Boot 配置来实现两个环境的切换,具体操作如下:

切换到 Vector 核:
setenv boot_vector 1
saveenv
boot

切换到非 VECTOR 核:

setenv boot_vector 0
saveenv
boot

启动后, 查看 cpuinfo:isa已带v

root@thead-910:~# cat /proc/cpuinfo
processor       : 0
hart            : 2
isa             : rv64imafdcvsu
mmu             : sv39
model name      : T-HEAD C910
freq            : 1.2GHz
icache          : 64kB
dcache          : 64kB
l2cache         : 2MB
tlb             : 1024 4-ways
cache line      : 64Bytes
address sizes   : 40 bits physical, 39 bits virtual
vector version  : 0.7.1

编译 Vector 程序

testvector.c:

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<riscv-vector.h>

#define vlen 128
#define sew 16
#define vmul 1
#define ISUNSIGN 0
#define VCTYPE "int16"

int main(int argc, char **argv)
{
    int vlmax = vmul*vlen/sew;
    int N=5;
    int avl[6] = {vlmax, vlmax-1, 2*vlmax-1, 2*vlmax+1000, 2*vlmax, 0};
    short int expect;
    int16xm1_t bb;
    int rte = 0;
    unsigned int gvl=0;
    long long max = 0;
    long long min = 0;
    char *name = argv[0];
    for(int t=0; t<N; t++) {
        gvl = vsetvli(vlmax, RVV_E16, RVV_M1);
        bb=vmvvi_int16xm1(15, gvl);
        for(int i=0; i<vlmax; i++) {
            if ( i < avl[t] )  {
                expect = 15;
            } else {
                expect =  0;
            }
            if ( bb[i]- expect != 0) {
                rte = -1;
            }
            printf("Expect = %d, Actual = %d, avl = %d\n",expect, bb[i], avl[t]);
        }
    }
    if ( rte != 0 )
        printf("FAIL: %s\n",name);
    else
        printf("PASS: %s\n",name);
    return rte;
}

编译命令:

riscv64-unknown-linux-gnu-gcc -O2 -march=rv64gcvxthead -mabi=lp64v -g -static -lm testvector.c -o testvector

results matching ""

    No results matching ""