8000 ENH: Move dispatch-able umath fast-loops to the new dispatcher by seiko2plus · Pull Request #16396 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Move dispatch-able umath fast-loops to the new dispatcher #16396

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

Closed
wants to merge 5 commits into from
Closed
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
Prev Previous commit
Next Next commit
ENH: [4/5] move dispatch-able umath fast-loops to the new dispatcher
    re-implement the workaround of disabling optimization for
    `*_right_shift`.
  • Loading branch information
seiko2plus committed Jul 11, 2020
commit 7c6495482bf93ef8d3648991f4787d98f8e8e7de
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 @@ -567,6 +567,18 @@ NPY_NO_EXPORT void
UNARY_LOOP_FAST(@type@, @type@, *out = +in);
}

#ifdef NPY_DO_NOT_OPTIMIZE_@TYPE@_right_shift
NPY_NO_EXPORT void
@TYPE@_right_shift_noopt(char **args, npy_intp const *dimensions, npy_intp const *steps)
{
BINARY_LOOP {
const @type@ in1 = *(@type@ *)ip1;
const @type@ in2 = *(@type@ *)ip2;
*((@type@ *)op1) = npy_rshift@c@(in1, in2);
}
}
#endif

/**begin repeat1
* #kind = maximum, minimum#
* #OP = >, <#
Expand Down
5 changes: 5 additions & 0 deletions numpy/core/src/umath/loops.h.src
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void @S@@TYPE@_@dispatch@,
(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)))
/**end repeat2**/

#ifdef NPY_DO_NOT_OPTIMIZE_@TYPE@_right_shift
NPY_NO_EXPORT void
@S@@TYPE@_right_shift_noopt(char **args, npy_intp const *dimensions, npy_intp const *steps);
#endif

/**begin repeat2
* #kind = maximum, minimum#
* #OP = >, <#
Expand Down
9 changes: 9 additions & 0 deletions numpy/core/src/umath/loops_fast.dispatch.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,16 @@ NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(@TYPE@_left_shift)
NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(@TYPE@_right_shift)
(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))
{
/**
* dispatch-able sources through policy '$maxopt' or '$autovec'
* get the maximum safe optimize flags that compiler can offer
* e.g on gcc '-O3', so @TYPE@_right_shift_noopt is defined in loops.c.
*/
#ifndef NPY_DO_NOT_OPTIMIZE_@TYPE@_right_shift
BINARY_LOOP_FAST(@type@, @type@, *out = npy_rshift@c@(in1, in2));
#else
@TYPE@_right_shift_noopt(args, dimensions, steps);
#endif
}

/**begin repeat1
Expand Down
0