Repository navigation
In-process Python bindings and faster ADI diffusion kernel - #29
Harishankar14 wants to merge 1 commit into
Conversation
Phase 1: SimParam::ComputeDerived(), in-memory results via SummaryRow; Simulate() accepts injected parameters and a results vector. Phase 2: direct writes instead of ChangeConcentrationBy, tightened Thomas loops, 8-line interleaving in all sweeps, a single parallel region. Single-threaded, 1 simulated day: 1936 s -> 557 s (3.48x). Output byte-identical to master (1 and 9 days; grids 32, 37 and 50).
857aef6 to
d711a2f
Compare
|
Damn !! Took too much time, I guess this PR indeed fixes it !! (Atleast stats shows that ) |
| #include <cstdint> | ||
| #include <cstdlib> | ||
| #include <filesystem> | ||
| #include <fstream> |
There was a problem hiding this comment.
warning: included header filesystem is not used directly [misc-include-cleaner]
| #include <fstream> | |
| #include <fstream> |
| #include <cstdlib> | ||
| #include <filesystem> | ||
| #include <fstream> | ||
| #include <iostream> |
There was a problem hiding this comment.
warning: included header fstream is not used directly [misc-include-cleaner]
| #include <iostream> | |
| #include <iostream> |
| #include <iostream> | ||
| #include <memory> | ||
| #include <stdexcept> | ||
| #include <string> |
There was a problem hiding this comment.
warning: included header stdexcept is not used directly [misc-include-cleaner]
| #include <string> | |
| #include <string> |
| // simulate total_minutes_to_simulate minutes including the last minute | ||
| const auto t_startup_end = std::chrono::steady_clock::now(); | ||
| const double startup_ms = | ||
| std::chrono::duration<double, std::milli>(t_startup_end - t_startup_begin) |
There was a problem hiding this comment.
warning: no header providing "std::milli" is directly included [misc-include-cleaner]
src/cart_tumor.cc:46:
- #include <stdexcept>
+ #include <ratio>
+ #include <stdexcept>| /// Function declaration for the main simulation | ||
| int Simulate(int argc, const char** argv); | ||
| int Simulate(int argc, const char** argv, SimParam* injected_params = nullptr, | ||
| std::vector<SummaryRow>* results = nullptr); |
There was a problem hiding this comment.
warning: no header providing "std::vector" is directly included [misc-include-cleaner]
src/cart_tumor.h:23:
- namespace bdm {
+ #include <vector>
+ namespace bdm {| inline void ForwardBlock(real_t* __restrict c, size_t base, int jump, int n, | ||
| const real_t* __restrict d, real_t k, real_t lo, | ||
| real_t hi) { | ||
| real_t prev[W]; |
There was a problem hiding this comment.
warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays]
real_t prev[W];
^| real_t hi) { | ||
| real_t prev[W]; | ||
| for (int b = 0; b < W; ++b) { | ||
| const real_t old = c[base + b]; |
There was a problem hiding this comment.
warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]
const real_t old = c[base + b];
^| real_t prev[W]; | ||
| for (int b = 0; b < W; ++b) { | ||
| const real_t old = c[base + b]; | ||
| const real_t v = old / d[0]; |
There was a problem hiding this comment.
warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]
const real_t v = old / d[0];
^| for (int b = 0; b < W; ++b) { | ||
| const real_t old = c[base + b]; | ||
| const real_t v = old / d[0]; | ||
| prev[b] = std::clamp(old + (v - old), lo, hi); |
There was a problem hiding this comment.
warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index]
prev[b] = std::clamp(old + (v - old), lo, hi);
^| const real_t old = c[base + b]; | ||
| const real_t v = old / d[0]; | ||
| prev[b] = std::clamp(old + (v - old), lo, hi); | ||
| c[base + b] = prev[b]; |
There was a problem hiding this comment.
warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index]
c[base + b] = prev[b];
^|
Adding this PR after merging #24 into the main stream !! |
|
Hi, could you please run the following these two simulations: |


Phase 1: SimParam::ComputeDerived(), in-memory results via SummaryRow; Simulate() accepts injected parameters and a results vector. Phase 2: direct writes instead of ChangeConcentrationBy, tightened Thomas loops, 8-line interleaving in all sweeps, a single parallel region.
Single-threaded, 1 simulated day: 1936 s -> 557 s (3.48x). Output byte-identical to master (1 and 9 days; grids 32, 37 and 50).