Skip to content

Instantly share code, notes, and snippets.

View pitrou's full-sized avatar

Antoine Pitrou pitrou

View GitHub Profile
C:\>conda create -p c:\t\env python=2.6 numpy llvmpy
Fetching package metadata: ...
Solving package specifications: .
Package plan for installation in environment c:\t\env:
The following packages will be downloaded:
package | build
---------------------------|-----------------
llvmpy-0.12.6 | py26_0 4.9 MB
import gc
import sys
import llvm.core as lc
import llvm.ee as le
# Cache plausible return values for sys.getallocatedblocks() - _base, to avoid
# allocating them later.
_int_pool = {}
$ LANG=C wget https://www.openssl.org/source/openssl-1.0.1h.tar.gz
--2014-07-15 02:04:59-- https://www.openssl.org/source/openssl-1.0.1h.tar.gz
Resolving www.openssl.org (www.openssl.org)... 185.9.166.106
Connecting to www.openssl.org (www.openssl.org)|185.9.166.106|:443... connected.
ERROR: The certificate of `www.openssl.org' is not trusted.
ERROR: The certificate of `www.openssl.org' hasn't got a known issuer.
building 'readline' extension
gcc -pthread -fPIC -Wno-unused-result -Werror=declaration-after-statement -g -O0 -Wall -Wstrict-prototypes -I./Include -I/home/antoine/miniconda3/envs/_build/include -I. -IInclude -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/home/antoine/miniconda3/conda-bld/work/Python-3.4.1/Include -I/home/antoine/miniconda3/conda-bld/work/Python-3.4.1 -c /home/antoine/miniconda3/conda-bld/work/Python-3.4.1/Modules/readline.c -o build/temp.linux-x86_64-3.4-pydebug/home/antoine/miniconda3/conda-bld/work/Python-3.4.1/Modules/readline.o
In file included from /home/antoine/miniconda3/envs/_build/include/readline/readline.h:36:0,
from /home/antoine/miniconda3/conda-bld/work/Python-3.4.1/Modules/readline.c:32:
/home/antoine/miniconda3/envs/_build/include/readline/rltypedefs.h:34:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
typedef int Function ();
^
/home/antoine/miniconda3/envs/_build/include/readline/rltypedefs.h:35:1: warning: function decl
### Keybase proof
I hereby claim:
* I am pitrou on github.
* I am pitrou (https://keybase.io/pitrou) on keybase.
* I have a public key whose fingerprint is 2CC2 3EF0 90A2 8BAC 5DDC 885F 769B DC21 29C2 658C
To claim this, I am signing this object:
from __future__ import absolute_import, print_function, division
import math
import numpy as np
from numba import jit, vectorize
from numba.utils import benchmark
Haswell addition main loop:
.LBB0_15:
vmovupd -96(%rsi), %ymm0
vmovupd -64(%rsi), %ymm1
vmovupd -32(%rsi), %ymm2
vmovupd (%rsi), %ymm3
vaddpd -96(%rdx), %ymm0, %ymm0
vaddpd -64(%rdx), %ymm1, %ymm1
vaddpd -32(%rdx), %ymm2, %ymm2
>>> print(type(a), a.dtype, a[:10])
<class 'numpy.ndarray'> [('x', '<i4'), ('y', '<f4')] [(0, 0.0) (1, 0.0) (2, 0.0) (3, 0.0) (4, 0.0) (5, 0.0) (6, 0.0) (7, 0.0)
(8, 0.0) (9, 9.171498449005928e-41)]
>>> print(type(aa), aa.dtype, aa[:10])
<class 'numpy.core.records.recarray'> [('x', '<i4'), ('y', '<f4')] [(0, 0.0) (1, 0.0) (2, 0.0) (3, 0.0) (4, 0.0) (5, 0.0) (6, 0.0) (7, 0.0)
(8, 0.0) (9, 9.171498449005928e-41)]
>>> %timeit numba_copy_x_to_y(a, b)
100000 loops, best of 3: 3.51 µs per loop
>>> %timeit numba_copy_x_to_y(aa, bb)
10000 loops, best of 3: 157 µs per loop
// gcc avx.c -mavx -std=c99 -O2
// while true; do ./a.out; done > log
// analyze via np.genfromtxt, e.g. min, 10th percentile, median
#include <stdio.h>
#include <string.h>
#include <x86intrin.h>
#include <avxintrin.h>
#define N 5000
// gcc avx.c -mavx -std=c99 -O2
// while true; do ./a.out; done > log
// analyze via np.genfromtxt, e.g. min, 10th percentile, median
#include <stdio.h>
#include <string.h>
#include <x86intrin.h>
#include <avxintrin.h>
#define N 3000