Skip to content

Adding CUDA GPU support for Filter function#1988

Open
wostrie2 wants to merge 4 commits into
CEED:mainfrom
wostrie2:adding_GPU_support_for_filter_function
Open

Adding CUDA GPU support for Filter function#1988
wostrie2 wants to merge 4 commits into
CEED:mainfrom
wostrie2:adding_GPU_support_for_filter_function

Conversation

@wostrie2

Copy link
Copy Markdown
Contributor

Purpose: adding CUDA GPU functionality for the Filter function, which filters or clips a vector to a threshold value by setting vector components to 0.0 if their absolute value is less than threshold.

Closes: N/A

LLM/GenAI Disclosure: Google AI spotted a missing parenthesis and saved me a compile error.

Helped by: Jeremy L. Thompson is a human who offered a lot of kind and helpful support while I was working on this.

By submitting this PR, the author certifies to its contents as described by the Developer's Certificate of Origin.
Please follow the Contributing Guidelines for all PRs.

@jrwrigh jrwrigh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks fine to me, but I'll wait for someone who's more familiar with the GPU backends to double check before merging.

Not sure what's going on with Noether CI though.

@jeremylt

Copy link
Copy Markdown
Member

Noether won't run for forks.

I can verify the tests myself tomorrow

@jeremylt

jeremylt commented Jul 15, 2026

Copy link
Copy Markdown
Member

Ok, we need to fix t129, because your code is all correct but the test is not executing on the GPU.

So, here's what has to happen.

I'd insert this code block into your `InitVec

  {
    // Sync memtype to device for GPU backends
    CeedMemType type = CEED_MEM_HOST;

    CeedGetPreferredMemType(CeedVectorReturnCeed(x), &type);
    CeedVectorSyncArray(x, type);
  }

That will pull the memory up to the device, which then will trigger the code you added during the test.

While you're in there, can you update a small style fix? A block (or line) of variable declarations must always be followed by an empty line, per our style guide, so CeedScalar array[len] on line 16 needs a blank line after it.

(We may need to add this fix to other vector tests, need to check)

Lemmie know if you have questions about this explanation!

@wostrie2

Copy link
Copy Markdown
Contributor Author

Ok, we need to fix t129, because your code is all correct but the test is not executing on the GPU.

So, here's what has to happen.

I'd insert this code block into your `InitVec

  {
    // Sync memtype to device for GPU backends
    CeedMemType type = CEED_MEM_HOST;

    CeedGetPreferredMemType(CeedVectorReturnCeed(x), &type);
    CeedVectorSyncArray(x, type);
  }

That will pull the memory up to the device, which then will trigger the code you added during the test.

While you're in there, can you update a small style fix? A block (or line) of variable declarations must always be followed by an empty line, per our style guide, so CeedScalar array[len] on line 16 needs a blank line after it.

(We may need to add this fix to other vector tests, need to check)

Lemmie know if you have questions about this explanation!

Ok, I added that block at the end of the InitVector function, and I added a blank line after the variable declaration on line 16.

Should I delete the equivalent block for memory syncing that appears between test cases 1 and 2?

@jeremylt

Copy link
Copy Markdown
Member

Yeah, go ahead and remove the one outside of the init function since it isn't helping us anymore

@wostrie2

Copy link
Copy Markdown
Contributor Author

ok, just pushed those changes to t129-vector.c

@jeremylt jeremylt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome, this is working for me locally and running on the GPU! Nice work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants