This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See companion blog post <https://mazzo.li/posts/crc-tips.html> for | |
// extended commentary. | |
// | |
// Compiled with | |
// | |
// % clang++ --version | |
// clang version 17.0.6 | |
// % clang++ -std=c++20 -march=raptorlake -Wall crc32c-tips.cpp -o crc32c-tips | |
#include <stdint.h> | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See <https://mazzo.li/posts/stopping-linux-threads.html> | |
// for blog post. | |
// | |
// Spawns a thread with a server listening on 55555 UDP, and | |
// then terminates it after 1 minute. | |
// | |
// I compile and run with | |
// | |
// clang++ -Wall -std=c++20 server.cpp -lpthread -o server && ./server | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From <https://github.com/clefru/nur-packages/tree/f633986f5e31afdd130595b6dc0dea6824d69ef9/pkgs/ib-tws> | |
{ pkgs ? import <nixpkgs> {} }: | |
with pkgs; | |
let | |
twsWrap = builtins.toFile "tws-wrap.sh" '' | |
#!/bin/sh | |
export INSTALL4J_JAVA_HOME_OVERRIDE='__JAVAHOME__' | |
mkdir -p $HOME/.tws | |
VMOPTIONS=$HOME/.tws/tws.vmoptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If TEST_RACE = False, no exception is thrown. If it's True, it is. The only difference is | |
# a sleep in _joinrealpath. | |
TEST_RACE = False | |
import os | |
import time | |
import threading | |
import pathlib | |
def realpath(filename): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Benchmark for Eigen change, see <https://gitlab.com/libeigen/eigen/-/merge_requests/734#note_743674873> | |
Comment reported here for posterity: | |
Here's a synthetic "benchmark" which I _believe_ shows the difference: https://gist.github.com/bitonic/2d09df858ba2233b7f472f5f8c0512b4 . | |
I say that I believe that it exhibits the difference because it shows the runtime differences that I'd expect, with some caveats (see comments on number of instructions below). | |
However, I have not inspected the assembly manually to check that the code varies in the way I'd expect, which would be a requirement to ensure that things change in the way we expect. That is a bit more labor intensive, and while I might do it, I don't have time to do it right now. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Full NixOS configuration for a ZFS server with full disk encryption hosted on Hetzner. | |
# See <https://mazzo.li/posts/hetzner-zfs.html> for more information. | |
{ config, pkgs, ... }: | |
let | |
# Deployment-specific parameters -- you need to fill these in where the ... are | |
hostName = "..."; | |
publicKey = "..."; | |
# From `ls -lh /dev/disk/by-id` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ lib | |
, stdenv | |
, coreutils | |
, callPackage | |
, makeWrapper | |
, requireFile | |
, python3 | |
, writeTextFile | |
, binutils | |
, patchelf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2021 Francesco Mazzoli <[email protected]> | |
// | |
// Permission to use, copy, modify, and distribute this software for any | |
// purpose with or without fee is hereby granted, provided that the above | |
// copyright notice and this permission notice appear in all copies. | |
// | |
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See <https://gist.github.com/pervognsen/b58108d134824e61caedffcc01004e03> for | |
// Per Vognsen gist on value speculation. | |
// | |
// I compile this on linux with | |
// | |
// $ clang --version | |
// clang version 12.0.0 | |
// Target: x86_64-unknown-linux-gnu | |
// $ clang -static -Wall -O3 value-speculation-linux.c -o value-speculation-linux | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MultiWayIf #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE RecordWildCards #-} | |
import Data.List (transpose) | |
data Forward a = Forward { _value :: !a, _grad :: !a } | |
deriving (Show, Eq) | |
lift :: Num a => a -> Forward a | |
lift a = Forward { _value = a, _grad = 0 } |
NewerOlder