Skip to content

Use ctypedef ... except + to intercept oneMKL exceptions #244

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 3 commits into from
Nov 18, 2020

Conversation

oleksandr-pavlyk
Copy link
Contributor

E.g.

In [1]: import dpnp
mkl-service + Intel(R) MKL: THREADING LAYER: (null)
mkl-service + Intel(R) MKL: setting Intel(R) MKL to use INTEL OpenMP runtime
mkl-service + Intel(R) MKL: preloading libiomp5.so runtime
MKL_VERBOSE Intel(R) MKL 2021.0 Update 1 beta10 build 20201008 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors, Lnx 1.
10GHz lp64 intel_thread
MKL_VERBOSE SDOT(2,0x561c72606c10,1,0x561c72606c10,1) 1.41ms CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:6
Running on: Intel(R) Graphics Gen9 [0x9bca]
DPCtrl SYCL queue used
SYCL kernels link time: 0.190619 (sec.)

In [2]: dpnp.random.gamma(3.4, 0.67)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)

<< stack elided >>

RuntimeError: oneMKL: rng/generate: Intel(R) Graphics Gen9 [0x9bca] is not supported

In [3]: quit

E.g.

```
In [1]: import dpnp
mkl-service + Intel(R) MKL: THREADING LAYER: (null)
mkl-service + Intel(R) MKL: setting Intel(R) MKL to use INTEL OpenMP runtime
mkl-service + Intel(R) MKL: preloading libiomp5.so runtime
MKL_VERBOSE Intel(R) MKL 2021.0 Update 1 beta10 build 20201008 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors, Lnx 1.
10GHz lp64 intel_thread
MKL_VERBOSE SDOT(2,0x561c72606c10,1,0x561c72606c10,1) 1.41ms CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:6
Running on: Intel(R) Graphics Gen9 [0x9bca]
DPCtrl SYCL queue used
SYCL kernels link time: 0.190619 (sec.)

In [2]: dpnp.random.gamma(3.4, 0.67)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)

<< stack elided >>

RuntimeError: oneMKL: rng/generate: Intel(R) Graphics Gen9 [0x9bca] is not supported

In [3]: quit
```
@oleksandr-pavlyk oleksandr-pavlyk force-pushed the intercept-one-mkl-exceptions-random branch from 13cf0ed to 4c5bf3b Compare November 16, 2020 16:38
Copy link

@samir-nasibli samir-nasibli left a comment

Choose a reason for hiding this comment

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

Looks good but I think this is not full solution for #201

@oleksandr-pavlyk
Copy link
Contributor Author

oleksandr-pavlyk commented Nov 16, 2020

@samir-nasibli This PR only does it for functions in _random.pyx. Similar changes must be applied throughout dpnp to address #201

@shssf
Copy link
Contributor

shssf commented Nov 16, 2020

If you use this approach and call Cython function from another Cython function - exception will be ignored.
Example: DPNP exception functions https://github.com/IntelPython/dpnp/blame/master/dpnp/dpnp_utils.pyx#L113 We used such approach for them and have delete it.

@oleksandr-pavlyk
Copy link
Contributor Author

@shssf What you describe is a likely root cause for #246

While it is true that calling a cdef side of function cpdef function the exception will be signaled, but Cython delegates checking for the exception to the caller.

So indeed, calling dpnp_beta as c function, one would need to wrap it into try/except to intercept the error.

Having this except + added results in marked improvement to interactive workflow. Crashes cause lost work and should be avoided.

@shssf shssf mentioned this pull request Nov 17, 2020
@oleksandr-pavlyk oleksandr-pavlyk merged commit 9154c79 into master Nov 18, 2020
@oleksandr-pavlyk oleksandr-pavlyk deleted the intercept-one-mkl-exceptions-random branch November 18, 2020 14:10
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.

3 participants