I hereby claim:
- I am pkhuong on github.
- I am pkhuong (https://keybase.io/pkhuong) on keybase.
- I have a public key ASCqsTjZLilMzRmz9kuPxAn3nF3Z-gOZMEtG8-G3qi4o8go
To claim this, I am signing this object:
(defun multiplicative-inverse (x bitwidth) | |
"Iteratively finds the multiplicative inverse of x mod 2^bitwidth. | |
The induction step uses the fact that, for a given inverse x^-1 | |
with (x * x^-1) mod 2^w == 1, (x * x^-1) mod 2^{w - 1} == 1 as | |
well. We start with the trivial inverse mod 2, and increase the | |
bitwidth iteratively: given inv_{w - 1} = x^-1 mod 2^{w - 1}, | |
x^-1 mod 2^w is either inv_{w - 1}, or inv_{w - 1} + 2^{w - 1}." | |
(assert (oddp x)) | |
(let ((inverse 1)) |
#include "trait.h" | |
static inline int | |
cmp_int(int x, int y) | |
{ | |
if (x == y) | |
return 0; | |
return x < y ? -1 : 1; | |
} |
I hereby claim:
To claim this, I am signing this object:
import math | |
import struct | |
import unittest | |
import hypothesis.strategies as st | |
from hypothesis.stateful import Bundle, RuleBasedStateMachine, consumes, invariant, multiple, precondition, rule | |
class VarianceStack: | |
def __init__(self): | |
self.n = 0 |
#define RUN_ME /* | |
exec cc -O2 -W -Wall -std=c99 -shared $0 -o "$(basename $0 .c).so" -fPIC | |
*/ | |
/* | |
* Copyright 2019 Paul Khuong | |
* SPDX-License-Identifier: BSD-2-Clause | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions |
FROM alpine:latest AS builder | |
RUN echo "foo" > /foo.txt | |
FROM scratch | |
COPY --from=builder /*.txt . |
(defstruct div-by-mul-constants | |
;; Implement truncated integer by `divisor` with a fixed point | |
;; approximation. | |
(divisor 0 :type sb-ext:word | |
:read-only t) | |
;; The reciprocal is roughly multipler / 2^(W + shift), | |
;; where W is the word width. | |
(multiplier 0 :type sb-ext:word | |
:read-only t) | |
(shift 0 :type sb-ext:word |
diff --git a/src/compiler/x86-64/simd-pack-256.lisp b/src/compiler/x86-64/simd-pack-256.lisp | |
index e6bdc560c..228f2018a 100644 | |
--- a/src/compiler/x86-64/simd-pack-256.lisp | |
+++ b/src/compiler/x86-64/simd-pack-256.lisp | |
@@ -189,7 +189,7 @@ | |
(:policy :fast-safe) | |
(:generator 3 | |
(inst vextracti128 tmp x 1) | |
- (inst vpextrq dst x 1))) | |
+ (inst vpextrq dst tmp 1))) |
;; load https://github.com/pkhuong/csm | |
(defun player-one () | |
(* (random 1d0) (random 1d0))) | |
(defun player-two () | |
(expt (random 1d0) 2)) | |
(defun player-one-wins () | |
(> (player-one) (player-two))) |
(sb-c:defknown prefetch ((member :nta :t0 :t1 :t2) | |
sb-sys:system-area-pointer sb-vm:signed-word | |
(member 2 4 8 16) | |
fixnum) | |
(values &optional) | |
(sb-c:any sb-c:always-translatable) :overwrite-fndb-silently t) | |
(sb-c:define-vop (prefetch) | |
(:translate prefetch) | |
(:policy :fast-safe) |