Skip to content

Instantly share code, notes, and snippets.

@nibrunie
nibrunie / vfrec7_bf16.c
Created February 8, 2025 16:48
Test program to list inputs for which vfrec7.v approximation is inexact in BFloat16
/** Determining when RVV 1.0 vfrev7.v SEW=32 result can not be converted
* exactly to a BF16 value. */
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
typedef union {
float f;
uint32_t u;
@nibrunie
nibrunie / vcrypto-lmul-alignment-test-case.c
Created September 22, 2024 20:56
[riscv-isa-sim] Simple test case for RISC-V vector crypto unaligned LMUL register indices
#include <stdio.h>
// How to build:
// riscv64-unknown-elf-gcc -march=rv64gcv_zvkned_zvksed_zvkg_zvknhb_zvksh_zvl128b vcrypto-lmul-alignment-test-case.c
// How to execute:
// spike --isa=rv64gcv_zvbc_zicntr_zihpm_zvkned_zvksed_zvkg_zvknhb_zvksh_zvl128b <pk-image> a.out
// This program aims at demonstrating that spike is flawed when
// it comes to executing vector crypto instructions with invalid register
@nibrunie
nibrunie / fp8Formats.py
Last active March 12, 2024 15:32
python generator to list values of various FP8 formats
# -*- coding: utf-8 -*-
# this script generates values for different 8-bit floating point formats
def bitMask(width):
""" generate a <width> wide bitmask """
return 2**width - 1
class FP8Fomat:
expBits = None # exponent field width (in bits)
@nibrunie
nibrunie / matrix_transpose.c
Created November 7, 2023 22:26
Toy example of vslide based 4x4 e32 matrix transpose in RVV
// build with clang trunk
// clang -O2 -march=rv64gcv
// https://godbolt.org/z/ebPcGPbG1
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <riscv_vector.h>