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

GPU Aggregation (2/8): GPUAggregator #8887

Open
wants to merge 3 commits into
base: x/aggregation-1
Choose a base branch
from

Conversation

Pessimistress
Copy link
Collaborator

@Pessimistress Pessimistress commented May 12, 2024

For #7457

Change List

  • Add GPUAggregator
  • Tests

defines: {
NUM_DIMS: settings.dimensions,
NUM_CHANNELS: settings.numChannels,
SAMEPLER_WIDTH: TEXTURE_WIDTH
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
SAMEPLER_WIDTH: TEXTURE_WIDTH
SAMPLER_WIDTH: TEXTURE_WIDTH

}

dimensions: 1 | 2;
numChannels: 1 | 2 | 3;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we make the Aggregator class generic on the number of channels? That way we could catch out of bounds access at compile time, e.g.

type 3Channel = 0 | 1 | 2;
new GPUAggregator<3Channel>(...)
getResult(channel: Channels)

#endif

gl_Position = vec4(0., 0., 0., 1.);
gl_PointSize = 2.0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this 2, rather than 1 like in the bin-sorter?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see the comment in the fragment shader now. Might be worth a small comment here also

uniforms: {
// Passed in as uniform because 1) there is no GLSL symbol for NaN 2) any expression that exploits undefined behavior to produces NaN
// will subject to platform differences and shader optimization
naN: NaN
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks risky, have we used this technique before?

const MAX_FLOAT32 = 3e38;
const EMPTY_MASKS = {SUM: 0, MEAN: 0, MIN: 0, MAX: 0};

export const TEXTURE_WIDTH = 1024;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be worth exposing as a prop?

}

function createModel(device: Device, settings: GPUAggregatorSettings): Model {
let userVs = settings.vs;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we provide a default, that just returns a constant, to avoid a shader compilation error?

{name: 'income', format: 'float32', stepMode: 'vertex'},
{name: 'education', format: 'float32', stepMode: 'vertex'}
],
vs: `
Copy link
Collaborator

Choose a reason for hiding this comment

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

Really like how we can just supply aggregation snippets! 😊

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.

None yet

2 participants