ctx - expand CeedContextFieldType to support additional field types - #2008
ctx - expand CeedContextFieldType to support additional field types#2008ksd-2005 wants to merge 2 commits into
Conversation
…ieldType Added a Ceed prefix to accessors for the libCEED-typedef'd types.
Updated Clang.jl compat to 0.19 and regenerated bindings Clang.jl 0.16 depends on the deprecated Clang_jll, which no longer resolves in the current registry. Regenerate for CeedContextFieldType expansion.
|
Please also let me know, if I have to change any coding style( I followed the exact way in which other functions are written in the codebase, but i want to know if I can change anything else), or can improve by making the code concise anywhere, I would like to learn on ways to improve the code. |
|
Thanks for the PR. It's evening for me here in the EU so I'll look in the morning and let you know! |
|
A note on the ordering: I think I would prefer the order for the switch, it's a bit more intuitive to be. I also think that the enum needs a zero value -- we often use |
|
Also, thank you for the very clear explanation of AI use! |
zatkins-dev
left a comment
There was a problem hiding this comment.
This is a great start, a couple high-level things on a first look.
| CEED_EXTERN int CeedQFunctionContextSetCeedFloat(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, float *values); | ||
| CEED_EXTERN int CeedQFunctionContextGetCeedFloatRead(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, size_t *num_values, | ||
| const float **values); | ||
| CEED_EXTERN int CeedQFunctionContextRestoreCeedFloatRead(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, const float **values); |
There was a problem hiding this comment.
Just to note, only the Ceed types should have the Ceed prefix on the type name for these functions.
For example, CeedScalar should be as you have it, but float should be
| CEED_EXTERN int CeedQFunctionContextRestoreCeedFloatRead(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, const float **values); | |
| CEED_EXTERN int CeedQFunctionContextRestoreFloatRead(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, const float **values); |
There was a problem hiding this comment.
Thats going to be a pretty big diff, so I'll let you handle it locally instead of me suggesting all of them.
There was a problem hiding this comment.
Yea, to clarify, I meant only the four types with Ceed in their name should have that added to the signature, so CeedInt, CeedScalar, CeedSize, and CeedInt8
|
I'm not sure that the Julia changes need to all be here -- some of that should probably be a separate PR. |
| CEED_EXTERN int CeedQFunctionContextRestoreData(CeedQFunctionContext ctx, void *data); | ||
| CEED_EXTERN int CeedQFunctionContextRestoreDataRead(CeedQFunctionContext ctx, void *data); | ||
| CEED_EXTERN int CeedQFunctionContextRegisterDouble(CeedQFunctionContext ctx, const char *field_name, size_t field_offset, size_t num_values, | ||
| CEED_EXTERN int CeedQFunctionContextRegisterCeedByte(CeedQFunctionContext ctx, const char *field_name, size_t field_offset, size_t num_values, |
There was a problem hiding this comment.
Note, these (and the other fn definitions and declarations) should use the ordering of the enum provided
| /// @ingroup CeedQFunction | ||
| typedef enum { | ||
| /// Byte value, C type of char | ||
| CEED_CONTEXT_FIELD_BYTE = 1, |
There was a problem hiding this comment.
As Zach said, I'd use the order I provided, starting at 0
| ccall((:CeedQFunctionSetData, libceed), Cint, (CeedQFunction, Ptr{Cvoid}), qf, data) | ||
| end | ||
|
|
||
| function CeedQFunctionIsImmutable(qf, is_immutable) |
There was a problem hiding this comment.
there's a bunch of other stuff added here - I'd only add the Julia changes that correspond to C API changes in this PR
| ccall((:CeedHouseholderApplyQ, libceed), Cint, (Ptr{CeedScalar}, Ptr{CeedScalar}, Ptr{CeedScalar}, CeedTransposeMode, CeedInt, CeedInt, CeedInt, CeedInt, CeedInt), mat_A, mat_Q, tau, t_mode, m, n, k, row, col) | ||
| end | ||
|
|
||
| function CeedMatrixPseudoinverse(ceed, mat, m, n, mat_pinv) |
There was a problem hiding this comment.
This definitely should not be exposed here
| function CeedOperatorLinearAssembleQFunctionBuildOrUpdateFallback(op, build_objects, assembled, rstr, request) | ||
| ccall((:CeedOperatorLinearAssembleQFunctionBuildOrUpdateFallback, libceed), Cint, (CeedOperator, Bool, Ptr{CeedVector}, Ptr{CeedElemRestriction}, Ptr{CeedRequest}), op, build_objects, assembled, rstr, request) | ||
| end | ||
|
|
||
| function CeedOperatorAssembleSingle(op, offset, values) |
| function CeedOperatorHasTensorBases(op, has_tensor_bases) | ||
| ccall((:CeedOperatorHasTensorBases, libceed), Cint, (CeedOperator, Ptr{Bool}), op, has_tensor_bases) | ||
| end | ||
|
|
||
| function CeedOperatorIsImmutable(op, is_immutable) | ||
| ccall((:CeedOperatorIsImmutable, libceed), Cint, (CeedOperator, Ptr{Bool}), op, is_immutable) |
There was a problem hiding this comment.
And these are internal utilities that don't belong... really just only add the fn's from this PR and non other to be safe
| @ref Backend | ||
| **/ | ||
| int CeedQFunctionContextRestoreCeedByteRead(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, const char **values) { | ||
| CeedCheck(field_label, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPORTED, "Invalid field label"); |
There was a problem hiding this comment.
These changes emphasize that probably this check should move from being duplicated in all of these functions to being in CeedQFunctionContextRestoreGenericRead
| @ref Backend | ||
| **/ | ||
| int CeedQFunctionContextSetCeedByte(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, char * values) { | ||
| CeedCheck(field_label, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPORTED, "Invalid field label"); |
There was a problem hiding this comment.
same comment here, all these replicated checks probably should go to CeedQFunctionContextSetGeneric
Purpose:
Adds seven new
CeedContextFieldTypevalues -BYTE,INT8,INT,INT64,SIZE,SCALAR,and
FLOAT- alongside the existingDOUBLE,INT32, andBOOL, with matchingCeedQFunctionContextRegisterCeed*/Set*/Get*Read/Restore*Readfunctions on bothCeedQFunctionContextandCeedOperator.As we agreed in the issue discussion, this renumbers the existing
CeedContextFieldTypeenum(an intentional ABI break, approved ahead of the 1.0 release) and gives every accessor function
a
Ceed-prefixed name for the libCEED-typedef'd types, as per @jeremylt 's and @zatkins-dev 's suggestion.CEED_CONTEXT_FIELD_SCALAR,FLOAT, andDOUBLEare kept as distinct field types.One thing I want to mention is:
The discussion we had earlier didn't say an exact enum ordering for the final 10-type set - the only ordering anyone said was the case order of
the
switch@jeremylt posted (BOOL, BYTE, INT8, INT, INT32, INT64, SIZE, SCALAR, FLOAT, DOUBLE).I've used
I am happy to change the ordering if anything else was intended.
This PR is currently a draft. The below tasks remain, before it's ready for full review:
tests/t407-qfunction.cto cover all ten field types (currently covers three)make prove-allclean run includingexamples/fluidsThese will be completed by tomorrow afternoon
Closes: #2004
LLM/GenAI Disclosure:
I used Claude to help me understand the existing
CeedQFunctionContextin
interface/ceed-qfunctioncontext.candinterface/ceed-operator.cbeforewriting this change, and to review my diff against the design decisions from the issue thread -
it pointed out a few bugs (a
CeedSize/size_tsignature mismatch that failed to compile, astale
CeedContextFieldTypes[]string table) which I then fixed myself.ALL CODE SOURCE CHANGES IN THIS PR ARE WRITTEN BY ME.
By submitting this PR, the author certifies to its contents as described by the Developer's Certificate of Origin.