Skip to content

Instantly share code, notes, and snippets.

View gkalsi's full-sized avatar

Gurjant Kalsi gkalsi

View GitHub Profile
@gkalsi
gkalsi / gist:c5004619d944cf020544a1eb155c559c
Last active September 29, 2023 18:46
Launch QEMU RiscV
#!/usr/bin/env bash
set -euo pipefail
CC="/home/gkalsi/code/sandbox/rv-hello-world/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang"
QEMU=
$CC --target=riscv64-linux -march=rv64gczve64d -static playground.c -o playground
./qemu-8.0.0-rc4/build/qemu-riscv64 -cpu rv64,v=true,zba=true,zbb=true,vlen=512,vext_spec=v1.0 ./playground
@gkalsi
gkalsi / build2.sh
Created June 29, 2023 00:08
Build FLAC for RV64 from source
#!/usr/bin/env bash
set -euo pipefail
# Fetch source code and toolchains and whatnot.
FLAC_REPO="https://github.com/xiph/flac.git"
OGG_REPO="https://github.com/xiph/ogg.git"
CROSS_COMPILER_URL="https://toolchains.bootlin.com/downloads/releases/toolchains/riscv64-lp64d/tarballs/riscv64-lp64d--glibc--stable-2022.08-1.tar.bz2"
CROSS_COMPILER_DIR="rv64-glibc"
CROSS_COMPILER_ZIP="${CROSS_COMPILER_DIR}.tar.bz2"
@gkalsi
gkalsi / main.cc
Last active May 2, 2023 21:09
Inline ARM NEON Vector Instructions
//
// Some notes:
// (1) To build and run invoke the following:
// `g++ main.cc -o main && ./main`
// This program builds with GCC but not Clang. I think it's because the SIMD syntax for Clang and GCC is different
// but I haven't confirmed this. Clang complains that `qN` is not a valid register. This would probably work fine
// if I used the `arm_neon.h` intrinsics header.
//
// (2) The codegen for Clang and GCC using the arm_neon header is somewhat different. It would be cool to see if one
// version is significantly faster than the other.
@gkalsi
gkalsi / main.py
Created September 15, 2022 21:53
def collatz(start : int):
iterations : int = 1
while start != 1:
if start % 2 == 0:
start = start / 2
else:
start = start * 3 + 1
iterations += 1
return iterations
name: upspin # you probably want to 'snapcraft register <name>'
version: '0.0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: A framework for naming everyone's everything. # 79 char long summary
description: |
Upspin is an experimental project to build a framework for naming and sharing
files and other data securely, uniformly, and globally: a global name system
of sorts.
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: classic # use 'strict' once you have the right plugs and slots
### Keybase proof
I hereby claim:
* I am gkalsi on github.
* I am gsk (https://keybase.io/gsk) on keybase.
* I have a public key whose fingerprint is 4FEB A71D 9676 BF2D 8C8B EA80 B1D3 B798 890F 1031
To claim this, I am signing this object: