Skip to content

Improves Pseudolikelihood computation performance#18

Merged
Freguglia merged 4 commits into
mainfrom
pl-performance
May 28, 2026
Merged

Improves Pseudolikelihood computation performance#18
Freguglia merged 4 commits into
mainfrom
pl-performance

Conversation

@Freguglia

Copy link
Copy Markdown
Owner

No description provided.

@Freguglia Freguglia self-assigned this May 28, 2026
@Freguglia
Freguglia requested a review from Copilot May 28, 2026 23:47
@Freguglia
Freguglia merged commit 97b3676 into main May 28, 2026
2 of 3 checks passed
@Freguglia
Freguglia deleted the pl-performance branch May 28, 2026 23:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the performance of pseudo-likelihood computation in the mrf2d package by (1) refactoring the per-pixel conditional probability computation to use a log-space, log-sum-exp formulation that avoids per-pixel NumericVector allocation and gives better numerical stability, (2) reordering the inner loops to iterate over neighbors outermost and values innermost (better cache locality plus a single bounds check per direction), and (3) adding optional OpenMP parallelization over the pixel grid in log_pl_mrf / log_pl_mrf_sub.

Changes:

  • Rewrite conditional_probabilities_mrf{,_sub} to accumulate log-potentials and normalize with the log-sum-exp trick.
  • Add log_cond_pixel{,_sub} helpers and OpenMP parallel for collapse(2) reductions in log_pl_mrf{,_sub}, with thread-local scratch buffers.
  • Add src/Makevars and src/Makevars.win enabling SHLIB_OPENMP_CXXFLAGS; bump Version to 1.0.2, RoxygenNote to 7.3.3, and actions/upload-artifact to v4.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/pseudo_likelihood.cpp New log-space per-pixel helpers and OpenMP-parallel reductions over the grid.
src/conditional_probability.cpp Reordered loops and added log-sum-exp normalization for numerical stability.
src/Makevars New file enabling OpenMP flags on Unix builds.
src/Makevars.win New file enabling OpenMP flags on Windows builds.
DESCRIPTION Bumps package Version and RoxygenNote.
.github/workflows/test-coverage.yaml Upgrades upload-artifact action from v3 to v4.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants