Skip to content

Conversation

@scal444
Copy link
Collaborator

@scal444 scal444 commented Jan 21, 2026

First PR for substructure search. Includes definitions for bit-packed atom data and comparison functions, and an implementation of a boolean tree walk.

The boolean tree reference recursive bits that are not yet implemented, but can be tested with dummy data.

@scal444 scal444 requested a review from evasnow1992 January 21, 2026 20:16
@scal444 scal444 self-assigned this Jan 21, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 21, 2026

Greptile Summary

Introduces foundational components for substructure search: a bit-packed atom data structure (AtomDataPacked) for efficient GPU comparison and a boolean tree evaluator for complex query expressions.

  • Added 128-bit packed atom representation with branchless mask-and-compare matching
  • Implemented boolean expression tree with AND/OR/NOT/comparison operations and recursive pattern support
  • Comprehensive test coverage for logical operations, bond matching, and recursive patterns (both host and device)
  • Tests for comparison operations (GreaterThan, LessEqual, GreaterEqual, Range) would strengthen coverage
  • CMake integration properly configured with new substruct subdirectory

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-structured with comprehensive tests for core functionality. The bit-packing logic is correct and well-documented. The only gap is missing test coverage for comparison operations, which are implemented but untested. The PR description notes that recursive bits are not yet implemented, and the code appropriately uses dummy data for testing that functionality.
  • No files require special attention

Important Files Changed

Filename Overview
src/substruct/atom_data_packed.h Introduces bit-packed atom data structure (128 bits) with getters/setters for efficient GPU comparison. Includes branchless matching functions for atom and bond queries.
src/substruct/boolean_tree.cuh Implements boolean expression tree evaluation for atom matching with logical operators (AND/OR/NOT), field comparisons, and recursive pattern matching using stack-based evaluation.
tests/test_boolean_tree.cu Comprehensive unit tests for boolean tree evaluation covering logical operations, bond matching, and recursive patterns. Tests both host and device execution with various atom types.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. tests/test_boolean_tree.cu, line 1025 (link)

    style: Consider adding tests for the comparison operations (GreaterThan, LessEqual, GreaterEqual, Range) defined in boolean_tree.cuh. These operations are implemented but currently untested.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

7 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

/// @name Compacted 4-bit field masks and bit positions
/// @{
static constexpr int k4BitMask = 0x0F; ///< Mask for 4-bit fields (max value 15)
static constexpr int kNumRingsBits = 0; ///< Low 4 bits of byte 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

I notice for several atom properties (numRings, ringBondCount, numImplicitHs, numHeteroatomNeighbors), we're using 4-bit fields with a max value of 15. Should we add bounds checking or saturation in the setters? Currently, values > 15 are silently truncated, which could cause unexpected behavior.

Copy link
Collaborator

@evasnow1992 evasnow1992 left a comment

Choose a reason for hiding this comment

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

Thank you for adding packed atom data and boolean tree operations. Only one minor comment. Also may considering adding some edge case tests like for empty trees, and/or tests for comparison operations like GreaterThan. Not required though

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