Skip to content

Conversation

@joaosaffran
Copy link
Collaborator

This patch modifies the Wave Match test to test modifications in different lanes and vector
indexes. This is achieved by forcing lanes 0, WAVE_SIZE/2 and WAVE_SIZE -1, to modify
the vector at indexes 0, WAVE_SIZE/2 or WAVE_SIZE -1, respectively.

uint64_t LowBits;
uint64_t HighBits;

Wave(CONST UINT NumWaves, uint64_t LB, uint64_t HB) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Wave(CONST UINT NumWaves, uint64_t LB, uint64_t HB) {
Wave(UINT NumWaves, uint64_t LB, uint64_t HB) {

uint64_t LowBits;
uint64_t HighBits;

Wave(CONST UINT NumWaves, uint64_t LB, uint64_t HB) {
Copy link
Member

Choose a reason for hiding this comment

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

I think you only ever pass LB = HB = ~0 or LB = HB = 0 to this. There may be a way to simplify to have a single value passed in?

template <typename T> struct Op<OpType::WaveMatch, T, 1> : StrictValidation {};

// Helper struct to build the expected result for WaveMatch tests.
struct Wave {
Copy link
Member

Choose a reason for hiding this comment

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

This probably needs a longer name. WaveMatchResultBuilder?

Comment on lines 1598 to 1602
uint64_t LowWaveMask;
uint64_t HighWaveMask;

uint64_t LowBits;
uint64_t HighBits;
Copy link
Member

Choose a reason for hiding this comment

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

We should aim to make these private.

What if there was function that looked like this?

void SetExpected(std::vector<UINT>::iterator It)

That would write the values into the 4 elements of the vector?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure taking an iterator is a great suggestion. Maybe void SetExpected(UINT* Dest) might be a better starting point.

@joaosaffran joaosaffran requested a review from damyanp December 9, 2025 19:57
Copy link
Contributor

@alsepkow alsepkow left a comment

Choose a reason for hiding this comment

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

Made some comments. It looks like we need a few fixes on this iteration still.


public:
WaveMatchResultBuilder(UINT NumWaves) : LowBits(0), HighBits(0) {
const UINT LowWaves = std::min(64U, NumWaves);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Take it or leave it. But I would consider defensively adding a 'VERIFY_IS_TRUE(NumWaves <= 128)' just to help identify this path as needing an update if/when we ever increase the max size.

That or you could also do a std::max for the HighWaves logic.
Damyan also mentioned its highly unlikely this number changes. So, it's probably overkill.

const UINT HighWaves = NumWaves - LowWaves;
LowWaveMask = (LowWaves < 64) ? (1ULL << LowWaves) - 1 : ~0ULL;
HighWaveMask = (HighWaves < 64) ? (1ULL << HighWaves) - 1 : ~0ULL;
LowBits &= LowWaveMask;
Copy link
Contributor

Choose a reason for hiding this comment

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

The assignment to LowBits and HighBits seems redundant? They're initialized to zero so the result of these operations will still always just be 0?

private:
uint64_t LowWaveMask;
uint64_t HighWaveMask;
uint64_t LowBits;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think LowBits/HighBits are actually intended to represent the currently active lanes for a given group?
Suggest updating the names to something like 'ActiveLanesLow' and 'ActiveLanesHigh' to better reflect that.

D3D12_FEATURE_D3D12_OPTIONS1, &WaveOpts, sizeof(WaveOpts)));

WaveSize = WaveOpts.WaveLaneCountMin;
WaveSize = 128; // WaveOpts.WaveLaneCountMin;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you intended to leave this commented out

WaveMatchResultBuilder(UINT NumWaves) : LowBits(0), HighBits(0) {
const UINT LowWaves = std::min(64U, NumWaves);
const UINT HighWaves = NumWaves - LowWaves;
LowWaveMask = (LowWaves < 64) ? (1ULL << LowWaves) - 1 : ~0ULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could help improve readability of this code (not that its bad) by using inline helpers or static constexp helpers for some of the bit math instead.

LowWaveMask = lowNBitsSet(LowWaves);

'~0ULL' is probably fine. It's simple and common.

private:
uint64_t LowWaveMask;
uint64_t HighWaveMask;
uint64_t LowBits;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason you opted for two uint64 values instead of 4 uints or one 128-bit uint?


const UINT LowWaves = std::min(64U, WaveSize);
const UINT HighWaves = WaveSize - LowWaves;
const UINT MidBit = WaveSize / 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming on this should be 'MidLaneID' and 'LastLaneID' respectively.

const uint64_t LowExpected = ~1ULL & LowWaveMask;
const uint64_t HighExpected = ~0ULL & HighWaveMask;
if (I == 0 || MidBit == I || LastBit == I) {
WaveMatchResultBuilder ChangedLanes(WaveSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

What were you intending to do with ChangedLanes? It's declared as a local in this for loop and not used outside of it.

@github-project-automation github-project-automation bot moved this from New to In progress in HLSL Roadmap Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

4 participants