Skip to content

Add a consistency check for the precision of gr_float#279

Merged
mabruzzo merged 9 commits into
grackle-project:mainfrom
hsinhaoHHuang:ValidateFloatPrecision
Apr 2, 2025
Merged

Add a consistency check for the precision of gr_float#279
mabruzzo merged 9 commits into
grackle-project:mainfrom
hsinhaoHHuang:ValidateFloatPrecision

Conversation

@hsinhaoHHuang

Copy link
Copy Markdown
Contributor

Issue Description

I installed two Grackle (via building with classic build system on Linux) separately,
one with single precision (make precision-32) and the other with double precision (make precision-64),
at /path/to/grackle_install_single/ and /path/to/grackle_install_double/, respectively.

Then, I called the Grackle library in a simple C++ code:

my_grackle_example.cpp
#include <stdio.h>
#include <grackle.h>

int main( int argc, char *argv[] )
{
 
// my_units
   code_units my_units;
   my_units.comoving_coordinates = 0;
   my_units.density_units        = 1.0;
   my_units.length_units         = 1.0;
   my_units.time_units           = 1.0;
   my_units.a_units              = 1.0;
   my_units.a_value              = 1.0;
   set_velocity_units( &my_units );


// my_grackle_data
   chemistry_data *my_grackle_data;
   my_grackle_data = new chemistry_data;
   set_default_chemistry_parameters( my_grackle_data );

   grackle_data->use_grackle            = 1;
   grackle_data->with_radiative_cooling = 0;
   grackle_data->primordial_chemistry   = 0;
   grackle_data->metal_cooling          = 0;
   grackle_data->UVbackground           = 0;
   grackle_data->grackle_data_file      = "./CloudyData_UVB=HM2012.h5";
   initialize_chemistry_data( &my_units );


// my_fields
   grackle_field_data my_fields;
   gr_initialize_field_data( &my_fields );

   my_fields.grid_rank            = 3;
   my_fields.grid_dimension       = new int[3];
   my_fields.grid_start           = new int[3];
   my_fields.grid_end             = new int[3];

   for (int i=0; i<3; i++)
   {
      my_fields.grid_dimension[i] = 1;
      my_fields.grid_start    [i] = 0;
      my_fields.grid_end      [i] = 0;
   }

   my_fields.density              = new gr_float[1];
   my_fields.internal_energy      = new gr_float[1];
   my_fields.metal_density        = new gr_float[1];

   my_fields.density        [0]   = 1.0;
   my_fields.internal_energy[0]   = 1.0;
   my_fields.metal_density  [0]   = grackle_data->SolarMetalFractionByMass * my_fields.density[0];


// solve_chemistry
   solve_chemistry( &my_units, &my_fields, 1.0 );

   free_chemistry_data();

   return 0;
}

I compiled the code by linking to the installed double-precision Grackle

icpc -I/path/to/grackle_install_double/include -L/path/to/grackle_install_double/lib -lgrackle my_grackle_example.cpp

If I also link to the double-precision Grackle library before the execution via LD_LIBRARY_PATH, there will be no problem:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/grackle_install_double/lib
./a.out

But if I run it by linking to the single-precision Grackle library instead:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/grackle_install_single/lib
./a.out

I will get the wrong result, probably due to the inconsistent floating-point precisions of gr_float during the compilation and the runtime of my program:

WARNING: metal density exceeds total density!
i, j, k, metal, density =            1           1           1  9.9999997E-21
 0.0000000E+00
Mean molecular weight not converged!                     NaN
                    NaN                     NaN

Goal

To avoid the above issue, we may need to check the consistency of Grackle's floating-point precisions between the linked libraries during compilation and runtime.

Previous Discussion

During the discussion on Slack, Matthew Abruzzo kindly provided the following solution for me, which is the main idea of this pull request:

quotes from Slack

Matthew Abruzzo:
Thanks for tagging me. (I totally missed this). Having a check like this would be extremely useful!
Compilation against and linking against mismatched header library pairs is actually a broader issue that plagues various C/C++ libraries (in addition to you could also have mismatched version numbers/APIs). For example, HDF5, provides a function to address this exact kind of problem (here). I’ve got some quick thoughts about how to improve on your solution (I’ve thought about this before).
Rather than requiring the user to manually compare the sizes of gr_float, we could instead define a function (maybe gr_check_consistency) that performs the consistency check and tells the user whether there is a consistency-problem. The key benefit of this approach, is it provides flexibility for us to improve the consistency checks ourselves at a later date (without grackle-users needing to change anything).
Concretely, this means:
within initialize_chemistry_data.c, I would replace your current implementation of get_sizeof_gr_float(void) with a something like the following:
int grimpl_check_consistency_(int gr_float_hdrsize) {
if (gr_float_hdrsize != ((int)sizeof(gr_float))) {
return GR_FAIL;
} else {
return GR_SUCCESS;
}
}
within grackle.h I would replace the declaration of get_sizeof_gr_float with something like:
// the following function's signature may change
int grimpl_check_consistency_(int gr_float_hdrsize);
static inline int gr_check_consistency(void) {
return grimpl_check_consistency_((int)sizeof(gr_float));
}
( The use of static inline is VERY important here! it means gr_check_consistency will be defined as part of the downstream application when grackle.h is included AND it will therefore use the definition of gr_float from the header files)

Changes made in this PR

  • Add a function gr_check_consistency() to check whether the precisions of the linked Grackle libraries are consistent.
  • Add this check in the example C/C++ programs.

Tests for the changes

In the following,
"Compile with double" means compiling with -L/path/to/grackle_install_double/lib, while
"Run with single" means export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/grackle_install_single/lib before execution.

  1. I added this in my_grackle_example.cpp provided above
    printf( "gr_check_consistency = %d\n", gr_check_consistency() );
    • Compile with double and run with double
      gr_check_consistency = 1
      
    • Compile with double and run with single
      ERROR: Inconsistent floating-point precisions.
        size of gr_float in the library linked against during compilation = 8
        size of gr_float in the library linked against during runtime     = 4
       WARNING: metal density exceeds total density!
       i, j, k, metal, density =            1           1           1  9.9999997E-21
        0.0000000E+00
       Mean molecular weight not converged!                     NaN
                       NaN                     NaN
      gr_check_consistency = 0
      
    • Compile with single and run with double
      ERROR: Inconsistent floating-point precisions.
             size of gr_float in the library linked against during compilation = 4
             size of gr_float in the library linked against during runtime     = 8
      WARNING: metal density exceeds total density!
      i, j, k, metal, density =            1           1           1
      9.999999999999999E-021  5.263544247120890E-315
      Mean molecular weight not converged!                     NaN
                      NaN                     NaN
      gr_check_consistency = 0
      
    • Compile with single and run with single
      gr_check_consistency = 1
      
  2. Run the default provided src/example/cxx_example.C
    • Compile with double and run with double

      results
      The Grackle Version 3.3.1-dev
      Git Branch   ValidateFloatPrecision
      Git Revision 9cc3fda0d83959f63f384a4bf0b06550a5899af1
      
      Initializing grackle data.
      Dust chemistry enabled, setting photoelectric_heating to 2.
      Dust chemistry enabled, setting dust_recombination_cooling to 1.
      Dust chemistry enabled, setting h2_on_dust to 1.
      Initializing Cloudy cooling: Metals.
      cloudy_table_file: ../../input/CloudyData_UVB=HM2012.h5.
      Cloudy cooling grid rank: 3.
      Cloudy cooling grid dimensions: 29 26 161.
      Parameter1: -10 to 4 (29 steps).
      Parameter2: 0 to 14.849 (26 steps).
      Temperature: 1 to 9 (161 steps).
      Reading Cloudy Cooling dataset.
      Reading Cloudy Heating dataset.
      Initializing UV background.
      Reading UV background data from ../../input/CloudyData_UVB=HM2012.h5.
      UV background information:
       Haardt & Madau (2012, ApJ, 746, 125) [Galaxies & Quasars]
        z_min =  0.000
        z_max = 15.130
      Setting UVbackground_redshift_on to 15.130000.
      Setting UVbackground_redshift_fullon to 15.130000.
      Setting UVbackground_redshift_drop to 0.000000.
      Setting UVbackground_redshift_off to 0.000000.
      Grackle run-time parameters:
      use_grackle                       = 1
      with_radiative_cooling            = 1
      primordial_chemistry              = 3
      dust_chemistry                    = 1
      metal_cooling                     = 1
      UVbackground                      = 1
      grackle_data_file                 = ../../input/CloudyData_UVB=HM2012.h5
      cmb_temperature_floor             = 1
      Gamma                             = 1.66667
      h2_on_dust                        = 1
      use_dust_density_field            = 0
      dust_recombination_cooling        = 1
      photoelectric_heating             = 2
      photoelectric_heating_rate        = 8.5e-26
      use_isrf_field                    = 1
      interstellar_radiation_field      = 1.7
      use_volumetric_heating_rate       = 0
      use_specific_heating_rate         = 0
      use_temperature_floor             = 0
      temperature_floor_scalar          = 0
      three_body_rate                   = 0
      cie_cooling                       = 0
      h2_optical_depth_approximation    = 0
      ih2co                             = 1
      ipiht                             = 1
      HydrogenFractionByMass            = 0.76
      DeuteriumToHydrogenRatio          = 6.8e-05
      SolarMetalFractionByMass          = 0.01295
      local_dust_to_gas_ratio           = 0.009387
      CaseBRecombination                = 0
      NumberOfTemperatureBins           = 600
      TemperatureStart                  = 1
      TemperatureEnd                    = 1e+09
      NumberOfDustTemperatureBins       = 250
      DustTemperatureStart              = 1
      DustTemperatureEnd                = 1500
      Compton_xray_heating              = 0
      LWbackground_sawtooth_suppression = 0
      LWbackground_intensity            = 0
      UVbackground_redshift_on          = 15.13
      UVbackground_redshift_off         = 0
      UVbackground_redshift_fullon      = 15.13
      UVbackground_redshift_drop        = 0
      cloudy_electron_fraction_factor   = 0.00915396
      use_radiative_transfer            = 0
      radiative_transfer_coupled_rate_solver = 0
      radiative_transfer_intermediate_step = 0
      radiative_transfer_hydrogen_only  = 0
      self_shielding_method             = 0
      H2_self_shielding                 = 0
      H2_custom_shielding               = 0
      h2_charge_exchange_rate           = 1
      h2_dust_rate                      = 1
      h2_h_cooling_rate                 = 1
      collisional_excitation_rates      = 1
      collisional_ionisation_rates      = 1
      recombination_cooling_rates       = 1
      bremsstrahlung_cooling_rates      = 1
      max_iterations                    = 10000
      exit_after_iterations_exceeded    = 0
      omp_nthreads                      = 0
      OpenMP: off
      cooling_time = -2.172897e+14 s.
      temperature = 2.550790e+03 K.
      pressure = 3.285492e-13 dyne/cm^2.
      gamma = 1.666543e+00.
      dust_temperature = 40.8327 K.
      
    • Compile with double and run with single, before modifications

      results
       WARNING: metal density exceeds total density!
       i, j, k, metal, density =            1           1           1  9.9999997E-21
        0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  9.9999997E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21  7.5000498E-21  9.9999997E-21  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  1.3566358E-20  1.1499641E-20       Infinity  0.0000000E+00
       HUGE HIp! ::            1           1           1                     NaN
        9.9999997E-21  9.9999997E-21       Infinity       Infinity  0.0000000E+00
      cooling_time = 0.000000e+00 s.
      temperature = 6.921579e-310 K.
      pressure = 0.000000e+00 dyne/cm^2.
      gamma = 6.921579e-310.
      dust_temperature = 6.92158e-310 K.
      
    • Compile with double and run with single, after modifications

      ERROR: Inconsistent floating-point precisions.
             size of gr_float in the library linked against during compilation = 8
             size of gr_float in the library linked against during runtime     = 4
      Error in gr_check_consistency.
      

      It successfully detected the consistency problem.

Comment thread src/clib/initialize_chemistry_data.c Outdated
@mabruzzo

Copy link
Copy Markdown
Collaborator

@hsinhaoHHuang, thank you for making this PR! And for providing such a detailed description! This looks fantastic!

I'll circle back and give this a more careful review in the next day (but I doubt I will have much to add).

Somewhere along the lines, we are going to need to document the gr_check_consistency() function in the online documentation. @hsinhaoHHuang do you want to take a stab at doing that? You would need to add an entry under the Miscellaneous Function Heading in the doc/source/Reference.rst file. It's totally fine if you don't have time or don't feel comfortable editing Restructured Text. (Britton or I could always do it).

@mabruzzo mabruzzo added the enhancement New feature or request label Mar 24, 2025
hsinhaoHHuang and others added 2 commits March 25, 2025 09:42
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
@hsinhaoHHuang

Copy link
Copy Markdown
Contributor Author

@mabruzzo Thank you for your comments. I have just tried to add descriptions in the documentation. Please let me know if I still need to add anything.
Thanks!

@mabruzzo mabruzzo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for making those changes! This morning, I had a moment to take a careful look at the PR. Again, it looks fantastic! Thank you again for making the PR.

I have 2 sets of important (largely superficial) suggestions. You should obviously feel free to push back if you disagree:

  1. I suggested a slight change to the description of gr_check_consistency
  2. In the code examples, I think we should be calling gr_check_consistency before we touch any part of Grackle's API (i.e. before we modify the grackle_verbose or declare the my_units variable).
    • ASIDE: As I explain in a comment, you are going to encounter a merge-conflict with cxx_grid_example.C (the comment provides a suggestion on how to resolve that conflict).

Most of the remaining suggestions are totally optional. They mostly pertain to the fact that I think we should start encouraging applications to only compare return-codes against GR_SUCCESS, and to avoid comparing with GR_FAIL (aka 0). As I note in the comments:

  • this is necessary for one potential approach (i.e. associating specialized return-codes with detailed error-messages) that might be used to improve Grackle's error-reporting
  • with that said, this isn't a formal policy (there are other approaches to improve error-reporting, that we may prefer). Importantly, we would need to do a bunch of work to gracefully convert (i.e. in a backwards compatible manner) most of Grackle's existing API functions to this sort of approach. Thus, it doesn't really matter which approach gr_check_consistency uses (converting it later would not involve much more effort)

reference of the Grackle

Comment thread doc/source/Reference.rst Outdated
Comment thread doc/source/Reference.rst Outdated
Comment thread src/include/grackle.h Outdated
Comment thread src/example/cxx_omp_example.C Outdated
Comment thread src/example/cxx_example.C Outdated
Comment thread src/example/c_local_example.c Outdated
Comment thread src/example/c_example.c Outdated
Comment thread src/example/cxx_grid_example.C Outdated
@mabruzzo

Copy link
Copy Markdown
Collaborator

One last thought:

  • when I suggested gr_check_consistency, I was heavily inspired by HDF5's H5check_version() function.
  • notably, H5check_version() immediately aborts the entire program if there is a version mismatch

Should we be aborting the program? HDF5 has the added incentive that they really want to avoid corruption of existing files. I think the answer is "no" for us. But, I am open to the idea of eagerly aborting.

@brittonsmith do you have any thoughts?

@hsinhaoHHuang

Copy link
Copy Markdown
Contributor Author

@mabruzzo Thank you for the thorough review. I will modify the code based on your suggestions in a few days.

mabruzzo added a commit to mabruzzo/grackle that referenced this pull request Mar 26, 2025
This PR shifts the core-library tests to a separate "job."

It has come to my attention in recent PRs (e.g. grackle-project#273, grackle-project#279), that our
current choice to run the core-library test-suite after the Pygrackle
test-suite is somewhat undesirable. Specifically, the core-library
test-suite is more likely to include unit-tests (while there may not
be many unit-tests yet, many forthcoming PRs have proposed adding them).

This is important for 2 reasons:
1. Unit-tests are inherently faster than answer-tests. We should run
   these as soon as possible so we can fail quickly.
2. Unit-tests are also more specialized than answer-tests. If a
   unit-test fails, it is likely that an answer-test will also fail. The
   way things have been configured (before this PR) will cause the
   answer-test to fail and CI to abort before the unit-tests can be
   reun.

As I write this up, I realize that I probably just could have re-ordered
the tests. I'm totally willing to do that. But, I think in some ways
this may be better (if we aren't too worried about using up resources)
mabruzzo added a commit to mabruzzo/grackle that referenced this pull request Mar 26, 2025
This PR shifts the core-library tests to a separate "job."

It has come to my attention in recent PRs (e.g. grackle-project#273, grackle-project#279), that our
current choice to run the core-library test-suite after the Pygrackle
test-suite is somewhat undesirable. Specifically, the core-library
test-suite is more likely to include unit-tests (while there may not
be many unit-tests yet, many forthcoming PRs have proposed adding them).

This is important for 2 reasons:
1. Unit-tests are inherently faster than answer-tests. We should run
   these as soon as possible so we can fail quickly.
2. Unit-tests are also more specialized than answer-tests. If a
   unit-test fails, it is likely that an answer-test will also fail. The
   way things have been configured (before this PR) will cause the
   answer-test to fail and CI to abort before the unit-tests can be
   reun.

As I write this up, I realize that I probably just could have re-ordered
the tests. I'm totally willing to do that. But, I think in some ways
this may be better (if we aren't too worried about using up resources)
@hsinhaoHHuang

Copy link
Copy Markdown
Contributor Author

@mabruzzo Thank you again for the review and suggestions. I agree with your comments and have applied your suggestions.

Regarding program abortion during consistency checks, here are some of my thoughts:

In the future, our consistency check process may identify two categories of inconsistencies:

  1. Critical issues (e.g., gr_float incompatibilities) that prevent proper execution
  2. Non-critical differences (e.g., minor version discrepancies) that allow continued operation

For non-critical inconsistencies, maybe we can print a warning message (or other preferred error reporting methods) and still return GR_SUCCESS in grimpl_check_consistency_ function. This approach would display appropriate notifications to the user while allowing program execution to continue.

@brittonsmith brittonsmith added this to the 3.4 milestone Apr 2, 2025

@mabruzzo mabruzzo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for making the changes! LGTM

(I think we are going to leave it to the user to decide whether we abort)

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants