Giter Club home page Giter Club logo

Comments (12)

jkwak-work avatar jkwak-work commented on July 2, 2024

I couldn't figure this one out why it is causing a problem.

I will need to figure out how to debug Falcor unit tests locally.
When I attempted, falcore.sln failed to open with my VisualStudio 2022.

Since this is a low priority clean up task, I am filing an issue and moving on to a higher priority task for now.

from slang.

csyonghe avatar csyonghe commented on July 2, 2024

I noticed that the falcor code is calling min from a static const:

struct LeapedHaltonSampleGenerator : ISampleGenerator
{
    struct Padded
    {
        LeapedHaltonSampleGenerator internal;
        uint2 _pad;
    };

    static const uint kDimensionCount = LeapedHaltonSequence::kDimensionCount;
    static const uint kInstanceCount = min(4096, LeapedHaltonSequence::kInstanceCount); //
...

Is there a way we can reproduce this with a similar test case?

from slang.

jkwak-work avatar jkwak-work commented on July 2, 2024

I noticed that the falcor code is calling min from a static const:

struct LeapedHaltonSampleGenerator : ISampleGenerator
{
    struct Padded
    {
        LeapedHaltonSampleGenerator internal;
        uint2 _pad;
    };

    static const uint kDimensionCount = LeapedHaltonSequence::kDimensionCount;
    static const uint kInstanceCount = min(4096, LeapedHaltonSequence::kInstanceCount); //
...

Is there a way we can reproduce this with a similar test case?

Interesting... I will test it with slang-test.

from slang.

jkwak-work avatar jkwak-work commented on July 2, 2024

I am not sure if I did it correctly.
But when I tried, the result was folded and there was no SMin/UMin instruction emitted.
I had a code like this,

enum TEST : int
{
   kConst = 1997
};

static int JKWAK = min(1996, int(TEST::kConst));

The emitted SPIR-V was like this,

%int_1996 = OpConstant %int 1996
OpStore %JKWAK %int_1996

from slang.

csyonghe avatar csyonghe commented on July 2, 2024

What is kConst is uint? Have you tried -O0? But the high level bit here is that things are compiling just fine.

from slang.

jkwak-work avatar jkwak-work commented on July 2, 2024

When I tried uint, I found a bug that it is treated as int.
But I don't think this is related to problem I was having, because it still doesn't emit UMin/SMin.

enum TEST : uint
{
   kConst = (1 << 31)
};

static uint JKWAK = min(4096, uint(TEST::kConst));

The code above yields the following,

%uint_2147483648 = OpConstant %uint 2147483648
OpStore %JKWAK %uint_2147483648

When I tried "(1 << 30)", it worked correctly but not for "(1 << 31).

The option -O0 hasn't shown any differences but I will keep playing with it.

from slang.

jkwak-work avatar jkwak-work commented on July 2, 2024

I will create a new issue for the problem with min.

from slang.

csyonghe avatar csyonghe commented on July 2, 2024

This is not a problem with min, but with overload resolution.

We should make conversion of an int literal to some other int type within range bearing a smaller cost so we can pick up min(uint,uint) when calling min(4096, uint(x)).

from slang.

jkwak-work avatar jkwak-work commented on July 2, 2024

I was able to build FalcorTest.exe locally.
On my previous attempt, the testing was done with an old binary that I built a few month ago.

With the latest binaries, I can reproduce the issue only with Release build not Debug build.

from slang.

csyonghe avatar csyonghe commented on July 2, 2024

The problem here is if the user writes:

static const uint val = min(4096, uint(0xFFFFFFFF));

What should we resolve?
If we resolve to min(int,int), then val will be 0xFFFFFFFF.
If we resolve to min(uint,uint), then val will be 4096.

from slang.

csyonghe avatar csyonghe commented on July 2, 2024

In this particular case, we shouldn't be resolving into min(int,int) because we know that 0xFFFFFFFF is out of range of int, but 4096 is within the range of uint, so we should prefer converting 4096 to uint and call min(uint, uint).

from slang.

jkwak-work avatar jkwak-work commented on July 2, 2024

This issue is blocked by another issue, #4104

from slang.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.