Skip to content

Commit 128c192

Browse files
authored
Add files via upload
1 parent 4c5c8d8 commit 128c192

31 files changed

+674
-0
lines changed

demos/mcpi/LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
BSD 2-Clause License
2+
3+
Copyright (c) 2023, Sergey Maydanov
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
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 HOLDER 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.

demos/mcpi/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# MCPI - Monte Carlo estimation of Pi using numpy, numba, dpnp, numba-dpex
2+
3+
This is a "Hello, World" application in Monte Carlo methods. It stresses random number generation
4+
along with some other math required for implementation of the Acceptance-Rejection technique.
5+
6+
For details please refer to [Wikipedia](https://en.wikipedia.org/wiki/Monte_Carlo_method)
7+
8+
## How to run
9+
10+
`python -m mcpi_demo [options]`
11+
12+
Demo can be invoked in several ways:
13+
14+
1. Cloning Github repo and running `python mcpi.py [options]`
15+
2. Cloning Github repo and running `python -m mcpi_demo [options]`
16+
3. Installing conda package and invoking executable
17+
* `conda install -c pycoddiy/label/dev mcpi-demo`
18+
* `mcpi [options]`
19+
20+
### Options
21+
22+
The following options are allowed:
23+
* `--variant [numpy, numba, dpnp, numba-dpex]` (default `numpy`): Implementation variant
24+
* `--batch-size`: Number of trial points in the batch
25+
* `--n-batches`: Number of batches
26+
27+
## Jupyter Notebook
28+
The Monte Carlo Pi demo is also supplemented with the [Juoyter Notebook](https://github.com/samaid/mcpi/blob/main/mcpi.ipynb),
29+
where step by step we illustrate the idea of the algorithm.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
python:
2+
- 3.8
3+
- 3.9
4+
- 3.10
5+
numpy:
6+
- 1.23

demos/mcpi/conda-recipe/meta.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package:
2+
name: mcpi-demo
3+
version: {{ GIT_DESCRIBE_TAG }}
4+
5+
source:
6+
path: ..
7+
8+
build:
9+
entry_points:
10+
- mcpi = mcpi_demo.pi:main
11+
number: {{ GIT_DESCRIBE_NUMBER }}
12+
script: {{ PYTHON }} -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv
13+
14+
requirements:
15+
host:
16+
- python
17+
run:
18+
- python
19+
- matplotlib >=3.7.1
20+
- numpy >=1.21
21+
- numba >=0.55
22+
- dpnp
23+
- numba-dpex
24+
25+
test:
26+
requires:
27+
- pytest
28+
commands:
29+
- mcpi --help
30+
- python -m mcpi_demo --variant numba
31+
- mcpi --batch-size 10 --n-batches 1
32+
imports:
33+
- mcpi_demo
34+
- mcpi_demo.impl.impl_versioner
35+
- mcpi_demo.impl.arg_parser
36+
37+
about:
38+
home: https://github.com/samaid
39+
license: BSD-2-Clause
40+
license_family: BSD
41+
license_file:
42+
- LICENSE
43+
summary: Monte Carlo method to compute Pi
44+
45+
extra:
46+
recipe-maintainers:
47+
- samaid

demos/mcpi/mcpi.ipynb

Lines changed: 387 additions & 0 deletions
Large diffs are not rendered by default.

demos/mcpi/mcpi.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from mcpi_demo.pi import main
2+
3+
main()

demos/mcpi/mcpi_demo/__init__.py

Whitespace-only changes.

demos/mcpi/mcpi_demo/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from mcpi_demo.pi import main
2+
3+
main()
152 Bytes
Binary file not shown.
737 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)