Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of partial sums #235

Open
richfitz opened this issue Aug 13, 2021 · 0 comments
Open

Better handling of partial sums #235

richfitz opened this issue Aug 13, 2021 · 0 comments

Comments

@richfitz
Copy link
Member

Consider this from sircovid

n_E_vaccinated[, ] <- sum(n_E_next_vacc_class[i, , , j])
dim(n_E_vaccinated) <- c(n_groups, n_vacc_classes)

this compiles to

    for (int i = 1; i <= shared->dim_n_E_vaccinated_1; ++i) {
      for (int j = 1; j <= shared->dim_n_E_vaccinated_2; ++j) {
        internal.n_E_vaccinated[i - 1 + shared->dim_n_E_vaccinated_1 * (j - 1)] = odin_sum4<real_t>(internal.n_E_next_vacc_class.data(), i - 1, i, 0, shared->dim_n_E_next_vacc_class_2, 0, shared->dim_n_E_next_vacc_class_3, j - 1, j, shared->dim_n_E_next_vacc_class_1, shared->dim_n_E_next_vacc_class_12, shared->dim_n_E_next_vacc_class_123);
      }
    }

We should be able to do this more efficiently, depending on how the indices here are being summed over, which might result in less churn through the loops here and a more efficient sum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant