Commit b706f13d authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Merge branch 'master' into script_devel to update to offload trapping

parents b8036aa5 3c2b3d5e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -78,13 +78,13 @@ compatibility_stage:
      - CXX=g++-14 FC=gfortran-14 ./configure
      - make wipe
      - make -j
      - echo "Running make with refinement with gnu compilers version 14..."
      - echo "Running make with gnu compilers version 14..."
      - cd ..
      - rm -rf build_gnu14
      - mkdir build_gnu14_refine
      - cd build_gnu14_refine
      - cp -r ../build/* .
      - CXX=g++-14 FC=gfortran-14 ./configure --enable-refinement
      - CXX=g++-14 FC=gfortran-14 ./configure
      - make wipe
      - make -j
      #- echo "Running make with flang version 16 and clang version 16..."
@@ -173,7 +173,7 @@ building_stage:
      - cat /etc/os-release
      - cd build
      - echo "Configuring with default compilers (MAGMA disabled)..."
      - ./configure --without-magma --without-cublas --disable-offload --enable-refinement --enable-shared
      - ./configure --without-magma --without-cublas --disable-offload --enable-shared
      - make wipe
      - echo "Building the default configuration..."
      - make -j
+2 −0
Original line number Diff line number Diff line
@@ -617,3 +617,5 @@ reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

+23 −27
Original line number Diff line number Diff line
@@ -21,21 +21,20 @@ NVTXFLAGS=""
OMPMODE="auto"
OFFLOAD="auto"
OFFLOADFLAGS=""
REFINEFLAGS=""
# End of default configuration settings

# Function declarations
function guess_cxx {
    # Guess the name of the C++ compiler
    result=$(which mpicxx)
    result=$(which mpicxx 2>/dev/null)
    if [ "x$result" = "x" ]; then
	result=$(which g++)
	result=$(which g++ 2>/dev/null)
    fi
    if [ "x$result" = "x" ]; then
	result=$(which clang)
	result=$(which clang 2>/dev/null)
    fi
    if [ "x$result" = "x" ]; then
	result=$(which icpx)
	result=$(which icpx 2>/dev/null)
    fi
    if [ "x$result" = "x" ]; then
	result="none"
@@ -45,21 +44,21 @@ function guess_cxx {

function guess_fc {
    # Guess the name of the FORTRAN compiler
    result=$(which mpif90)
    result=$(which mpif90 2>/dev/null)
    if [ "x$result" = "x" ]; then
	result=$(which gfortran)
	result=$(which gfortran 2>/dev/null)
    fi
    if [ "x$result" = "x" ]; then
	result=$(which f77)
	result=$(which f77 2>/dev/null)
    fi
    if [ "x$result" = "x" ]; then
	result=$(which flang)
	result=$(which flang 2>/dev/null)
    fi
    if [ "x$result" = "x" ]; then
	result=$(which flang-new)
	result=$(which flang-new 2>/dev/null)
    fi
    if [ "x$result" = "x" ]; then
	result=$(which ifx)
	result=$(which ifx 2>/dev/null)
    fi
    if [ "x$result" = "x" ]; then
	result="none"
@@ -87,9 +86,6 @@ function print_help {
    echo "--enable-nvtx                     Enable NVTX profiling tools.                   "
    echo "--disable-nvtx                    Disable NVTX profiling tools (DEFAULT).        "
    echo "--enable-optimize=OPT             Use OPT-level compiler optimization.           "
    echo "--enable-refinement               Use iterative refinement of matrix inversion.  "
    echo "--disable-refinement              Do not iterate refinement of matrix inversion  "
    echo "                                  (DEFAULT).                                     "
    echo "--enable-shared                   Use shared libraries (default is static).      "
    echo "--disable-shared                  Use static libraries (DEFAULT).                "
    echo "--help                            Print this help and exit.                      "
@@ -198,10 +194,6 @@ do
	fi
	FC_OPT=$opt_level
	CXX_OPT=$opt_level
    elif [ "x$cut_arg" = "x--enable-refinement" ]; then
	REFINEFLAGS=" -DUSE_REFINEMENT"
    elif [ "x$cut_arg" = "x--disable-refinement" ]; then
	REFINEFLAGS=""
    elif [ "x$cut_arg" = "x--enable-shared" ]; then
	LIBMODE="shared"
    elif [ "x$cut_arg" = "x--disable-shared" ]; then
@@ -634,6 +626,11 @@ if [ "x$CUBLAS" != "xno" ]; then
		cuda_pkg=$(for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cublas)
    		CUDAFLAGS=$(pkg-config --cflags ${cuda_pkg})
    		CUDALDFLAGS=$(pkg-config --libs ${cuda_pkg})
	    else
		# CUBLAS not detected
		CUBLAS="no"
		CUDAFLAGS=""
		CUDALDFLAGS=""
            fi # end of CUBLAS runtime decision tree
            declare -a pkg_array=$(pkg-config --list-all | grep cudart)
            for i in "${pkg_array[@]}"; do echo "$i" | cut --delimiter=" " -f1; done | grep cudart > /dev/null
@@ -647,13 +644,17 @@ if [ "x$CUBLAS" != "xno" ]; then
            echo $CUDALDFLAGS | grep cublas > /dev/null
            cudart_check=$?
            if [ "x${cudart_check}" != "x0" ]; then
		if [ "x${CUBLAS}" != "xno" ]; then
		    CUDALDFLAGS="$CUDALDFLAGS -lcublas"
		fi
            fi
            echo $CUDALDFLAGS | grep cudart > /dev/null
            cudart_check=$?
            if [ "x${cudart_check}" != "x0" ]; then
		if [ "x${CUBLAS}" != "xno" ]; then
		    CUDALDFLAGS="$CUDALDFLAGS -lcudart"
		fi
            fi
	else
            # pkg-config is not available
            if [ -f /usr/local/cuda/include/cuda.h ]; then
@@ -813,7 +814,7 @@ EOF
    fi
    if [ "x$result" = "x0" ]; then
	echo "yes"
	OFFLOADFLAGS=" -fcf-protection=check -foffload=nvptx-none=\"-O${CXX_OPT}${CXX_DBG} -fcf-protection=check -fopt-info -lm -latomic -gomp\""
	OFFLOADFLAGS=" -DUSE_TARGET_OFFLOAD -fcf-protection=check -foffload=nvptx-none=\"-O${CXX_OPT}${CXX_DBG} -fcf-protection=check -fopt-info -lm -latomic -lgomp\""
	if [ "x${OMPFLAGS}" = "x" ]; then
	    OFFLOADFLAGS="${OFFLOADFLAGS} -fopenmp"
	fi
@@ -826,7 +827,7 @@ else
fi
# End of offload checks
if [ "x$CXXFLAGS" = "x" ]; then
    CXXFLAGS="-O${CXX_OPT}${CXX_DBG}${CLANGFLAGS}${INCLUDEFLAGS}${HDF5FLAGS}${OMPFLAGS}${MPIFLAGS}${LAPACKFLAGS}${CUBLASFLAGS}${MAGMAFLAGS}${REFINEFLAGS}${DEBUGFLAGS}${OFFLOADFLAGS}${NVTXFLAGS}"
    CXXFLAGS="-O${CXX_OPT}${CXX_DBG}${CLANGFLAGS}${INCLUDEFLAGS}${HDF5FLAGS}${OMPFLAGS}${MPIFLAGS}${LAPACKFLAGS}${CUBLASFLAGS}${MAGMAFLAGS}${DEBUGFLAGS}${OFFLOADFLAGS}${NVTXFLAGS}"
fi
if [ "x$CXXLDFLAGS" = "x" ]; then
    if [ "x$LIBMODE" = "xstatic" ]; then
@@ -885,11 +886,6 @@ if [ "x${NVTXFLAGS}" = "x" ]; then
else
    echo "INFO: NVTX profiling is enabled."
fi
if [ "x${REFINEFLAGS}" = "x" ]; then
    echo "INFO: iterative matrix inversion refinement is disabled."
else
    echo "INFO: iterative matrix inversion refinement is enabled."
fi
if [ "x${OFFLOADFLAGS}" = "x" ]; then
    echo "INFO: GPU offload through OpenMP is disabled."
else
+37 −21
Original line number Diff line number Diff line
/* Copyright (C) 2024   INAF - Osservatorio Astronomico di Cagliari
/* Copyright (C) 2025   INAF - Osservatorio Astronomico di Cagliari

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -757,9 +757,15 @@ int cluster_jxi488_cycle(
	+ ").\n";
      logger->log(message, LOG_WARN);
    } else if (recommended_li < cid->c1->li) {
      if (gconf->dyn_order_flag > 0) {
	message = "INFO: lowering internal order from " + to_string(cid->c1->li) + " to "
	  + to_string(recommended_li) + " for scale iteration " + to_string(jxi488) + ".\n";
	logger->log(message, LOG_INFO);
      } else {
	message = "WARNING: internal order " + to_string(cid->c1->li) + " too high for scale iteration "
	  + to_string(jxi488) + ".\n";
	logger->log(message, LOG_WARN);
      }
    }
    if (recommended_le > cid->c1->le) {
      message = "WARNING: external order " + to_string(cid->c1->le) + " for scale iteration "
@@ -767,11 +773,18 @@ int cluster_jxi488_cycle(
	+ ").\n";
      logger->log(message, LOG_WARN);
    } else if (recommended_le < cid->c1->le) {
      if (gconf->dyn_order_flag > 0) {
	message = "INFO: lowering external order from " + to_string(cid->c1->le) + " to "
	  + to_string(recommended_le) + " for scale iteration " + to_string(jxi488) + ".\n";
	logger->log(message, LOG_INFO);
      } else {
	message = "INFO: external order " + to_string(cid->c1->le) + " too high for scale iteration "
	  + to_string(jxi488) + ".\n";
	logger->log(message, LOG_WARN);
      }
    }
    if (recommended_li < max_li || recommended_le < max_le) {
      if (gconf->dyn_order_flag > 0) {
	int new_li = (recommended_li < max_li) ? recommended_li : max_li;
	int new_le = (recommended_le < max_le) ? recommended_le : max_le;
	cid->update_orders(sconf->_rcf, new_li, new_le);
@@ -780,6 +793,7 @@ int cluster_jxi488_cycle(
	cid->refinemode = 2;
      }
    }
  }
  int li = cid->c1->li;
  int le = cid->c1->le;
  int lm = cid->c1->lm;
@@ -883,8 +897,10 @@ int cluster_jxi488_cycle(
  double actualaccuracy = cid->accuracygoal;
  invert_matrix(cid->am, ndit, jer, cid->maxrefiters, actualaccuracy, cid->refinemode, output_path, jxi488, mxndm, cid->proc_device);
  // in principle, we should check whether the returned actualaccuracy is indeed lower than the accuracygoal, and do something about it if not
#ifdef USE_REFINEMENT
  if (gconf->refine_flag > 0) {
    if (cid->refinemode==2) {
      message = "DEBUG: iterative refinement enabled at run-time.\n";
      logger->log(message, LOG_DEBG);
      message = "INFO: calibration obtained accuracy " + to_string(actualaccuracy) + " (" + to_string(cid->accuracygoal) + " requested) in " + to_string(cid->maxrefiters) + " refinement iterations\n";
      logger->log(message);
      if (actualaccuracy > 1e-1) {
@@ -892,7 +908,7 @@ int cluster_jxi488_cycle(
	exit(1);
      }
    }
#endif
  }
  cid->refinemode = 0;
#ifdef DEBUG_AM
  VirtualAsciiFile *outam2 = new VirtualAsciiFile();
+1 −1
Original line number Diff line number Diff line
/* Copyright (C) 2024   INAF - Osservatorio Astronomico di Cagliari
/* Copyright (C) 2025   INAF - Osservatorio Astronomico di Cagliari

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
Loading