Skip to content

How to count execution time? #6

Description

@js4ngu

Hi im jongsang who is user of DC-ROMA Gen2 Laptop.

Actually i have lots of interest in RVV.

now, i have curious of "vsetvli", "vle32.v", "vse32.v" Instruction's execution time.

I try to write test code like this.
`
#include <stdio.h>
#include <stdint.h>

#define VECTOR_SIZE 8
int main() {
uint64_t start, end, cycle;

asm volatile (
    "fence.i\n\t"         // Invalidate the instruction cache
    "rdcycle %0 \n\t"

    "vsetvli t0, %2, e32\n\t"
    "vsetvli t0, %2, e32\n\t"
    "vsetvli t0, %2, e32\n\t"
    "vsetvli t0, %2, e32\n\t"
    "vsetvli t0, %2, e32\n\t"

    "vsetvli t0, %2, e32\n\t"
    "vsetvli t0, %2, e32\n\t"
    "vsetvli t0, %2, e32\n\t"
    "vsetvli t0, %2, e32\n\t"
    "vsetvli t0, %2, e32\n\t"

    "fence.i\n\t"         // Invalidate the instruction cache
    "rdcycle %1 \n\t"

    : "=r"(start), "=r"(end)    // Output operands
    : "r"(VECTOR_SIZE)          // Input operand
    : "t0"                      // Clobbered register
);

printf("start: %ld\n", start);
printf("end: %ld\n", end);
cycle = end - start;
printf("cycle: %ld\n", cycle);
return 0;

}
`

But, result is confuse.
스크린샷 2024-09-04 오후 9 02 54

I cant understand about this result.

How does it take 0 cycles to perform "vsetvli" 10 times?

Is there any problem to my method?

If it has problem, please give some advice...

Thank you.

Best regard,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions