-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH, TST: Bring the NumPy C SIMD vectorization interface "NPYV" to Python #16782
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cb3efe8
ENH: Expose the NumPy C SIMD vectorization interface "NPYV" to Python
seiko2plus c65a559
ENH, TST: Add testing unit that covers the current implemented intrin…
seiko2plus 1779c2a
TST: Add testing unit for checking the sainty of SIMD module
seiko2plus 92a4693
TST: Add testing unit for fused NPYV intrinsics
seiko2plus e19f7a8
MAINT, TST: use PyArg_ParseTuple() instead of iterate Python tuple di…
seiko2plus 7d125fb
MAINT, TST: Serveral imporvments to _SIMD module
seiko2plus 018e0ca
MAINT: Syntax highlighting for *.inc.src on github
seiko2plus d54a45b
BUG, BLD: fix multi-target name in `CCompilerOpt`'s report
seiko2plus 8cc5009
MAINT, TST: Add _SIMD attribute for each enabled SIMD extension
seiko2plus 5d8c3be
MAINT, TST: Add testing cases for partial/non-contig load and store
seiko2plus ac4ffe1
MAINT, TST: update name of _SIMD submodule to match import path
seiko2plus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 characters
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 characters
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "_simd.h" | ||
|
||
PyMODINIT_FUNC PyInit__simd(void) | ||
{ | ||
static struct PyModuleDef defs = { | ||
.m_base = PyModuleDef_HEAD_INIT, | ||
.m_name = "numpy.core._simd", | ||
.m_size = -1 | ||
}; | ||
if (npy_cpu_init() < 0) { | ||
return NULL; | ||
} | ||
PyObject *m = PyModule_Create(&defs); | ||
if (m == NULL) { | ||
return NULL; | ||
} | ||
PyObject *targets = PyDict_New(); | ||
if (targets == NULL) { | ||
goto err; | ||
} | ||
if (PyModule_AddObject(m, "targets", targets) < 0) { | ||
Py_DECREF(targets); | ||
goto err; | ||
} | ||
// add keys for non-supported optimizations with None value | ||
#define ATTACH_MODULE(TESTED_FEATURES, TARGET_NAME, MAKE_MSVC_HAPPY) \ | ||
{ \ | ||
PyObject *simd_mod; \ | ||
if (!TESTED_FEATURES) { \ | ||
Py_INCREF(Py_None); \ | ||
simd_mod = Py_None; \ | ||
} else { \ | ||
simd_mod = NPY_CAT(simd_create_module_, TARGET_NAME)(); \ | ||
if (simd_mod == NULL) { \ | ||
goto err; \ | ||
} \ | ||
} \ | ||
const char *target_name = NPY_TOSTRING(TARGET_NAME); \ | ||
if (PyDict_SetItemString(targets, target_name, simd_mod) < 0) { \ | ||
mattip marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Py_DECREF(simd_mod); \ | ||
goto err; \ | ||
} 8A66 \ | ||
Py_INCREF(simd_mod); \ | ||
if (PyModule_AddObject(m, target_name, simd_mod) < 0) { \ | ||
Py_DECREF(simd_mod); \ | ||
goto err; \ | ||
} \ | ||
} | ||
|
||
#define ATTACH_BASELINE_MODULE(MAKE_MSVC_HAPPY) \ | ||
{ \ | ||
PyObject *simd_mod = simd_create_module(); \ | ||
if (simd_mod == NULL) { \ | ||
goto err; \ | ||
} \ | ||
if (PyDict_SetItemString(targets, "baseline", simd_mod) < 0) { \ | ||
Py_DECREF(simd_mod); \ | ||
goto err; \ | ||
} \ | ||
Py_INCREF(simd_mod); \ | ||
if (PyModule_AddObject(m, "baseline", simd_mod) < 0) { \ | ||
Py_DECREF(simd_mod); \ | ||
goto err; \ | ||
} \ | ||
} | ||
|
||
NPY__CPU_DISPATCH_CALL(NPY_CPU_HAVE, ATTACH_MODULE, MAKE_MSVC_HAPPY) | ||
NPY__CPU_DISPATCH_BASELINE_CALL(ATTACH_BASELINE_MODULE, MAKE_MSVC_HAPPY) | ||
return m; | ||
err: | ||
Py_DECREF(m); | ||
return NULL; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.