Skip to content

Examples added #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 3, 2020
Merged

Examples added #197

merged 12 commits into from
Dec 3, 2020

Conversation

oleksandr-pavlyk
Copy link
Contributor

@oleksandr-pavlyk oleksandr-pavlyk commented Dec 3, 2020

Closes #187

This PR reorganizes examples/ folder. The current structure is as follows:

(idp) [14:14:25 ansatnuc04 examples]$ tree .
.
├── cython
│   ├── sycl_buffer
│   │   ├── bench.py
│   │   ├── _buffer_example.pyx
│   │   ├── README.md
│   │   ├── run.py
│   │   ├── setup.py
│   │   ├── use_sycl_buffer.cpp
│   │   └── use_sycl_buffer.h
│   ├── sycl_direct_linkage
│   │   ├── _buffer_example.pyx
│   │   ├── run.py
│   │   ├── setup.py
│   │   ├── sycl_function.cpp
│   │   └── sycl_function.hpp
│   └── usm_memory
│       ├── blackscholes.pyx
│       ├── README.md
│       ├── reference_black_scholes.py
│       ├── run.py
│       ├── setup.py
│       ├── sycl_blackscholes.cpp
│       └── sycl_blackscholes.hpp
└── python
    ├── create_sycl_queues.py
    ├── usm_memory_allocation.py
    ├── usm_memory_host_access.py
    └── usm_memory_operation.py

5 directories, 23 files

Examples in python/ folder intend to show usage of dpctl from Python. Perhaps this folder may also showcase usage of ctypes to interface with DPPLSyclInterface shared library.

Examples in cython/ folder intend to provide examples of building Cython extensions using dpctl.

Forthcoming examples will show pybind11 as well as SWIG, which will go in their respective folders.

1. Cython/sycl_direct_linkage

Example of native extension "cdef import"-ing sycl C++ classes directly
from CL/sycl.hpp

Queue is created within the function, adding measurable overhead.

Extension uses GEMV to compute column-wise total of a C-contiguous matrix,
and illustrates linking to oneMKL.

2. Cython/sycl_bufer

Example of native extension building on the above, but illustrating getting
the queue from dpctl.

3. Cython/usm_memory

Example of native extension allocating USM shared memory via dpctl, and using
it as a buffer underlying NumPy array.

Cython functions dispatches to a SYCL code that works with USM pointer.

One function populates USM memory underneath NumPy array with random numbers
using ``oneapi::mkl::rng::device`` function used in SYCL kernel, with random
number being parameters of European vanilla options.

The second function uses SYCL to price these options using Black-Scholes
formula.
@PokhodenkoSA
Copy link
Contributor

Is it possible to create makefile for building Cython examples?

@diptorupd
Copy link
Contributor

Is it possible to create makefile for building Cython examples?

We can add an optional cmake option to build the examples? Should we also add examples for the C API in this folder?

@oleksandr-pavlyk
Copy link
Contributor Author

Each example can be built using CXX=dpcpp CC=clang python setup.py develop. This is reflected in README.md

@PokhodenkoSA
Copy link
Contributor

@diptorupd
I think we can check examples in this PR manually. Creating build scripts and CI should be in separate PR.

Copy link
Contributor

@PokhodenkoSA PokhodenkoSA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please update main README.md section Examples too?

@diptorupd
Copy link
Contributor

Merging, as this is a big improvement over what we have currently.

@diptorupd diptorupd merged commit 3d2dbd6 into master Dec 3, 2020
@diptorupd diptorupd deleted the examples-added branch December 3, 2020 23:26
@diptorupd diptorupd mentioned this pull request Dec 4, 2020
1 task
@PokhodenkoSA PokhodenkoSA mentioned this pull request Dec 4, 2020
@diptorupd diptorupd mentioned this pull request Dec 4, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Examples are out of date Add more examples SYCL functionalities
3 participants