Skip to content

Batch processing of Chemtab Source Computation#506

Merged
klbudzin merged 9 commits intoUBCHREST:mainfrom
ubdsgroup:batch_processing
Jan 28, 2025
Merged

Batch processing of Chemtab Source Computation#506
klbudzin merged 9 commits intoUBCHREST:mainfrom
ubdsgroup:batch_processing

Conversation

@profPlum
Copy link
Contributor

@profPlum profPlum commented Dec 7, 2023

I've manually verified it produces the same results as before and it appears to now be twice as fast.

Copy link
Contributor

@mmcgurn mmcgurn left a comment

Choose a reason for hiding this comment

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

I have some questions about the batch processing.

std::size_t ndata = ninputs * sizeof(float);
TF_Tensor *input_tensor = TF_NewTensor(TF_FLOAT, dims, (int)ndims, data, ndata, &NoOpDeallocator, nullptr);
std::size_t ndata = sizeof(input_data);
TF_Tensor *input_tensor = TF_NewTensor(TF_FLOAT, dims, (int)ndims, input_data, ndata, &NoOpDeallocator, nullptr);
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 we might be able to save time by reusing the memory/tensor object? We could do that by having the ChemTabSourceCalculator own the tensor. The ChemTabSourceCalculator instance is always the same batch size.

}

// Using batch overloaded version
// TODO: consider/optimize the problem that is likely requires loop to copy these arrays into TF inputs??
Copy link
Contributor

Choose a reason for hiding this comment

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

If the ChemTabSourceCalculator instance owned the tensor, you could copy directly into the tensor here.


// Verified to work 11/7/23
// NOTE: id arg is to index a potentially batched outputValues argument
void ablate::eos::ChemTab::extractModelOutputsAtPoint(const PetscReal density, PetscReal *densityEnergySource, PetscReal *densityProgressVariableSource, PetscReal *densityMassFractions,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind changing the names to match the google style case? https://ablate.dev/content/development/Formatting.html

PetscReal* densityMassFractions) const;
void ChemTabModelComputeFunction(const PetscReal density[], const PetscReal* const* const densityProgressVariables, PetscReal** densityEnergySource, PetscReal** densityProgressVariableSource,
PetscReal** densityMassFractions, size_t batch_size) const;
// Batched Version of above
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you change this comment to work with doxygen for the method signature? Is this method used anywhere or tested?

@profPlum profPlum requested a review from mmcgurn January 17, 2025 01:39
@klbudzin klbudzin merged commit e0535af into UBCHREST:main Jan 28, 2025
9 checks passed
kolosret pushed a commit to kolosret/ablate that referenced this pull request Aug 5, 2025
* commiting clarifying comments and & function definitions
+ some helpful utility functions for debugging

* fixed problem with previous commit where consts weren't being used where
needed

* first draft of dummy batch api changes
essentially passing to dummy batch function which manually calls the
unbatched version, but good test case.

* added dummy batched version of every function, each of which relies on
the single dummy batched ChemTabModelComputeFunction

* commiting first working draft of batched processing (implemented on
chemistry source only for now)

* clarified/corrected confusing & outdated comment

* commiting reformatted code & version bump

* reworked version so this would be a patch increment since it is just
optimization

* Updated doxygen comments and addressed various style issues with the PR
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