SciML / Surrogates.jl

Surrogate modeling and optimization for scientific machine learning (SciML)
https://docs.sciml.ai/Surrogates/stable/
Other
330 stars 69 forks source link

Optimize GEK.jl #474

Closed Spinachboul closed 5 months ago

Spinachboul commented 7 months ago
  1. Matrix Operations Optimization:

    • Utilized LinearAlgebra functions for matrix inversion to improve efficiency.
  2. Loop Optimization:

    • Utilized @inbounds and @simd macros for loop bounds-check elimination and vectorization, respectively, to enhance performance.
  3. Calculations are reused:

    • Moved common calculations outside loops to avoid redundancy and improve efficiency.
  4. Redundant Checks:

    • Moved the check for sample repetition outside the constructor function to eliminate redundant checks and improve readability.
  5. Consolidation of Functions:

    • Removed duplicate _calc_gek_coeffs function and consolidated its logic into a single function to enhance maintainability.
  6. Optimized Constructor:

    • Streamlined the constructor function to improve readability and efficiency.
  7. Added Dimension Checking:

    • Added a _check_dimension function to ensure the input dimension matches the surrogate dimension, improving robustness.

Testing yet to be performed after after appropriate review by the maintainers

@ChrisRackauckas and @sathvikbhagavan

ChrisRackauckas commented 7 months ago

I'm not sure I see what in these changes would actually improve performance? Can you show a benchmark and a flamegraph?

Spinachboul commented 7 months ago

Sure! I'll do that soon

Spinachboul commented 6 months ago

@ChrisRackauckas and @sathvikbhagavan I have drafted this PR since while benchmarking, I could only find some differences/improvements in terms of time and space I have attached a pdf describing the differences between my code and the original code. The sphere benchmarking will be done soon, withing a couple of days!! Differences table.pdf