Skip to content
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

powr() implemented inefficiently for non-metal targets #5587

Open
cheneym2 opened this issue Nov 18, 2024 · 1 comment
Open

powr() implemented inefficiently for non-metal targets #5587

cheneym2 opened this issue Nov 18, 2024 · 1 comment
Assignees
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang GoodFirstBug Great bug for people getting going in slang codebase kind:performance things we wish were faster

Comments

@cheneym2
Copy link
Collaborator

It seems like powr() is implemented inefficiently on non-metal targets. If I understand correctly, powr() is only defined for x>=0 but for some reason we coerce x to be abs(x) before delegating to regular pow() for other targets, instead of letting it be undefined.

/// @category math
__generic<T : __BuiltinFloatingPointType>
[__readNone]
[require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, sm_4_0_version)]
T powr(T x, T y)
{
    __target_switch
    {
    case metal: __intrinsic_asm "powr";
    default:
        return pow(abs(x), y);
    }
}
@cheneym2 cheneym2 added kind:performance things we wish were faster GoodFirstBug Great bug for people getting going in slang codebase labels Nov 18, 2024
@cheneym2 cheneym2 added this to the Q4 2024 (Fall) milestone Nov 18, 2024
@jkwak-work
Copy link
Collaborator

I think we should simply remove the function powr.
When I added it, I misunderstood what needed to be done and I added bunch of Metal only functions in hlsl.meta.slang.
I wasn't meant to add new intrinsics only because Metal has those.

@bmillsNV bmillsNV added the goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang GoodFirstBug Great bug for people getting going in slang codebase kind:performance things we wish were faster
Projects
None yet
Development

No branches or pull requests

3 participants