Skip to content

Instantly share code, notes, and snippets.

while ! ./_/build.sh 2> _/build.log; do
if [[ $(grep "No such file or directory" _/build.log) =~ .*error..(.*)..No.such.* ]]; then
missing=${BASH_REMATCH[1]}
echo "Adding file" $missing
mkdir -p $(dirname _missing/$missing)
touch _missing/$missing
elif [[ $(grep "was not declared in this scope" _/build.log) =~ .*error..‘([A-Z0-9_]*)’.was.not.* ]]; then
missing=${BASH_REMATCH[1]}
echo "Adding constant" $missing
@rrika
rrika / expected_output.v
Created March 27, 2018 01:59
Using CAQE to synthesize Verilog code
/* Generated by Yosys 0.7+528 (git sha1 3f007024, gcc 7.3.0 -fPIC -Os) */
(* top = 1 *)
module \7controller.aig (bit_control_0, bit_mode_0, bit_control_16, bit_control_15, bit_control_14, bit_control_13, bit_control_12, bit_control_11, bit_control_10, bit_control_9, bit_control_8, bit_control_7, bit_control_6, bit_control_5, bit_control_4, bit_control_3, bit_control_2, bit_control_1);
output bit_control_0;
output bit_control_1;
output bit_control_10;
output bit_control_11;
output bit_control_12;
output bit_control_13;
def cone2(v1, v2):
return Cone(direction=normalize(v1+v2), angle_by_point=v1)
def cone3(v1, v2, v3):
return Cone(direction=normalize(cross(v2-v1, v3-v1)), angle_by_point=v1)
def cone4(v1, v2, v3, v4):
c = cone2(v1, v2)
if v3 not in c:
c = cone2(v1, v3)
extern crate llvm_sys;
use std::ffi::CStr;
use llvm_sys::core::*;
use llvm_sys::bit_reader::*;
fn main() {
unsafe {
let mut llvm_module = std::mem::uninitialized();
let mut buffer = std::mem::uninitialized();
@rrika
rrika / test.c
Created December 14, 2018 00:08
Mesa hooking
/*
MESA=<path to git clone of git://anongit.freedesktop.org/mesa/mesa>
gcc
-I$MESA/include/
-I$MESA/src/
-I$MESA/src/mesa
-I$MESA/src/mapi
-I$MESA/src/gallium/include
-lglapi
@rrika
rrika / test.py
Last active May 8, 2019 11:38
Trying to write a borrow checker
class Expr: pass
class Type: pass
class Stmt: pass
class RefMut(Type):
def __init__(self, lt, ty):
self.lt = lt
self.ty = ty
def __repr__(self):
return "&'{} {!r}".format(self.lt, self.ty)
factorial = (
("op", "a", "input"),
("loop",
("phi", "a", "a", "a2"),
("phi", "b", 1, "b2"),
("op", "b2", "mul", "a", "b"),
("op", "a2", "sub", "a", 1),
("op", "loop-condition", "gt", "a", 0),
"loop-condition"
)
import math
# an implementation of
# Edge Finding Filtering Algorithm for Discrete Cumulative Resources in O(kn log n)
# by Petr Vilı́m
# TODO: make this truly O(n log n) by addressing the tree
# rebuild in every iteration in compute_update,
class Task:
// a sat solver for instances with <= 32 variables
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#define b00000 0
#define b00001 1
#define b00010 2
#define b00011 3
@rrika
rrika / test.cpp
Created February 15, 2021 19:41
HIP without HIP
// clang++
// -x hip
// test.cpp
// -O3
// --cuda-gpu-arch=gfx1010
// --hip-device-lib=dummy.bc
// --hip-device-lib-path=path_to_dummy_bc
// -nogpuinc
// -fuse-ld=lld
// -fgpu-rdc