Skip to content

add omp_sz_hacker_ForLargeSystems#205

Open
tmisawa wants to merge 4 commits intodevelopfrom
LargeHilbertSpace
Open

add omp_sz_hacker_ForLargeSystems#205
tmisawa wants to merge 4 commits intodevelopfrom
LargeHilbertSpace

Conversation

@tmisawa
Copy link
Copy Markdown
Contributor

@tmisawa tmisawa commented Jun 16, 2025

@k-yoshimi k-yoshimi requested a review from Copilot June 18, 2025 00:18
Copy link
Copy Markdown

Copilot AI left a comment

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 enhances the existing hacker mode by adding a specialized path for large systems (mode 2) and implements the supporting functions.

  • Broadened the hacker check to >=1 and introduced a new branch for hacker==2 calling omp_sz_hacker_ForLargeSystems.
  • Added implementation of omp_sz_hacker_ForLargeSystems, make_true_spin, update_lists, and compare_ulong in src/sz.c.
  • Updated sz.h with prototypes for the new functions and added error handling for invalid hacker values.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/sz.c Modified branching on hacker value, added new large-system support mode, introduced helper functions and error checks.
src/include/sz.h Declared prototypes for omp_sz_hacker_ForLargeSystems, make_true_spin, update_lists, and compare_ulong.
Comments suppressed due to low confidence (5)

src/sz.c:1711

  • [nitpick] Function name 'omp_sz_hacker_ForLargeSystems' mixes case and underscores; consider using a consistent snake_case style (e.g. 'omp_sz_hacker_for_large_systems') to match existing conventions.
unsigned long int omp_sz_hacker_ForLargeSystems(

src/sz.c:397

  • [nitpick] The error message refers to 'read_hacker in ModPara file' which may confuse readers; consider simplifying to 'Invalid hacker value: must be 0, 1, or 2.' and reference the actual parameter name.
          fprintf(stderr, "Error: read_hacker in ModPara file must be 0, 1 or 2 for Hubbard model.");

src/sz.c:1698

  • The doc comment for 'omp_sz_hacker_ForLargeSystems' should more precisely describe the return value semantics, valid input ranges, and behavior on edge cases (e.g., when ihfbit is zero).
/** 

src/include/sz.h:118

  • The new API 'omp_sz_hacker_ForLargeSystems' (and its helpers) lack dedicated unit tests; consider adding tests to verify correct behavior across different system sizes and edge conditions.
unsigned long int omp_sz_hacker_ForLargeSystems(

src/sz.c:1801

  • [nitpick] Sorting the full list for very large systems may be a bottleneck. Consider more efficient on-the-fly or streaming approaches to avoid high memory and CPU usage.
      qsort(tmp, len_n, sizeof(long unsigned int), compare_ulong);

}
/*[s]sort*/
long unsigned int len_n = X->Check.idim_max + 1;
long unsigned int *tmp = malloc(len_n * sizeof(long unsigned int));
Copy link

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

The result of malloc is not checked; if allocation fails, 'tmp' will be NULL, leading to undefined behavior. Add a NULL check and handle allocation failures.

Copilot uses AI. Check for mistakes.
@k-yoshimi
Copy link
Copy Markdown
Contributor

@tmisawa
Please correspond to the following comments:

Comments suppressed due to low confidence (5)

src/sz.c:1711

  • [nitpick] Function name 'omp_sz_hacker_ForLargeSystems' mixes case and underscores; consider using a consistent snake_case style (e.g. 'omp_sz_hacker_for_large_systems') to match existing conventions.
unsigned long int omp_sz_hacker_ForLargeSystems(

src/sz.c:397

  • [nitpick] The error message refers to 'read_hacker in ModPara file' which may confuse readers; consider simplifying to 'Invalid hacker value: must be 0, 1, or 2.' and reference the actual parameter name.
          fprintf(stderr, "Error: read_hacker in ModPara file must be 0, 1 or 2 for Hubbard model.");

src/sz.c:1698

  • The doc comment for 'omp_sz_hacker_ForLargeSystems' should more precisely describe the return value semantics, valid input ranges, and behavior on edge cases (e.g., when ihfbit is zero).
/** 

src/include/sz.h:118

  • The new API 'omp_sz_hacker_ForLargeSystems' (and its helpers) lack dedicated unit tests; consider adding tests to verify correct behavior across different system sizes and edge conditions.
unsigned long int omp_sz_hacker_ForLargeSystems(

src/sz.c:1801

  • [nitpick] Sorting the full list for very large systems may be a bottleneck. Consider more efficient on-the-fly or streaming approaches to avoid high memory and CPU usage.
      qsort(tmp, len_n, sizeof(long unsigned int), compare_ulong);

@tmisawa
Copy link
Copy Markdown
Contributor Author

tmisawa commented Jun 18, 2025

@k-yoshimi
I have resolved the conflict.
I have also checked the comments by Copilot and made the necessary changes where possible.

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.

3 participants