8000 ENH: create and use indexed inner loops by mattip · Pull Request #23136 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: create and use indexed inner loops #23136

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 20 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ENH: add indexed loops
  • Loading branch information
mattip committed Jan 30, 2023
commit 90243f53f8efa200e22ee13ef1f0a8e1120b1c3a
12 changes: 12 additions & 0 deletions numpy/core/src/umath/loops.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,18 @@ NPY_NO_EXPORT NPY_GCC_OPT_3 @ATTR@ void
BINARY_LOOP_FAST(@type@, @type@, *out = in1 @OP@ in2);
}
}

NPY_NO_EXPORT NPY_GCC_OPT_3 @ATTR@ void
@TYPE@_@kind@@isa@_indexed(char const *ip1, npy_intp const *indx, char *value,
npy_intp const *dimensions, npy_intp const *steps) {
npy_intp is1 = steps[0], is2 = steps[1], os1 = steps[2];
npy_intp n = dimensions[0];
npy_intp i;
for(i = 0; i < n; i++, indx += is2, value += os1) {
@type@ op1 = *(@type@ *)(ip1 + is1 * indx[0]) + value[0];
}
}

#endif

/**end repeat2**/
Expand Down
12 changes: 12 additions & 0 deletions numpy/core/src/umath/loops_arithm_fp.dispatch.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,18 @@ NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(@TYPE@_@kind@)
}
}
}

NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(@TYPE@_@kind@_indexed)
(char const *ip1, npy_intp const *indx, char *value,
npy_intp const *dimensions, npy_intp const *steps) {
npy_intp is1 = steps[0], is2 = steps[1], os1 = steps[2];
npy_intp n = dimensions[0];
npy_intp i;
for(i = 0; i < n; i++, indx += is2, value += os1) {
@type@ op1 = *(@type@ *)(ip1 + is1 * indx[0]) + value[0];
}
}

/**end repeat1**/
/**end repeat**/

Expand Down
0