PavelBlend / blender-molecular

molecular addon for blender
27 stars 7 forks source link

Refactoring entire C code #19

Closed OmidGhotbi closed 2 months ago

OmidGhotbi commented 2 months ago

Code Refactoring: The entire C codebase, including headers, function calls, and code structures, has been refactored for improved readability and maintainability. Debugging Enhancement: An attach.json file has been added to enable direct debugging inside Visual Studio Code. This process can be replicated for other editors and debuggers. Multithreading: Multithreading functionality has been added to necessary parts of the code to enhance performance and speed up execution. Memory Allocation Retry: A retry mechanism has been implemented for situations where memory allocation or relocation fails, enhancing the robustness of the code. OpenMP Update: Multithreading has been updated to use OpenMP 3.2 LLVM, improving the efficiency of parallel execution. The OpenMP folder is no longer needed and can be removed unless it's needed for other platforms or compilers. Memory Copy: Line-by-line assignments have been replaced with memory copy operations, which are faster and safer. Memory Allocation Optimization: Memory is now allocated using the link_with_capacity function to avoid repetition. This is because memory allocation and relocation are expensive operations and can cause issues when frequently called. Calculation Optimization: The code has been optimized to reduce the number of calculations by avoiding repeated calculations. Math Optimization: Replace faster math like Sqrt instead of Pow 0.5 as the modern CPUs have hardware support for the square root operation, which can make it more efficient. And more optimization in code.

Note: the setup.py has a few changes and now, it will compile the simulation.c instead of main.c