Commit 4ef7c9a0 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Merge branch 'update_trapping' into 'master'

Update trapping

See merge request giacomo.mulas/np_tmcode!60
parents ecebe07a 6670962f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -212,18 +212,18 @@ testing_stage:
      - cd build/sphere
      - export FFILE=../../test_data/sphere/OSPH
      - echo "Comparing output of SPHERE"
      - python3 ../../src/scripts/pycompare.py --no-progress --ffile=$FFILE --cfile=c_OSPH --html
      - python3 ../../src/scripts/pycompare.py --no-progress --ffile $FFILE --cfile c_OSPH --html
      - echo "Checking consistency among legacy and HDF5 configuration files"
      - ../testing/test_TEDF ../../test_data/sphere/DEDFB c_TEDF c_TEDF.hd5
      - cd ../cluster
      - echo "Comparing output of CLUSTER"
      - export FFILE=../../test_data/cluster/OCLU
      - python3 ../../src/scripts/pycompare.py --no-progress --ffile=$FFILE --cfile=c_OCLU --html
      - python3 ../../src/scripts/pycompare.py --no-progress --ffile $FFILE --cfile c_OCLU --html
      - echo "Testing cluster with 24 spheres"
      - OMP_NUM_THREADS=1 OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 mpirun -n 2 ./np_cluster ../../test_data/cluster/DEDFB_24 ../../test_data/cluster/DCLU_24 .
      - echo "Comparing output of CLUSTER with 24 spheres"
      - export FFILE=../../test_data/cluster/OCLU_24
      - python3 ../../src/scripts/pycompare.py --no-progress --ffile=$FFILE --cfile=c_OCLU --html
      - python3 ../../src/scripts/pycompare.py --no-progress --ffile $FFILE --cfile c_OCLU --html
      - echo "Checking consistency among legacy and HDF5 configuration files"
      - ../testing/test_TEDF ../../test_data/cluster/DEDFB_24 c_TEDF c_TEDF.hd5
      - echo "Checking consistency among legacy and HDF5 TM files"
+16 −2
Original line number Diff line number Diff line
@@ -62,7 +62,21 @@ typedef __complex__ double dcomplex;
#endif // lapack_int
#endif // np_int

#define imag(z) ( __imag__ (z) )
#define real(z) ( __real__ (z) )
#define dconjg(z) ( (__real__ (z) - I * (__imag__ (z))) )

/*! \brief Get the imaginary part of double precision complex number.
 *
 * \param z: `const dcomplex &` Reference to the complex number from
 * which to extract the imaginary part.
 * \return Im(z): `double` Imaginary part of z.
 */
double inline imag(const dcomplex &z) { return __imag__ z; }

/*! \brief Get the imaginary part of double precision complex number.
 *
 * \param z: `const dcomplex &` Reference to the complex number from
 * which to extract the real part.
 * \return Re(z): `double` Real part of z.
 */
double inline real(const dcomplex &z) { return __real__ z; }
#endif
+4 −3
Original line number Diff line number Diff line
@@ -856,6 +856,7 @@ ScattererConfiguration* ScattererConfiguration::from_hdf5(const std::string& fil
    } // di loop
    delete[] elements;
    status = hdf_file->close();
    delete hdf_file;
    conf = new ScattererConfiguration(
				      nsph,
				      configuration_count,
@@ -873,8 +874,8 @@ ScattererConfiguration* ScattererConfiguration::from_hdf5(const std::string& fil
				      _wp,
				      _xip
    );
    delete[] xi_vec;
  }
  
  return conf;
}

+14 −4
Original line number Diff line number Diff line
@@ -45,6 +45,18 @@
#include "../include/tra_subs.h"
#endif

#ifdef USE_NVTX
#include <nvtx3/nvToolsExt.h>
#endif

#ifdef _OPENMP
#include <omp.h>
#endif

#ifdef USE_TARGET_OFFLOAD
#pragma omp requires unified_shared_memory
#endif

void camp(dcomplex *ac, dcomplex **am0m, dcomplex *ws, CIL *cil) {
  for (int j = 0; j < cil->nlemt; j++) {
    for (int i = 0; i < cil->nlemt; i++) {
@@ -96,8 +108,7 @@ void ffrf(
      int ltpo = lpo + l40;
      int imm = l40 * lpo;
      for (int ilmp40 = 1; ilmp40 <= 3; ilmp40++) {
	// NOTE: if trapping execution diverges, replace "break" with "continue"
	if ((l40 == 1 && ilmp40 == 1) || (l40 == cil->le && ilmp40 == 3)) break; // ilmp40 loop
	if ((l40 == 1 && ilmp40 == 1) || (l40 == cil->le && ilmp40 == 3)) continue; // ilmp40 loop
	int lmpml = ilmp40 - 2;
	int lmp = l40 + lmpml;
	uimmp = uim * (-1.0 * lmpml);
@@ -150,8 +161,7 @@ void ffrf(
      int ltpo = lpo + l80;
      int imm = l80 * lpo;
      for (int ilmp80 = 1; ilmp80 <= 3; ilmp80++) {
	// NOTE: if trapping execution diverges, replace "break" with "continue"
	if ((l80 == 1 && ilmp80 == 1) || (l80 == cil->le && ilmp80 == 3)) break; // ilmp80 loop
	if ((l80 == 1 && ilmp80 == 1) || (l80 == cil->le && ilmp80 == 3)) continue; // ilmp80 loop
	int lmpml = ilmp80 - 2;
	int lmp = l80 + lmpml;
	uimmp = uim * (-1.0 * lmpml);
+47 −16
Original line number Diff line number Diff line
@@ -343,6 +343,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None):
                                log_line + "</code><span style=\"font-weight: bold; color: rgb(255,0,0)\"><code>"
                                + c_groups[-1] + "</code></span><code>" + c_line[c_ends[-1]:len(c_line) - 2]
                            )
                    if ((not config['hide_noise'] and noisy > 0) or warnings > 0 or errors > 0):
                        log_file.write(log_line + "</code></pre></div>\n")
                        log_file.write(ref_line)
        else: # The two lines contain a different number of numeric values
@@ -428,11 +429,17 @@ def mismatch_severities(str_f_values, str_c_values, config):
                        fractional = scale * (f_values[i] - c_values[i]) / f_values[i]
                        if (fractional < 0.0): fractional *= -1.0
                        if (fractional <= config['warning_threshold']):
                            if (log_f_value > config['data_order']):
                                result[i] = 2
                            else:
                                result[i] = 1
                        else:
                            if (log_f_value > config['data_order']):
                                result[i] = 3
                            else:
                                result[i] = 1
                    else:
                        result[i] = 1
                else: # f_values[i] == 0 and c_values[i] != 0
                    sign = 1.0 if c_values[i] > 0.0 else -1.0
                    log_c_value = log10(sign * c_values[i])
@@ -441,11 +448,17 @@ def mismatch_severities(str_f_values, str_c_values, config):
                        fractional = scale * (c_values[i] - f_values[i]) / c_values[i]
                        if (fractional < 0.0): fractional *= -1.0
                        if (fractional <= config['warning_threshold']):
                            if (log_c_value > config['data_order']):
                                result[i] = 2
                            else:
                                result[i] = 1
                        else:
                            if (log_c_value > config['data_order']):
                                result[i] = 3
                            else:
                                result[i] = 1
                    else:
                        result[i] = 1
        # End number comparison
    return result
    
@@ -460,31 +473,42 @@ def mismatch_severities(str_f_values, str_c_values, config):
#  \returns config: `dict` A dictionary containing the script configuration.
def parse_arguments():
    config = {
        'fortran_file_name': '',
        'c_file_name': '',
        'check_all': True,
        'data_order': -99.0,
        'fortran_file_name': '',
        'full_log': False,
        'help_mode': False,
        'hide_noise': True,
        'html_output': 'pycompare.html',
        'linewise': True,
        'log_html': False,
        'html_output': 'pycompare.html',
        'say_progress': True,
        'warning_threshold': 0.005,
        'help_mode': False,
        'check_all': True,
    }
    arg_index = 1
    skip_arg = False
    for arg in argv[1:]:
        if skip_arg:
            skip_arg = False
            continue
        split_arg = arg.split("=")
        if (arg.startswith("--ffile")):
            config['fortran_file_name'] = split_arg[1]
            config['fortran_file_name'] = argv[arg_index + 1]
            arg_index += 1
            skip_arg = True
        elif (arg.startswith("--cfile")):
            config['c_file_name'] = split_arg[1]
            config['c_file_name'] = argv[arg_index + 1]
            arg_index += 1
            skip_arg = True
        elif (arg.startswith("--data-order")):
            config['data_order'] = float(split_arg[1])
        elif (arg.startswith("--full")):
            config['full_log'] = True
        elif (arg.startswith("--html")):
            config['log_html'] = True
            if (len(split_arg) == 2):
                config['html_output'] = split_arg[1]
        elif (arg.startswith("--warn")):
            config['warning_threshold'] = float(split_arg[1])
        elif (arg.startswith("--help")):
            config['help_mode'] = True
        elif (arg.startswith("--linewise")):
@@ -493,8 +517,13 @@ def parse_arguments():
            config['say_progress'] = False
        elif (arg.startswith("--quick")):
            config['check_all'] = False
        elif (arg.startswith("--show-noise")):
            config['hide_noise'] = False
        elif (arg.startswith("--warn")):
            config['warning_threshold'] = float(split_arg[1])
        else:
            raise Exception("Unrecognized argument \'{0:s}\'".format(arg))
        arg_index += 1
    return config

## \brief Print a command-line help summary.
@@ -507,14 +536,16 @@ def print_help():
    print("Usage: \"./pycompare.py OPTIONS\"           ")
    print("                                            ")
    print("Valid options are:                          ")
    print("--ffile=FORTRAN_OUTPUT    File containing the output of the FORTRAN code (mandatory).")
    print("--cfile=C++_OUTPUT        File containing the output of the C++ code (mandatory).")
    print("--ffile FORTRAN_OUTPUT    File containing the output of the FORTRAN code (mandatory).")
    print("--cfile C++_OUTPUT        File containing the output of the C++ code (mandatory).")
    print("--data-order=ORDER        Consider data only down to specified order (default order is -99).")
    print("--full                    Print all lines to log file (default prints only mismatches).")
    print("--help                    Print this help and exit.")
    print("--html[=OPT_OUTPUT_NAME]  Enable logging to HTML file (default logs to \"pycompare.html\").")
    print("--linewise                Load only one line at a time. Useful to compare big files (True by default).")
    print("--no-progress             Disable progress logging.")
    print("--quick                   Stop on first mismatch (default is to perform a full check).")
    print("--show-noise              Show noise in reports (default is to hide it).")
    print("--warn                    Set a fractional threshold for numeric warning (default = 0.005).")
    print("                                            ")

Loading