Skip to content

Instantly share code, notes, and snippets.

View standy66's full-sized avatar

Andrew Stepanov standy66

  • Quantum Light Capital
  • London, United Kingdom
View GitHub Profile
@mmellison
mmellison / grpc_asyncio.py
Last active August 6, 2024 01:23
gRPC Servicer with Asyncio (Python 3.6+)
import asyncio
from concurrent import futures
import functools
import inspect
import threading
from grpc import _server
def _loop_mgr(loop: asyncio.AbstractEventLoop):
@teamdandelion
teamdandelion / labels_1024.tsv
Last active February 6, 2024 08:33
TensorBoard: TF Dev Summit Tutorial
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
7
2
1
0
4
1
4
9
5
9
@andersx
andersx / fastexp.h
Created February 16, 2015 01:27
Very fast EXP(x) for AVX2+FMA instructions
// Approximation for EXP(x) -- very fast, but not super accurate
static inline __m256 _mm256_expfaster_ps(const __m256 &q) {
const __m256 C1 = _mm256_set1_ps(1064872507.1541044f);
const __m256 C2 = _mm256_set1_ps(12102203.161561485f);
return _mm256_castsi256_ps(_mm256_cvttps_epi32(_mm256_fmadd_ps(C2, q, C1)));
}
@andersx
andersx / exp_avx.cpp
Last active March 16, 2018 15:28
EXP(x) for AVX2
// Approximation for EXP(x), only valid for -126.0f < x < 0.0f.
static inline __m256 _mm256_expfast_ps(const __m256 &q) {
const __m256 INVLOG_2 = _mm256_set1_ps(1.442695040f);
const __m256 BIT_SHIFT = _mm256_set1_ps(8388608);
const __m256 ONE = _mm256_set1_ps(1.0f);
const __m256 C1 = _mm256_set1_ps(121.2740838f);
const __m256 C2 = _mm256_set1_ps(27.7280233f);
const __m256 C3 = _mm256_set1_ps(4.84252568f);
@jboner
jboner / latency.txt
Last active November 17, 2024 11:32
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@hannes-brt
hannes-brt / pyximport_numpy.py
Created December 28, 2010 13:08
Setup pyximport to include the numpy headers
import pyximport
import numpy as np
pyximport.install(setup_args={'include_dirs': np.get_include()})