Giter Club home page Giter Club logo

Comments (4)

aritger avatar aritger commented on July 26, 2024 3

My read of the code is that currentBankInfo is indeed a bitfield. MEM_GROW_DOWN and MEM_GROW_UP are particular fields within it. From src/nvidia/generated/g_heap_nvoc.h:

// grow direction within a bank
#define BANK_MEM_GROW_UP                  0x00
#define BANK_MEM_GROW_DOWN                0x40
#define BANK_MEM_GROW_MASK                0x40

// grow direction if a bank placement fails
#define MEM_GROW_UP                       0x00
#define MEM_GROW_DOWN                     0x80
#define MEM_GROW_MASK                     0x80

Though the code could be clearer, bitwise AND has higher precedence than ternary ?:, so I don't believe the code is wrong.
https://en.cppreference.com/w/c/language/operator_precedence
Tagging as cosmetic.

from open-gpu-kernel-modules.

dcb314 avatar dcb314 commented on July 26, 2024 2

Whichever version is correct, I suggest use ( and ) to make the code more clear.

Better code is more clear code. We haven't got time or inclination to master fine details
of the C standard.

from open-gpu-kernel-modules.

RealAstolfo avatar RealAstolfo commented on July 26, 2024

both of them would reach the same result anyway. i suggest currentBankInfo = currentBankInfo & BANK_MEM_GROW_DOWN ? MEM_GROW_DOWN : MEM_GROW_UP; to clear any confusion

from open-gpu-kernel-modules.

jareklupinski avatar jareklupinski commented on July 26, 2024

looking at the previous section:

if (pVidHeapAlloc->flags & NVOS32_ALLOC_FLAGS_BANK_HINT)
{
    if (pVidHeapAlloc->flags & NVOS32_ALLOC_FLAGS_BANK_GROW_DOWN)
        currentBankInfo = MEM_GROW_DOWN;
    else
        currentBankInfo = MEM_GROW_UP;
    pVidHeapAlloc->flags &= ~(NVOS32_ALLOC_FLAGS_BANK_HINT); // hint flag only lasts for 1 loop
}
else
{
    currentBankInfo = (currentBankInfo & BANK_MEM_GROW_DOWN ? MEM_GROW_DOWN : MEM_GROW_UP);
}

it seems the original intent was to actually set currentBankInfo to MEM_GROW_DOWN or MEM_GROW_UP, not treat it like a bitfield?

from open-gpu-kernel-modules.

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.