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

Bug on supporting bit_cast<uint64_t>(double) #5470

Open
kaizhangNV opened this issue Oct 31, 2024 · 5 comments
Open

Bug on supporting bit_cast<uint64_t>(double) #5470

kaizhangNV opened this issue Oct 31, 2024 · 5 comments
Assignees
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang kind:bug something doesn't work like it should

Comments

@kaizhangNV
Copy link
Contributor

Following code will cause internal error:

RWStructuredBuffer<uint64_t> out;

uint64_t cast(double x)
{
    return bit_cast<uint64_t>(x);
}

[shader("compute")]
[numthreads(1,1,1)]
void computeMain()
{
    double x = 1.0;

    out[0] = cast(x);
}

note, there is no problem just doing

  out[0] = bit_cast<uint64_t>(1.0lf);
@kaizhangNV
Copy link
Contributor Author

The error message is:

test1.slang(6): internal error 99999: unimplemented feature in Slang compiler: unexpected IR opcode during code emit
    return bit_cast<uint64_t>(x);

@kaizhangNV
Copy link
Contributor Author

I tried other targets
It has no problem on cpp, cuda, spirv.

@kaizhangNV
Copy link
Contributor Author

on all the shader language targets, we don't handle double base type during processing kIROp_BitCast.

@kaizhangNV
Copy link
Contributor Author

There is a TODO in hlsl target
// TODO: There is an asdouble function
// for converting two 32-bit integer values into
// one double. We could use that for
// bit casts of 64-bit values with a bit of
// extra work, but doing so might be best
// handled in an IR pass that legalizes
// bit-casts.
//

@bmillsNV bmillsNV added this to the Q4 2024 (Fall) milestone Oct 31, 2024
@bmillsNV bmillsNV added the goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang label Oct 31, 2024
@csyonghe
Copy link
Collaborator

csyonghe commented Nov 4, 2024

We should work on top of #5020 for this issue.

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 kind:bug something doesn't work like it should
Projects
None yet
Development

No branches or pull requests

3 participants