Skip to content

Commit d46811a

Browse files
Initial commit of mkl_random
0 parents  commit d46811a

20 files changed

+10373
-0
lines changed

LICENSE.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2017, Intel Corporation
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright notice,
7+
this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution.
11+
* Neither the name of Intel Corporation nor the names of its contributors
12+
may be used to endorse or promote products derived from this software
13+
without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
19+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
##``mkl_random`` -- a NumPy-based Python interface to Intel (R) MKL Random Number Generation functionality
2+
3+
`mkl_random` has started as Intel (R) Distribution for Python optimizations for NumPy.
4+
5+
Per NumPy's community suggestions, voiced in https://github.com/numpy/numpy/pull/8209, it is being released as a
6+
stand-alone package.
7+
8+
Prebuilt `mkl_random` can be installed into conda environment from Intel's channel on Anaconda cloud:
9+
10+
```
11+
conda install -c intel mkl_random
12+
```
13+
14+
`mkl_random` is not fixed-seed backward compatible drop-in replacement for `numpy.random`, meaning that it implements sampling from the same distributions as `numpy.random`.
15+
16+
For distributions directly supported in Intel (R) Math Kernel Library (MKL), `method` keyword is supported:
17+
18+
```
19+
mkl_random.standard_normal(size=(10**5, 10**3), method='BoxMuller')
20+
```
21+
22+
Additionally, `mkl_random` exposes different basic random number generation algorithms available in MKL. For example to use `SFMT19937` use
23+
24+
```
25+
mkl_random.RandomState(77777, brng='SFMT19937')
26+
```
27+
28+
For generator families, such that `MT2203` and Wichmann-Hill, a particular member of the family can be chosen by specifying ``brng=('WH', 3)``, etc.
29+
30+
See MKL reference guide for more details:
31+
https://software.intel.com/en-us/mkl-developer-reference-c-random-number-generators

conda-recipe/bld.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@rem Remember to source Intel (R) Compiler
2+
3+
set CC=icl
4+
set LD=xilink
5+
6+
%PYTHON% setup.py config --compiler=intelemw install --old-and-unmanageable
7+
if errorlevel 1 exit 1

conda-recipe/build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash -x
2+
3+
if [ `uname` == Darwin ]; then
4+
export MACOSX_DEPLOYMENT_TARGET=10.10
5+
fi
6+
7+
export CFLAGS="-I$PREFIX/include $CFLAGS"
8+
export CC=icc
9+
export LDSHARED="icc -shared"
10+
11+
$PYTHON setup.py config --compiler=intelem --fcompiler=intelem build install --old-and-unmanageable

conda-recipe/meta.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{% set version = "1.0.0" %}
2+
{% set buildnumber = 5 %}
3+
4+
### If you change the iccver here, you must also set the path correctly in build.sh / bld.bat!!!
5+
{% set iccver = "16.0.3" %} [unix or py3k]
6+
{% set iccver = "13.1.5" %} [win and py27]
7+
8+
package:
9+
name: mkl_random
10+
version: {{ version }}
11+
12+
source:
13+
git_url: http://github.com/IntelPython/mkl_random
14+
git_branch: v{{version}}
15+
16+
build:
17+
number: {{buildnumber}}
18+
features:
19+
- intel
20+
always_include_files:
21+
- {{ SP_DIR.replace('\\', '/') if win else SP_DIR }}/mkl_random/__init__.py
22+
- {{ SP_DIR.replace('\\', '/') if win else SP_DIR }}/mkl_random/mklrand.*
23+
- {{ SP_DIR.replace('\\', '/') if win else SP_DIR }}/mkl_random/setup.py
24+
- {{ SP_DIR.replace('\\', '/') if win else SP_DIR }}/mkl_random/tests/test_random.py
25+
- {{ SP_DIR.replace('\\', '/') if win else SP_DIR }}/mkl_random/tests/test_regressions.py
26+
- {{ SP_DIR.replace('\\', '/') if win else SP_DIR }}/mkl_random/__pycache__/*
27+
- {{ SP_DIR.replace('\\', '/') if win else SP_DIR }}/mkl_random/tests/__pycache__/*
28+
29+
requirements:
30+
build:
31+
- python
32+
- setuptools
33+
- intelpython
34+
- mkl-devel [not nomkl]
35+
- icc_rt {{iccver}}
36+
- cython
37+
- numpy x.x
38+
run:
39+
- python
40+
- mkl [not nomkl]
41+
- icc_rt >={{iccver}}
42+
- intelpython
43+
- numpy x.x
44+
45+
test:
46+
commands:
47+
- nosetests -v mkl_random
48+
requires:
49+
- nose
50+
imports:
51+
- mkl_random
52+
- mkl_random.mklrand
53+
54+
about:
55+
home: http://github.com/IntelPython/mkl_random
56+
license: BSD
57+
license_file: LICENSE.txt
58+
summary: NumPy-based implementation of random number generation sampling using Intel (R) Math Kernel Library, mirroring numpy.random, but exposing all choices of sampling algorithms available in MKL.

mkl_random/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
# Copyright (c) 2017, Intel Corporation
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# * Redistributions of source code must retain the above copyright notice,
8+
# this list of conditions and the following disclaimer.
9+
# * Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in the
11+
# documentation and/or other materials provided with the distribution.
12+
# * Neither the name of Intel Corporation nor the names of its contributors
13+
# may be used to endorse or promote products derived from this software
14+
# without specific prior written permission.
15+
#
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
from __future__ import division, absolute_import, print_function
28+
29+
from .mklrand import *
30+
31+
from numpy.testing.nosetester import _numpy_tester
32+
test = _numpy_tester().test
33+
bench = _numpy_tester().bench

0 commit comments

Comments
 (0)