File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
sklearn/metrics/_pairwise_distances_reduction Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -341,9 +341,16 @@ memory alignment, direct blas calls...
341341Using OpenMP
342342------------
343343
344- Since scikit-learn can be built without OpenMP, it's necessary to
345- protect each direct call to OpenMP. This can be done using the following
346- syntax::
344+ Since scikit-learn can be built without OpenMP, it's necessary to protect each
345+ direct call to OpenMP.
346+
347+ There are some helpers in
348+ [sklearn/utils/_openmp_helpers.pyx](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/utils/_openmp_helpers.pyx)
349+ that you can reuse for the main useful functionalities and already have the
350+ necessary protection to be built without OpenMP.
351+
352+ If the helpers are not enough, you need to protect your OpenMP code using the
353+ following syntax::
347354
348355 # importing OpenMP
349356 IF SKLEARN_OPENMP_PARALLELISM_ENABLED:
Original file line number Diff line number Diff line change 11cimport numpy as cnp
2- cimport openmp
32
43from cython cimport final
54from cython.operator cimport dereference as deref
@@ -73,7 +72,8 @@ cpdef DTYPE_t[::1] _sqeuclidean_row_norms32(
7372 )
7473
7574 with nogil, parallel(num_threads=num_threads):
76- thread_num = openmp.omp_get_thread_num()
75+ thread_num = _openmp_thread_num()
76+
7777 for i in prange(n, schedule='static'):
7878 # Upcasting the i-th row of X from float32 to float64
7979 for j in range(d):
You can’t perform that action at this time.
0 commit comments