Jupyter Snippet CB2nd 07_openmp

Jupyter Snippet CB2nd 07_openmp

5.7. Releasing the GIL to take advantage of multi-core processors with Cython and OpenMP

%%cython --compile-args=-fopenmp --link-args=-fopenmp --force
from cython.parallel import prange
cdef Vec3 add(Vec3 x, Vec3 y) nogil:
    return vec3(x.x + y.x, x.y + y.y, x.z + y.z)
with nogil:
    for i in prange(w):
        # ...