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

LLVM_Util: add support for masked operations #1248

Merged
merged 1 commit into from
Sep 10, 2020

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Sep 3, 2020

Work by Alex Wells.

This will be used extensively by the SIMD batched shading.

  • Added support for masked operations by managing a stack of masks
    that were created by conditionals or control flow. Detailed
    explanation of the Masking Strategy in llvm_util.h.

  • Added support for logically masked functions (handling of masked
    return from inside OSL functions)

  • Added support for masked loops (handling of masked break and or
    masked continue).

  • Added support for masked exit (handling of masked exit from entire
    shader).

  • Added support for management of when masking is required with a
    ScopedMasking object to allow nesting during code gen.

  • op_store (and other store variations) respect the current masking
    requirement and current top of the mask stack (not just the top
    entry, but a combined view of the entire mask stack).

  • Added support for results of conditional operations to remain
    boolean. Most masking operations are expecting vector of bool
    values, not a vector of integers., e.g. when vector width is 16, for
    scalar or <16 x i1> for wide. When a conditional result is used by
    another operation a numerical value it is automatically converted to
    an integer.

  • Added llvm::Type *type_native_mask() const; because different
    ISA's may have different representations of a mask from llvm's
    vector of bits that comparison operations emit. And we need varying
    boolean symbols to have the correct data type (size) on the stack
    and in data structures.

  • Added gather and scatter operations.

  • Added helpers to convert from bool<->int, native_mask<->llvm_mask

Signed-off-by: Larry Gritz [email protected]

Copy link
Contributor

@AlexMWells AlexMWells left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@fpsunflower fpsunflower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few minor notes below

src/include/OSL/llvm_util.h Outdated Show resolved Hide resolved
src/include/OSL/llvm_util.h Outdated Show resolved Hide resolved
src/include/OSL/llvm_util.h Outdated Show resolved Hide resolved
@lgritz
Copy link
Collaborator Author

lgritz commented Sep 9, 2020

Quite right on the typos and other comments, @fpsunflower . Pushed an update and will merge after all the CI tests pass.

Work by Alex Wells.

This will be used extensively by the SIMD batched shading.

* Added support for masked operations by managing a stack of masks
  that were created by conditionals or control flow. Detailed
  explanation of the Masking Strategy in llvm_util.h.

* Added support for logically masked functions (handling of masked
  return from inside OSL functions)

* Added support for masked loops (handling of masked break and or
  masked continue).

* Added support for masked exit (handling of masked exit from entire
  shader).

* Added support for management of when masking is required with a
  ScopedMasking object to allow nesting during code gen.

* op_store (and other store variations) respect the current masking
  requirement and current top of the mask stack (not just the top
  entry, but a combined view of the entire mask stack).

* Added support for results of conditional operations to remain
  boolean.  Most masking operations are expecting vector of bool
  values, not a vector of integers., e.g. when vector width is 16, for
  scalar or <16 x i1> for wide. When a conditional result is used by
  another operation a numerical value it is automatically converted to
  an integer.

* Added `llvm::Type *type_native_mask() const;` because different
  ISA's may have different representations of a mask from llvm's
  vector of bits that comparison operations emit.  And we need varying
  boolean symbols to have the correct data type (size) on the stack
  and in data structures.

* Added gather and scatter operations.

* Added helpers to convert from bool<->int, native_mask<->llvm_mask

Signed-off-by: Larry Gritz <[email protected]>
@lgritz lgritz merged commit 9a85e6f into AcademySoftwareFoundation:master Sep 10, 2020
@lgritz lgritz deleted the alex-masking branch September 10, 2020 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants