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

[core/simd]: Write package documentation #4545

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

flysand7
Copy link
Contributor

@flysand7 flysand7 commented Dec 1, 2024

No description provided.

core/simd/simd.odin Outdated Show resolved Hide resolved
core/simd/simd.odin Outdated Show resolved Hide resolved
Check if SIMD is emulated on a target platform.

This value is `true`, if the compile-time target has the hardware support for
at 128-bit (or wider) SIMD. If the compile-time target lacks the hardware support
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
at 128-bit (or wider) SIMD. If the compile-time target lacks the hardware support
at least 128-bit (or wider) SIMD. If the compile-time target lacks the hardware support

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"at least" implies "or wider" so at least one of these has to go

Copy link
Collaborator

Choose a reason for hiding this comment

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

You now have has the hardware support for at 128-bit (or wider) where for at doesn't make any sense, so I tried to fix it with that suggestion.

core/simd/simd.odin Outdated Show resolved Hide resolved
core/simd/simd.odin Outdated Show resolved Hide resolved
between all of the lanes in a vector.

Inputs:
- `a`: Vector to reduce
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- `a`: Vector to reduce
- `a`: The vector to reduce.

reduce_and :: intrinsics.simd_reduce_and

/*
Reduce SIMD vector to a scalar by performing bitwise OR of all of the lanes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Reduce SIMD vector to a scalar by performing bitwise OR of all of the lanes.
Reduce a vector to a scalar by performing bitwise OR of all of the lanes.

/*
Reduce SIMD vector to a scalar by performing bitwise OR of all of the lanes.

This procedure returns a scalar, that is the result of the bitwise OR operation
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This procedure returns a scalar, that is the result of the bitwise OR operation
This procedure returns a scalar that is the result of the bitwise OR operation

between all of the lanes in a vector.

Inputs:
- `a`: Vector to reduce
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- `a`: Vector to reduce
- `a`: The vector to reduce.

- `a`: Vector to reduce

Result:
- Bitwise AND of all lanes, as a scalar.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Bitwise AND of all lanes, as a scalar.
- Bitwise OR of all lanes, as a scalar.

Check if SIMD is emulated on a target platform.

This value is `true`, if the compile-time target has the hardware support for
at 128-bit (or wider) SIMD. If the compile-time target lacks the hardware support
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"at least" implies "or wider" so at least one of these has to go

core/simd/simd.odin Show resolved Hide resolved
core/simd/simd.odin Show resolved Hide resolved
core/simd/simd.odin Show resolved Hide resolved
}
return res

Example:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! I should fix this then. I haven't read your comments below, but it should be okay to surround the code block with text that describes what the example achieves, right? Otherwise I feel like the purpose of example is defeated, unless it's explained at least a little bit.

+-------+-------+-------+-------+
res:
+-------+-------+-------+--------+
| 0x44 | 0xaa | 0x06 | 0xfe |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay this one I have to refuse, I was assuming 1-byte lanes, which I should probably make explicit in the comments.

/*
Saturated addition of SIMD vectors.

The *saturated sum* is a sum, that upon overflow or underflow, instead of
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I should rewrite this.

core/simd/simd.odin Outdated Show resolved Hide resolved
res := simd.gather(ptrs, defaults, mask)
fmt.println(res)

The code would print `<2, 127, 10, 127>`. First and the third positions came
Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are indented with a tab. Thanks for Output: tip!

core/simd/simd.odin Outdated Show resolved Hide resolved
+------+------+------+------+
| 0 | 1 | 0.33 | 0.2 |
+------+------+------+------+
*/
Copy link
Member

Choose a reason for hiding this comment

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

1/0 may not result in 0. That's a poor example.

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