Last active
February 1, 2023 05:58
-
-
Save nico-zck/3b6b7aede686d7b3ec403e6e50beda0c to your computer and use it in GitHub Desktop.
Revisions
-
nico-zck renamed this gist
Jan 8, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
nico-zck revised this gist
Jan 8, 2022 . 2 changed files with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,3 @@ import cython cimport cython This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ build: `python3 setup.py build_ext -if` using: -
nico-zck renamed this gist
Jan 8, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
nico-zck renamed this gist
Jan 8, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
nico-zck revised this gist
Jan 8, 2022 . No changes.There are no files selected for viewing
-
nico-zck revised this gist
Jan 8, 2022 . 2 changed files with 14 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ build: `python3 setup.py build_ext -if` using: ``` from parallelsort import parallelsort import numpy as np arr = np.random.uniform(0,100,100000000) %timeit np.sort(arr) %timeit parallelsort(arr) ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ -
nico-zck created this gist
Jan 8, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ python3 setup.py build_ext -if This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ import numpy as np cimport numpy as np import cython cimport cython ctypedef fused real: cython.short cython.ushort cython.int cython.uint cython.long cython.ulong cython.longlong cython.ulonglong cython.float cython.double cdef extern from "<parallel/algorithm>" namespace "__gnu_parallel": cdef void sort[T](T first, T last) nogil @cython.boundscheck(False) # turn off bounds-checking for entire function @cython.wraparound(False) # turn off negative index wrapping for entire function def parallelsort(real[:] a): """ In-place parallel sort for numpy types """ sort(&a[0], &a[a.shape[0]]) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ from setuptools import Extension, setup from Cython.Build import cythonize ext_modules = [ Extension( "parallelsort", ["parallelsort.pyx"], language="c++", extra_compile_args=['-fopenmp'], extra_link_args=['-fopenmp'], ) ] setup( name='parallelsort', ext_modules=cythonize(ext_modules, compiler_directives={'language_level': "3"}), )