diff --git a/archer2/README.md b/archer2/README.md index eaa78f8..a6b65ae 100644 --- a/archer2/README.md +++ b/archer2/README.md @@ -34,6 +34,12 @@ From the directory one level above this, .e.g., $ bash ./archer2/libraries/metis/metis-build.sh --prefix=/work/y07/shared ``` +which will install libraries to + +``` +${prefix}/libs/core +``` + ## Build For each package, a number of versions are compiled appropriate @@ -43,7 +49,7 @@ for different programming environment. Modulefiles are installed to ``` -/work/y07/shared/archer2-modules/modulefiles-cse-libs +/work/y07/shared/archer2-lmod/libs/core ``` ## Library modules (formerly TPSL) @@ -56,12 +62,12 @@ Some details for each package will appear here. | hypre | 2.18.0 | none | yes | yes | | matio | 1.5.18 | none | no | no | | metis | 5.1.0 | none | yes | no | -| mumps | 5.2.1 | metis, parmetis, scotch | yes | yes | +| mumps | 5.3.5 | metis, parmetis, scotch | yes | yes | | parmetis | 4.0.3 | none | yes | yes | -| scotch | 6.0.10 | none | no | yes | +| scotch | 6.1. 0 | none | no | yes | | sundials | 4.1.0 | none | yes | yes | -| superlu | 5.2.1 | none | no | no | -| superlu-dist | 6.1.1 | metis, parmetis | yes | yes | +| superlu | 5.2.2 | none | no | no | +| superlu-dist | 6.4.0 | metis, parmetis | yes | yes | ## Library modules (others via pe-scripts) @@ -69,10 +75,11 @@ Some details for each package will appear here. |--------------|----------|----------------------------|---------|------| | adios | 1.13.1 | cray-hdf5-parallel | no | yes | | boost | 1.72.0 | none | no | yes | -| petsc | 3.13.3 | superlu, superlu-dist, | yes | yes | +| petsc | 3.14.2 | superlu, superlu-dist, | no | yes | | | | metis, parmetis, scotch, | | | -| | | mumps | | | -| slepc | tbc | petsc | | | +| | | mumps, hypre, | | | +| | | cray-hdf5-parallel | | | +| slepc | 3.14.1 | petsc | no | yes | | trilinos | 12.18.1 | cray-hdf5-parallel | yes | yes | | | | cray-netcdf-hdf5parallel | | | | | | tpsl (bar hypre,sundials) | | | @@ -80,4 +87,12 @@ Some details for each package will appear here. ## Library modules (other CSE) +| Package | Version | Dependencies | OpenMP? | MPI? | +|--------------|----------|----------------------------|---------|------| +| arpack-ng | 3.8.0 | none | no | yes | + + + +## Other +See also https://github.com/PE-Cray/cpe-changelog diff --git a/archer2/command_line.sh b/archer2/command_line.sh index 6a269f1..db6d8e6 100644 --- a/archer2/command_line.sh +++ b/archer2/command_line.sh @@ -2,12 +2,12 @@ set -e -# Switch off paging (esp. for "module restore") -export MODULES_PAGER="" +# Switch off paging (esp. for long listings) +export LMOD_PAGER="None" # Default location, PE cse_root=/work/y07/shared -cpe_version=21.03 +cpe_version=21.04 # Common functions plus command line argument processing @@ -41,30 +41,18 @@ done # libraries to: ${install_root_libs} # modules to: ${install_root_mods} -install_root_libs=${prefix}/libs +install_root_libs=${prefix}/libs/core +install_root_utils=${prefix}/utils/core if [[ -n ${modprefix} ]]; then install_root_mods=${modprefix} else modprefix=${prefix} - install_root_mods=${prefix}/archer2-modules/modulefiles-cse-libs + install_root_mods=${prefix}/archer2-lmod/libs/core fi mkdir -p ${install_root_libs} mkdir -p ${install_root_mods} - -# We need ${cse_root}/archer2-modules/archer-modules-tcl.lib -# and ${cse_root}/archer2-modules/archer-pkgconfig-tcl.lib -# for testing purposes. - -if [ ! -f "${modprefix}/archer2-modules/archer-modules-tcl.lib" ]; then - cp ${cse_root}/archer2-modules/archer-modules-tcl.lib \ - ${modprefix}/archer2-modules/archer-modules-tcl.lib -fi - -if [ ! -f "${modprefix}/archer2-modules/archer-pkgconfig-tcl.lib" ]; then - cp ${cse_root}/archer2-modules/archer-pkgconfig-tcl.lib \ - ${modprefix}/archer2-modules/archer-pkgconfig-tcl.lib -fi +mkdir -p ${prefix}/archer2-lmod/utils/core # Check programming environment @@ -112,7 +100,7 @@ function moduleCollection { local prgenv=$1 - echo "${prgenv_dir}/${prgenv}" + echo ${prgenv} } function moduleToCompilerMajorMinor { @@ -173,21 +161,30 @@ function moduleInstallDirectory { function moduleUseLibs { - module unuse /work/y07/shared/archer2-modules/modulefiles-cse-libs module use ${install_root_mods} printf "MODULEPATH: %s\n" "${MODULEPATH}" } -function moduleRestore { +function moduleInstallDirectoryUtils { + + echo "${prefix}/archer2-lmod/utils/core" +} + +function moduleUseUtils { + + module use $(moduleInstallDirectoryUtils) + +} + +function moduleLoad { # A wrapper to "module restore" to allow loading of a relevant # module file. "PrgEnv-cray" or "PrgEnv-gnu" or "PrgEnv-aocc" local prgenv=$1 - module restore "${A2_ROOT}/module/${prgenv}-${PE_CPE_VERSION}" - + module load ${prgenv} } function slurmAllocRun { diff --git a/archer2/libraries/adios/build-adios.sh b/archer2/libraries/adios/build-adios.sh index 4c3d988..03a11c6 100644 --- a/archer2/libraries/adios/build-adios.sh +++ b/archer2/libraries/adios/build-adios.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/adios/${ADIOS_VERSION} + local install_root=${install_root_libs}/adios/${ADIOS_VERSION} ${build_cce} && adiosBuildCray ${install_root} ${build_gnu} && adiosBuildGnu ${install_root} ${build_amd} && adiosBuildAocc ${install_root} - adiosInstallModuleFile + adiosInstallModuleFileLua adiosInstallationTest printf "ARCHER2: Installation test of adios successful\n" @@ -28,9 +28,22 @@ function main { function adiosLoadModuleDependencies { + # Adios v2 requires cmake >= 3.12 + moduleUseLibs - module load cray-hdf5-parallel/${CRAY_HDF5_PARALLEL_VERSION} + module load cmake + # While AOCC pending pkgconfig fix + #module load cray-hdf5-parallel/${CRAY_HDF5_PARALLEL_VERSION} + module load epcc-cray-hdf5-parallel/${CRAY_HDF5_PARALLEL_VERSION} +} + +function adiosUnloadModuleDependencies { + + module unload epcc-cray-hdf5-parallel + # While AOCC pending pkgconfig fix + #module unload cray-hdf5-parallel + module unload cmake } function adiosBuildAocc { @@ -38,8 +51,9 @@ function adiosBuildAocc { local install_root=${1} # restore pe/compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} adiosLoadModuleDependencies module list @@ -49,14 +63,16 @@ function adiosBuildAocc { amd_prefix=${amd_root}/${amd_version} adiosBuild ${amd_prefix} + + adiosUnloadModuleDependencies } function adiosBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} adiosLoadModuleDependencies module list @@ -66,14 +82,16 @@ function adiosBuildCray { cray_prefix=${cray_root}/${cray_version} adiosBuild ${cray_prefix} + + adiosUnloadModuleDependencies } function adiosBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} adiosLoadModuleDependencies module list @@ -83,6 +101,8 @@ function adiosBuildGnu { gnu_prefix=${gnu_root}/${gnu_version} adiosBuild ${gnu_prefix} + + adiosUnloadModuleDependencies } function adiosBuild { @@ -109,6 +129,34 @@ function adiosBuildMPI { } +function adiosInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/adios ]]; then + mkdir ${module_dir}/adios + fi + + local module_file=${module_dir}/adios/${ADIOS_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load adios/${ADIOS_VERSION} + + cc --cray-print-opts + + module unload adios + module unuse ${module_dir} +} + function adiosInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -153,7 +201,8 @@ function adiosTest { local module_use=$(moduleInstallDirectory) printf "Adios test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load adios/${ADIOS_VERSION} @@ -166,6 +215,7 @@ function adiosTest { make cd - + module unload adios } main diff --git a/archer2/libraries/adios/module_boilerplate.lua b/archer2/libraries/adios/module_boilerplate.lua new file mode 100755 index 0000000..8169160 --- /dev/null +++ b/archer2/libraries/adios/module_boilerplate.lua @@ -0,0 +1,166 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +-- setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +-- setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +-- setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +-- prepend_path("PE_PKGCONFIG_LIBS", productName) +-- prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + -- local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + -- prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + + -- bin is required + + prepend_path("PATH", pathJoin(productPath, "bin")) + +end + diff --git a/archer2/libraries/adios/module_preamble.lua b/archer2/libraries/adios/module_preamble.lua new file mode 100755 index 0000000..9372b80 --- /dev/null +++ b/archer2/libraries/adios/module_preamble.lua @@ -0,0 +1,22 @@ +-- Adios v1 preamble +-- Note Adios does not integrate with the compiler wrappers +-- see https://docs.archer2.ac.uk/software-libraries/adios/ + +family("adios") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") +depends_on("epcc-cray-hdf5-parallel/1.12.0.3") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "Adios version " .. productLevel .. "\n" +local help2 = "For details of Adios on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/adios/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/arpack-ng/build-arpack-ng.sh b/archer2/libraries/arpack-ng/build-arpack-ng.sh index 3042b04..775bc36 100644 --- a/archer2/libraries/arpack-ng/build-arpack-ng.sh +++ b/archer2/libraries/arpack-ng/build-arpack-ng.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/arpack-ng/${ARPACK_VERSION} + local install_root=${install_root_libs}/arpack-ng/${ARPACK_VERSION} ${build_amd} && arpackBuildAocc ${install_root} ${build_cce} && arpackBuildCray ${install_root} ${build_gnu} && arpackBuildGnu ${install_root} - arpackInstallModuleFile + arpackInstallModuleFileLua arpackInstallationTest ${install_root} printf "ARCHER2: Arpack installation test completed successfully\n" @@ -31,8 +31,10 @@ function arpackBuildAocc { local install_root=${1} # restore pe/compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} + module list amd_version=$(moduleToCompilerMajorMinor) @@ -46,8 +48,9 @@ function arpackBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} + module list cray_version=$(moduleToCompilerMajorMinor) @@ -61,8 +64,9 @@ function arpackBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} + module list gnu_version=$(moduleToCompilerMajorMinor) @@ -134,9 +138,6 @@ function arpackPackageConfigFiles { # Here we declare the necessary information required to generate # pkgconfig files - # Note PKGCONFIG file is "arpack" to simplify environment - # in module file - local prefix=${1} local prgEnv=$(peEnvLower) local ext="${prgEnv}" @@ -151,7 +152,36 @@ function arpackPackageConfigFiles { pcmap[requires]="parpack_${extmpi} arpack_${ext}" pcRefactorPackageConfigFiles ${prefix} pcmap - pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/arpack.pc" pcmap + pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/arpack_ng.pc" pcmap +} + +function arpackInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/arpack-ng ]]; then + mkdir ${module_dir}/arpack-ng + fi + + local module_file=${module_dir}/arpack-ng/${ARPACK_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load arpack-ng/${ARPACK_VERSION} + + cc --cray-print-opts + + module unload arpack-ng + module unuse ${module_dir} + } function arpackInstallModuleFile { @@ -196,7 +226,8 @@ function arpackTest { local version="${ARPACK_VERSION}" printf "Arpack-NG test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load arpack-ng/${version} diff --git a/archer2/libraries/arpack-ng/module_boilerplate.lua b/archer2/libraries/arpack-ng/module_boilerplate.lua new file mode 100755 index 0000000..17c5fb9 --- /dev/null +++ b/archer2/libraries/arpack-ng/module_boilerplate.lua @@ -0,0 +1,164 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_SUPERLU_DIST" as a convenience + +productName = string.gsub(productName, "-", "_") + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, string.gsub(productName, "_", "-"), productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/libraries/arpack-ng/module_preamble.lua b/archer2/libraries/arpack-ng/module_preamble.lua new file mode 100755 index 0000000..9b5c4fd --- /dev/null +++ b/archer2/libraries/arpack-ng/module_preamble.lua @@ -0,0 +1,19 @@ +-- ARPACK-NG preamble + +family("arpack_ng") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "ARPACK-NG version " .. productLevel .. "\n" +local help2 = "For details of ARPACK on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/arpack/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/boost/build-boost.sh b/archer2/libraries/boost/build-boost.sh index e95e488..4c7db67 100644 --- a/archer2/libraries/boost/build-boost.sh +++ b/archer2/libraries/boost/build-boost.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/boost/${BOOST_VERSION} + local install_root=${install_root_libs}/boost/${BOOST_VERSION} ${build_amd} && boostBuildAocc ${install_root} ${build_cce} && boostBuildCray ${install_root} ${build_gnu} && boostBuildGnu ${install_root} - boostInstallModuleFile + boostInstallModuleFileLua boostInstallationTest printf "ARCHER2: boost install/test complete\n" @@ -31,8 +31,10 @@ function boostBuildAocc { local install_root=${1} # restore pe/compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} + module list amd_version=$(moduleToCompilerMajorMinor) @@ -46,8 +48,9 @@ function boostBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} + module list cray_version=$(moduleToCompilerMajorMinor) @@ -61,8 +64,9 @@ function boostBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} + module list gnu_version=$(moduleToCompilerMajorMinor) @@ -129,7 +133,36 @@ function boostPackageConfigFile { # Order is important for link stage... pcmap[requires]="boost_coroutine boost_log_setup boost_log boost_timer boost_type_erasure boost_wave boost_atomic boost_chrono boost_container boost_fiber boost_context boost_contract boost_date_time boost_filesystem boost_graph_parallel boost_graph boost_mpi boost_iostreams boost_locale boost_math_c99f boost_math_c99l boost_math_c99 boost_math_tr1f boost_math_tr1l boost_math_tr1 boost_prg_exec_monitor boost_program_options boost_random boost_regex boost_wserialization boost_serialization boost_stacktrace_addr2line boost_stacktrace_basic boost_stacktrace_noop boost_system boost_thread boost_unit_test_framework boost_test_exec_monitor boost_exception" - pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/boost-cxx.pc" pcmap + pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/boost.pc" pcmap + +} + +function boostInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/boost ]]; then + mkdir ${module_dir}/boost + fi + + local module_file=${module_dir}/boost/${BOOST_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load boost/${BOOST_VERSION} + + cc --cray-print-opts + + module unload boost + module unuse ${module_dir} } @@ -174,7 +207,8 @@ function boostTest { local version=${BOOST_VERSION} printf "BOOST test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load boost/${version} diff --git a/archer2/libraries/boost/module_boilerplate.lua b/archer2/libraries/boost/module_boilerplate.lua new file mode 100755 index 0000000..ec4f844 --- /dev/null +++ b/archer2/libraries/boost/module_boilerplate.lua @@ -0,0 +1,162 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_CXX_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_CXX_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/libraries/boost/module_preamble.lua b/archer2/libraries/boost/module_preamble.lua new file mode 100755 index 0000000..432158b --- /dev/null +++ b/archer2/libraries/boost/module_preamble.lua @@ -0,0 +1,18 @@ +-- Boost preamble + +family("boost") +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "Boost version " .. productLevel .. "\n" +local help2 = "For details of Boost on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/boost/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/glm/build-glm.sh b/archer2/libraries/glm/build-glm.sh index ddd64dc..619ce2a 100644 --- a/archer2/libraries/glm/build-glm.sh +++ b/archer2/libraries/glm/build-glm.sh @@ -14,16 +14,16 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/glm/${GLM_VERSION} + local install_root=${install_root_libs}/glm/${GLM_VERSION} ${build_cce} && glmBuildCray ${install_root} ${build_gnu} && glmBuildGnu ${install_root} ${build_amd} && glmBuildAocc ${install_root} - glmInstallModuleFile + glmInstallModuleFileLua glmInstallationTest - printf "ARCHER2: glm install/test complete" + printf "ARCHER2: glm install/test complete\n" } function glmBuildAocc { @@ -31,8 +31,10 @@ function glmBuildAocc { local install_root=${1} # Restore PE/Compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} + module list amd_version=$(moduleToCompilerMajorMinor) @@ -46,8 +48,9 @@ function glmBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} + module list cray_version=$(moduleToCompilerMajorMinor) @@ -61,8 +64,9 @@ function glmBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} + module list gnu_version=$(moduleToCompilerMajorMinor) @@ -98,6 +102,36 @@ function glmBuildSerial { } +function glmInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/glm ]]; then + mkdir ${module_dir}/glm + fi + + local module_file=${module_dir}/glm/${GLM_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load glm/${GLM_VERSION} + + cc --cray-print-opts + + module unload glm + module unuse ${module_dir} + +} + + function glmInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -139,7 +173,8 @@ function glmTest { local version=${GLM_VERSION} printf "GLM test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load glm/${version} diff --git a/archer2/libraries/glm/module_boilerplate.lua b/archer2/libraries/glm/module_boilerplate.lua new file mode 100755 index 0000000..ec4f844 --- /dev/null +++ b/archer2/libraries/glm/module_boilerplate.lua @@ -0,0 +1,162 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_CXX_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_CXX_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/libraries/glm/module_preamble.lua b/archer2/libraries/glm/module_preamble.lua new file mode 100755 index 0000000..f7e84e4 --- /dev/null +++ b/archer2/libraries/glm/module_preamble.lua @@ -0,0 +1,19 @@ +-- GLM preamble + +family("glm") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "GLM version " .. productLevel .. "\n" +local help2 = "For details of GLM on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/glm/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/hypre/build-hypre.sh b/archer2/libraries/hypre/build-hypre.sh index 7a6ed16..b68efbf 100644 --- a/archer2/libraries/hypre/build-hypre.sh +++ b/archer2/libraries/hypre/build-hypre.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/hypre/${HYPRE_VERSION} + local install_root=${install_root_libs}/hypre/${HYPRE_VERSION} ${build_cce} && hypreBuildCray ${install_root} ${bluid_gnu} && hypreBuildGnu ${install_root} ${build_amd} && hypreBuildAocc ${install_root} - hypreInstallModuleFile + hypreInstallModuleFileLua hypreInstallationTest printf "ARCHER2: HYPRE install/test successful\n" @@ -31,8 +31,10 @@ function hypreBuildAocc { local install_root=${1} # Restore relevant PE/Compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} + module list amd_version=$(moduleToCompilerMajorMinor) @@ -46,8 +48,9 @@ function hypreBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} + module list cray_version=$(moduleToCompilerMajorMinor) @@ -61,8 +64,9 @@ function hypreBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} + module list gnu_version=$(moduleToCompilerMajorMinor) @@ -83,6 +87,9 @@ function hypreBuild { hypreBuildMPI ${prefix} hyprePackageConfigFiles ${prefix} + + # Remove any shared objects + rm -f ${prefix}/lib/lib*.so } function hypreClean { @@ -147,6 +154,36 @@ function hyprePackageConfigFiles { pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/hypre.pc" pcmap } +function hypreInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + local time_stamp=$(date) + + if [[ ! -d ${module_dir}/hypre ]]; then + mkdir ${module_dir}/hypre + fi + + local module_file=${module_dir}/hypre/${HYPRE_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load hypre/${HYPRE_VERSION} + + cc --cray-print-opts + + module unload hypre + module unuse ${module_dir} + +} + function hypreInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -185,7 +222,8 @@ function hypreTest { local module_use=$(moduleInstallDirectory) printf "Hypre test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load hypre/${HYPRE_VERSION} diff --git a/archer2/libraries/hypre/module_boilerplate.lua b/archer2/libraries/hypre/module_boilerplate.lua new file mode 100755 index 0000000..674338c --- /dev/null +++ b/archer2/libraries/hypre/module_boilerplate.lua @@ -0,0 +1,175 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP is available + +setenv(PE_PRODUCT .. "_OMP_REQUIRES", "") +setenv(PE_PRODUCT .. "_OMP_REQUIRES_openmp", "_mp") +setenv(PE_PRODUCT .. "_PKGCONFIG_VARIABLES", PE_PRODUCT .. "_OMP_REQUIRES_@openmp@") + + + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + + -- bin is required + + prepend_path("PATH", pathJoin(productPath, "bin")) + +end + diff --git a/archer2/libraries/hypre/module_preamble.lua b/archer2/libraries/hypre/module_preamble.lua new file mode 100755 index 0000000..065e41b --- /dev/null +++ b/archer2/libraries/hypre/module_preamble.lua @@ -0,0 +1,19 @@ +-- HYPRE preamble + +family("hypre") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "HYPRE version " .. productLevel .. "\n" +local help2 = "For details of HYPRE on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/hypre/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/matio/build-matio.sh b/archer2/libraries/matio/build-matio.sh index 7a3de24..663320c 100644 --- a/archer2/libraries/matio/build-matio.sh +++ b/archer2/libraries/matio/build-matio.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/matio/${MATIO_VERSION} + local install_root=${install_root_libs}/matio/${MATIO_VERSION} ${build_amd} && matioBuildAocc ${install_root} ${build_cce} && matioBuildCray ${install_root} ${build_gnu} && matioBuildGnu ${install_root} - matioInstallModuleFile + matioInstallModuleFileLua matioInstallationTest printf "ARCHER2: Matio installation was successful\n" @@ -31,8 +31,10 @@ function matioBuildAocc { local install_root=${1} # restore pe/compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} + module list amd_version=$(moduleToCompilerMajorMinor) @@ -46,8 +48,9 @@ function matioBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} + module list cray_version=$(moduleToCompilerMajorMinor) @@ -61,8 +64,9 @@ function matioBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} + module list gnu_version=$(moduleToCompilerMajorMinor) @@ -100,6 +104,38 @@ function matioBuildSerial { } +function matioInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/matio ]]; then + mkdir ${module_dir}/matio + fi + + local module_file=${module_dir}/matio/${MATIO_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + # Smoke test module + + module use ${module_dir} + module load matio/${MATIO_VERSION} + + cc --cray-print-opts + + module unload matio + module unuse ${module_dir} + + +} + function matioInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -140,7 +176,8 @@ function matioTest { local version=${MATIO_VERSION} printf "Matio test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load matio/${version} diff --git a/archer2/libraries/matio/module_boilerplate.lua b/archer2/libraries/matio/module_boilerplate.lua new file mode 100755 index 0000000..6bf4fa7 --- /dev/null +++ b/archer2/libraries/matio/module_boilerplate.lua @@ -0,0 +1,172 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP is not required + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + + -- bin is required + + prepend_path("PATH", pathJoin(productPath, "bin")) + + -- man pages available + + prepend_path("MANPATH", pathJoin(productPath, "share/man")) + +end + diff --git a/archer2/libraries/matio/module_preamble.lua b/archer2/libraries/matio/module_preamble.lua new file mode 100755 index 0000000..a088f22 --- /dev/null +++ b/archer2/libraries/matio/module_preamble.lua @@ -0,0 +1,19 @@ +-- Matio preamble + +family("matio") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "Matio version " .. productLevel .. "\n" +local help2 = "For details of Matio on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/matio/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/metis/build-metis.sh b/archer2/libraries/metis/build-metis.sh index 7e3036e..9561e69 100644 --- a/archer2/libraries/metis/build-metis.sh +++ b/archer2/libraries/metis/build-metis.sh @@ -18,13 +18,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/metis/${METIS_VERSION} + local install_root=${install_root_libs}/metis/${METIS_VERSION} ${build_cce} && metisBuildCray ${install_root} ${build_gnu} && metisBuildGnu ${install_root} ${build_amd} && metisBuildAocc ${install_root} - metisInstallModuleFile + metisInstallModuleFileLua metisInstallationTest } @@ -33,8 +33,10 @@ function metisBuildAocc { local install_root=${1} # restore modules - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} + module list # use currently loaded compiler @@ -49,8 +51,9 @@ function metisBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} + module list cray_version=$(moduleToCompilerMajorMinor) @@ -64,8 +67,9 @@ function metisBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} + module list gnu_version=$(moduleToCompilerMajorMinor) @@ -160,6 +164,36 @@ function metisPackageConfigFiles { } +function metisInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/metis ]]; then + mkdir ${module_dir}/metis + fi + + local module_file=${module_dir}/metis/${METIS_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + # Smoke test module + + module use ${module_dir} + module load metis/${METIS_VERSION} + + cc --cray-print-opts + + module unload metis + module unuse ${module_dir} +} + function metisInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -202,7 +236,7 @@ function metisTest { printf "Metis installation test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + module load ${prgenv} module use ${module_use} module load metis/${METIS_VERSION} @@ -227,6 +261,8 @@ function metisTest { m2gmetis ${graph_dir}/metis.mesh /dev/null cd - + module unload metis + module unuse ${module_use} } main diff --git a/archer2/libraries/metis/module_boilerplate.lua b/archer2/libraries/metis/module_boilerplate.lua new file mode 100755 index 0000000..2db22e5 --- /dev/null +++ b/archer2/libraries/metis/module_boilerplate.lua @@ -0,0 +1,176 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP is available + +setenv(PE_PRODUCT .. "_OMP_REQUIRES", "") +setenv(PE_PRODUCT .. "_OMP_REQUIRES_openmp", "_mp") +setenv(PE_PRODUCT .. "_PKGCONFIG_VARIABLES", PE_PRODUCT .. "_OMP_REQUIRES_@openmp@") + + + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + prepend_path("PKG_CONFIG_PATH", pkgconfig) + + -- bin is required + + prepend_path("PATH", pathJoin(productPath, "bin")) + +end + diff --git a/archer2/libraries/metis/module_preamble.lua b/archer2/libraries/metis/module_preamble.lua new file mode 100755 index 0000000..a76e806 --- /dev/null +++ b/archer2/libraries/metis/module_preamble.lua @@ -0,0 +1,18 @@ +-- Metis preamble + +family("metis") +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "Metis version " .. productLevel .. "\n" +local help2 = "For details of Metis on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/metis/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/mumps/build-mumps.sh b/archer2/libraries/mumps/build-mumps.sh index 6c78fc4..25216a4 100644 --- a/archer2/libraries/mumps/build-mumps.sh +++ b/archer2/libraries/mumps/build-mumps.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/mumps/${MUMPS_VERSION} + local install_root=${install_root_libs}/mumps/${MUMPS_VERSION} ${build_cce} && mumpsBuildCray ${install_root} ${build_gnu} && mumpsBuildGnu ${install_root} ${build_amd} && mumpsBuildAocc ${install_root} - mumpsInstallModuleFile + mumpsInstallModuleFileLua mumpsInstallationTest printf "ARCHER2: MUMPS installation/test complete\n" @@ -31,8 +31,9 @@ function mumpsBuildAocc { local install_root=${1} # Restore relevant PE/Compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} moduleUseLibs module load parmetis/${PARMETIS_VERSION} @@ -44,14 +45,16 @@ function mumpsBuildAocc { amd_prefix=${amd_root}/${amd_version} mumpsBuild ${amd_prefix} + + module unload scotch parmetis } function mumpsBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} moduleUseLibs module load parmetis/${PARMETIS_VERSION} @@ -63,14 +66,16 @@ function mumpsBuildCray { cray_prefix=${cray_root}/${cray_version} mumpsBuild ${cray_prefix} + + module unload scotch parmetis } function mumpsBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} moduleUseLibs module load parmetis/${PARMETIS_VERSION} @@ -82,6 +87,8 @@ function mumpsBuildGnu { gnu_prefix=${gnu_root}/${gnu_version} mumpsBuild ${gnu_prefix} + + module unload scotch parmetis } function mumpsBuild { @@ -172,6 +179,35 @@ function mumpsPackageConfigFiles { pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/mumps.pc" pcmap } +function mumpsInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/mumps ]]; then + mkdir ${module_dir}/mumps + fi + + local module_file=${module_dir}/mumps/${MUMPS_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load mumps/${MUMPS_VERSION} + + cc --cray-print-opts + + module unload mumps + module unuse ${module_dir} + +} + function mumpsInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -214,7 +250,8 @@ function mumpsTest { local prgenv=${1} printf "Mumps test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} moduleUseLibs module load mumps/${MUMPS_VERSION} @@ -239,5 +276,3 @@ function mumpsTest { } main - -return 0 diff --git a/archer2/libraries/mumps/module_boilerplate.lua b/archer2/libraries/mumps/module_boilerplate.lua new file mode 100755 index 0000000..7986b15 --- /dev/null +++ b/archer2/libraries/mumps/module_boilerplate.lua @@ -0,0 +1,171 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP is available + +setenv(PE_PRODUCT .. "_OMP_REQUIRES", "") +setenv(PE_PRODUCT .. "_OMP_REQUIRES_openmp", "_mp") +setenv(PE_PRODUCT .. "_PKGCONFIG_VARIABLES", PE_PRODUCT .. "_OMP_REQUIRES_@openmp@") + + + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/libraries/mumps/module_preamble.lua b/archer2/libraries/mumps/module_preamble.lua new file mode 100755 index 0000000..2a4fd79 --- /dev/null +++ b/archer2/libraries/mumps/module_preamble.lua @@ -0,0 +1,22 @@ +-- MUMPS preamble + +family("mumps") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") +depends_on("metis/5.1.0") +depends_on("parmetis/4.0.3") +depends_on("scotch/6.1.0") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "MUMPS version " .. productLevel .. "\n" +local help2 = "For details of MUMPS on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/mumps/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/parmetis/build-parmetis.sh b/archer2/libraries/parmetis/build-parmetis.sh index 1a65949..c26e4fb 100644 --- a/archer2/libraries/parmetis/build-parmetis.sh +++ b/archer2/libraries/parmetis/build-parmetis.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/parmetis/${PARMETIS_VERSION} + local install_root=${install_root_libs}/parmetis/${PARMETIS_VERSION} ${build_cce} && parmetisBuildCray ${install_root} ${build_gnu} && parmetisBuildGnu ${install_root} ${build_amd} && parmetisBuildAocc ${install_root} - parmetisInstallModuleFile + parmetisInstallModuleFileLua parmetisInstallationTest } @@ -29,8 +29,9 @@ function parmetisBuildAocc { local install_root=${1} # Restore relevant PE/Compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} moduleUseLibs module load metis/${METIS_VERSION} @@ -41,14 +42,16 @@ function parmetisBuildAocc { amd_prefix=${amd_root}/${amd_version} parmetisBuild ${amd_prefix} + + module unload metis } function parmetisBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} moduleUseLibs module load metis/${METIS_VERSION} @@ -59,14 +62,16 @@ function parmetisBuildCray { cray_prefix=${cray_root}/${cray_version} parmetisBuild ${cray_prefix} + + module unload metis } function parmetisBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} moduleUseLibs module load metis/${METIS_VERSION} @@ -77,6 +82,8 @@ function parmetisBuildGnu { gnu_prefix=${gnu_root}/${gnu_version} parmetisBuild ${gnu_prefix} + + module unload metis } function parmetisBuild { @@ -153,6 +160,34 @@ function parmetisPackageConfigFiles { pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/parmetis.pc" pcmap } +function parmetisInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/parmetis ]]; then + mkdir ${module_dir}/parmetis + fi + + local module_file=${module_dir}/parmetis/${PARMETIS_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load parmetis/${PARMETIS_VERSION} + + cc --cray-print-opts + + module unload parmetis + module unuse ${module_dir} +} + function parmetisInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -196,7 +231,8 @@ function parmetisTest { local module_use=$(moduleInstallDirectory) printf "Parmetis test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load parmetis/${PARMETIS_VERSION} @@ -210,6 +246,7 @@ function parmetisTest { slurmAllocRun "srun -n 3 ./a.out" cd - + module unload parmetis } main diff --git a/archer2/libraries/parmetis/module_boilerplate.lua b/archer2/libraries/parmetis/module_boilerplate.lua new file mode 100755 index 0000000..02aedfa --- /dev/null +++ b/archer2/libraries/parmetis/module_boilerplate.lua @@ -0,0 +1,176 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP is available + +setenv(PE_PRODUCT .. "_OMP_REQUIRES", "") +setenv(PE_PRODUCT .. "_OMP_REQUIRES_openmp", "_mp") +setenv(PE_PRODUCT .. "_PKGCONFIG_VARIABLES", PE_PRODUCT .. "_OMP_REQUIRES_@openmp@") + + + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + prepend_path("PKG_CONFIG_PATH", pkgconfig) + + -- bin is required + + prepend_path("PATH", pathJoin(productPath, "bin")) + +end + diff --git a/archer2/libraries/parmetis/module_preamble.lua b/archer2/libraries/parmetis/module_preamble.lua new file mode 100755 index 0000000..3fbd32b --- /dev/null +++ b/archer2/libraries/parmetis/module_preamble.lua @@ -0,0 +1,20 @@ +-- Parmetis preamble + +family("parmetis") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") +depends_on("metis/5.1.0") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "Parmetis version " .. productLevel .. "\n" +local help2 = "For details of Metis and Parmetis on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/metis/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/petsc/build-petsc.sh b/archer2/libraries/petsc/build-petsc.sh index a680219..4ab3253 100644 --- a/archer2/libraries/petsc/build-petsc.sh +++ b/archer2/libraries/petsc/build-petsc.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/petsc/${PETSC_VERSION} + local install_root=${install_root_libs}/petsc/${PETSC_VERSION} ${build_cce} && petscBuildCray ${install_root} ${build_gnu} && petscBuildGnu ${install_root} ${build_amd} && petscBuildAocc ${install_root} - petscInstallModuleFile + petscInstallModuleFileLua petscInstallationTest printf "ARCHER2: PETSC install/test complete\n" @@ -29,23 +29,35 @@ function main { function petscLoadModuleDependencies { moduleUseLibs - module load cray-hdf5-parallel/${CRAY_HDF5_PARALLEL_VERSION} - module load parmetis/${PARMETIS_VERSION} + + # Pending AOCC pkgconfig fix... + #module load cray-hdf5-parallel/${CRAY_HDF5_PARALLEL_VERSION} + module load epcc-cray-hdf5-parallel/${CRAY_HDF5_PARALLEL_VERSION} module load hypre/${HYPRE_VERSION} - module load scotch/${SCOTCH_VERSION} module load mumps/${MUMPS_VERSION} module load superlu/${SUPERLU_VERSION} module load superlu-dist/${SUPERLUDIST_VERSION} } +function petscUnloadModuleDependencies { + + module unload epcc-cray-hdf5-parallel/${CRAY_HDF5_PARALLEL_VERSION} + #module unload cray-hdf5-parallel/${CRAY_HDF5_PARALLEL_VERSION} + module unload hypre/${HYPRE_VERSION} + module unload mumps/${MUMPS_VERSION} + module unload superlu/${SUPERLU_VERSION} + module unload superlu-dist/${SUPERLUDIST_VERSION} + +} + function petscBuildAocc { local install_root=${1} # restore pe/compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} petscLoadModuleDependencies module list @@ -55,14 +67,16 @@ function petscBuildAocc { amd_prefix=${amd_root}/${amd_version} petscBuild ${amd_prefix} + + petscUnloadModuleDependencies } function petscBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} petscLoadModuleDependencies module list @@ -73,19 +87,22 @@ function petscBuildCray { petscBuild ${cray_prefix} + petscUnloadModuleDependencies + # Package config file # The Cflags: argument has -Wno-unused-command-line-argument # which will crash Fortran, so remove it. sed -i 's/^Cflags.*/Cflags: -I${includedir}/' ${cray_prefix}/lib/pkgconfig/petsc.pc + } function petscBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} petscLoadModuleDependencies module list @@ -95,6 +112,8 @@ function petscBuildGnu { gnu_prefix=${gnu_root}/${gnu_version} petscBuild ${gnu_prefix} + + petscUnloadModuleDependencies } function petscBuild { @@ -128,6 +147,35 @@ function petscBuildMPIOpenMP { --version=${PETSC_VERSION} } +function petscInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/petsc ]]; then + mkdir ${module_dir}/petsc + fi + + local module_file=${module_dir}/petsc/${PETSC_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load petsc/${PETSC_VERSION} + + cc --cray-print-opts + + module unload petsc + module unuse ${module_dir} + +} + function petscInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -177,7 +225,7 @@ function petscTest { local module_use=$(moduleInstallDirectory) printf "Petsc test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + module load ${prgenv} module use ${module_use} module load petsc/${PETSC_VERSION} diff --git a/archer2/libraries/petsc/module_boilerplate.lua b/archer2/libraries/petsc/module_boilerplate.lua new file mode 100755 index 0000000..0fb8b4a --- /dev/null +++ b/archer2/libraries/petsc/module_boilerplate.lua @@ -0,0 +1,165 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP is not required + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/libraries/petsc/module_preamble.lua b/archer2/libraries/petsc/module_preamble.lua new file mode 100755 index 0000000..8112374 --- /dev/null +++ b/archer2/libraries/petsc/module_preamble.lua @@ -0,0 +1,26 @@ +-- PETSc preamble + +family("petsc") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +depends_on("epcc-cray-hdf5-parallel/1.12.0.3") +depends_on("hypre/2.18.0") +depends_on("mumps/5.3.5") +depends_on("superlu/5.2.2") +depends_on("superlu-dist/6.4.0") + + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "PETSc version " .. productLevel .. "\n" +local help2 = "For details of PETSc on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/petsc/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/scotch/build-scotch.sh b/archer2/libraries/scotch/build-scotch.sh index b622918..8d45ef2 100644 --- a/archer2/libraries/scotch/build-scotch.sh +++ b/archer2/libraries/scotch/build-scotch.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/scotch/${SCOTCH_VERSION} + local install_root=${install_root_libs}/scotch/${SCOTCH_VERSION} ${build_amd} && scotchBuildAocc ${install_root} ${build_cce} && scotchBuildCray ${install_root} ${build_gnu} && scotchBuildGnu ${install_root} - scotchInstallModuleFile + scotchInstallModuleFileLua scotchInstallationTest ${install_root} printf "ARCHER2: Scotch installation test completed successfully\n" @@ -31,8 +31,9 @@ function scotchBuildAocc { local install_root=${1} # Restore relevant PE/Compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} module list amd_version=$(moduleToCompilerMajorMinor) @@ -46,8 +47,9 @@ function scotchBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} + module list cray_version=$(moduleToCompilerMajorMinor) @@ -61,8 +63,9 @@ function scotchBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} + module list gnu_version=$(moduleToCompilerMajorMinor) @@ -155,6 +158,35 @@ function scotchPackageConfigFiles { pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/scotch.pc" pcmap } +function scotchInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/scotch ]]; then + mkdir ${module_dir}/scotch + fi + + local module_file=${module_dir}/scotch/${SCOTCH_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load scotch/${SCOTCH_VERSION} + + cc --cray-print-opts + + module unload scotch + module unuse ${module_dir} + +} + function scotchInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -197,7 +229,8 @@ function scotchTest { local version="${SCOTCH_VERSION}" printf "Scotch test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load scotch/${version} @@ -234,5 +267,3 @@ function scotchTest { } main - -return 0 diff --git a/archer2/libraries/scotch/module_boilerplate.lua b/archer2/libraries/scotch/module_boilerplate.lua new file mode 100755 index 0000000..7b6cb38 --- /dev/null +++ b/archer2/libraries/scotch/module_boilerplate.lua @@ -0,0 +1,169 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP not required + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + + -- bin is required + + prepend_path("PATH", pathJoin(productPath, "bin")) + +end + diff --git a/archer2/libraries/scotch/module_preamble.lua b/archer2/libraries/scotch/module_preamble.lua new file mode 100755 index 0000000..363faf4 --- /dev/null +++ b/archer2/libraries/scotch/module_preamble.lua @@ -0,0 +1,19 @@ +-- Scotch preamble + +family("scotch") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "Scotch version " .. productLevel .. "\n" +local help2 = "For details of Scotch on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/scotch/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/slepc/build-slepc.sh b/archer2/libraries/slepc/build-slepc.sh index 9977db9..7ef20cd 100644 --- a/archer2/libraries/slepc/build-slepc.sh +++ b/archer2/libraries/slepc/build-slepc.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/slepc/${SLEPC_VERSION} + local install_root=${install_root_libs}/slepc/${SLEPC_VERSION} ${build_cce} && slepcBuildCray ${install_root} ${build_gnu} && slepcBuildGnu ${install_root} ${build_amd} && slepcBuildAocc ${install_root} - slepcInstallModuleFile + slepcInstallModuleFileLua slepcInstallationTest printf "ARCHER2: successful installation and test of SLEPc\n" @@ -33,12 +33,18 @@ function slepcLoadModuleDependencies { } +function slepcUnloadModuleDependencies { + + module unload petsc + +} + function slepcBuildAocc { local install_root=${1} - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} slepcLoadModuleDependencies module list @@ -48,14 +54,16 @@ function slepcBuildAocc { amd_prefix=${amd_root}/${amd_version} slepcBuild ${amd_prefix} + + slepcUnloadModuleDependencies } function slepcBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} slepcLoadModuleDependencies module list @@ -66,6 +74,8 @@ function slepcBuildCray { slepcBuild ${cray_prefix} + slepcUnloadModuleDependencies + # Package config file # The Cflags: argument has -Wno-unused-command-line-argument # which will crash Fortran, so remove it. @@ -77,8 +87,8 @@ function slepcBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} slepcLoadModuleDependencies module list @@ -88,6 +98,8 @@ function slepcBuildGnu { gnu_prefix=${gnu_root}/${gnu_version} slepcBuild ${gnu_prefix} + + slepcUnloadModuleDependencies } function slepcBuild { @@ -160,6 +172,35 @@ function slepcPackageConfigFiles { } +function slepcInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/slepc ]]; then + mkdir ${module_dir}/slepc + fi + + local module_file=${module_dir}/slepc/${SLEPC_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load slepc/${SLEPC_VERSION} + + cc --cray-print-opts + + module unload slepc + module unuse ${module_dir} + +} + function slepcInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -182,7 +223,11 @@ function slepcInstallModuleFile { # Ensure this has worked module use ${module_dir} module load slepc/${SLEPC_VERSION} + + cc --cray-print-opts + module unload slepc + module unuse ${module_dir} } function slepcInstallationTest { @@ -198,7 +243,8 @@ function slepcTest { local module_use=$(moduleInstallDirectory) printf "Slepc test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load slepc/${SLEPC_VERSION} diff --git a/archer2/libraries/slepc/module_boilerplate.lua b/archer2/libraries/slepc/module_boilerplate.lua new file mode 100755 index 0000000..0fb8b4a --- /dev/null +++ b/archer2/libraries/slepc/module_boilerplate.lua @@ -0,0 +1,165 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP is not required + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/libraries/slepc/module_preamble.lua b/archer2/libraries/slepc/module_preamble.lua new file mode 100755 index 0000000..7241ae4 --- /dev/null +++ b/archer2/libraries/slepc/module_preamble.lua @@ -0,0 +1,20 @@ +-- SLEPc preamble + +family("slepc") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") +depends_on("petsc/3.14.2") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "SLEPc version " .. productLevel .. "\n" +local help2 = "For details of SLEPc on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/slepc/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/superlu-dist/build-superlu-dist.sh b/archer2/libraries/superlu-dist/build-superlu-dist.sh index 5b62005..6b45c8d 100644 --- a/archer2/libraries/superlu-dist/build-superlu-dist.sh +++ b/archer2/libraries/superlu-dist/build-superlu-dist.sh @@ -14,13 +14,13 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/superlu-dist/${SUPERLUDIST_VERSION} + local install_root=${install_root_libs}/superlu-dist/${SUPERLUDIST_VERSION} ${build_amd} && superludistBuildAocc ${install_root} ${build_cce} && superludistBuildCray ${install_root} ${build_gnu} && superludistBuildGnu ${install_root} - superludistInstallModuleFile + superludistInstallModuleFileLua superludistInstallationTest printf "ARCHER2: Test and installation of SuperLU_DIST complete\n" @@ -31,8 +31,9 @@ function superludistBuildAocc { local install_root=${1} # Restore relevant PE/Compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} moduleUseLibs module load parmetis/${PARMETIS_VERSION} @@ -44,14 +45,16 @@ function superludistBuildAocc { amd_prefix=${amd_root}/${amd_version} superludistBuild ${amd_prefix} + + module unload parmetis } function superludistBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} moduleUseLibs module load parmetis/${PARMETIS_VERSION} @@ -63,14 +66,16 @@ function superludistBuildCray { cray_prefix=${cray_root}/${cray_version} superludistBuild ${cray_prefix} + + module unload parmetis } function superludistBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} moduleUseLibs module load parmetis/${PARMETIS_VERSION} @@ -82,6 +87,8 @@ function superludistBuildGnu { gnu_prefix=${gnu_root}/${gnu_version} superludistBuild ${gnu_prefix} + + module unload parmetis } function superludistBuild { @@ -166,6 +173,35 @@ function superludistPackageConfigFiles { pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/superlu_dist.pc" pcmap } +function superludistInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/superlu-dist ]]; then + mkdir ${module_dir}/superlu-dist + fi + + local module_file=${module_dir}/superlu-dist/${SUPERLUDIST_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load superlu-dist/${SUPERLUDIST_VERSION} + + cc --cray-print-opts + + module unload superlu-dist + module unuse ${module_dir} + +} + function superludistInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -208,7 +244,8 @@ function superludistTest { local version="${SUPERLUDIST_VERSION}" printf "SuperLU test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} moduleUseLibs module load superlu-dist/${version} diff --git a/archer2/libraries/superlu-dist/module_boilerplate.lua b/archer2/libraries/superlu-dist/module_boilerplate.lua new file mode 100755 index 0000000..e8c92a2 --- /dev/null +++ b/archer2/libraries/superlu-dist/module_boilerplate.lua @@ -0,0 +1,173 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_SUPERLU_DIST" as a convenience + +productName = string.gsub(productName, "-", "_") + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP is available + +setenv(PE_PRODUCT .. "_OMP_REQUIRES", "") +setenv(PE_PRODUCT .. "_OMP_REQUIRES_openmp", "_mp") +setenv(PE_PRODUCT .. "_PKGCONFIG_VARIABLES", PE_PRODUCT .. "_OMP_REQUIRES_@openmp@") + + + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, string.gsub(productName, "_", "-"), productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/libraries/superlu-dist/module_preamble.lua b/archer2/libraries/superlu-dist/module_preamble.lua new file mode 100755 index 0000000..fa0a398 --- /dev/null +++ b/archer2/libraries/superlu-dist/module_preamble.lua @@ -0,0 +1,21 @@ +-- SuperLU-DIST preamble + +family("superlu_dist") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") +depends_on("metis/5.1.0") +depends_on("parmetis/4.0.3") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "SuperLU_DIST version " .. productLevel .. "\n" +local help2 = "For details of SuperLU_DIST on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/superlu/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/superlu/build-superlu.sh b/archer2/libraries/superlu/build-superlu.sh index 9d3f289..bc8211e 100644 --- a/archer2/libraries/superlu/build-superlu.sh +++ b/archer2/libraries/superlu/build-superlu.sh @@ -14,14 +14,15 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/superlu/${SUPERLU_VERSION} + local install_root=${install_root_libs}/superlu/${SUPERLU_VERSION} ${build_amd} && superluBuildAocc ${install_root} ${build_cce} && superluBuildCray ${install_root} ${build_gnu} && superluBuildGnu ${install_root} - superluInstallModuleFile + superluInstallModuleFileLua superluInstallationTest + printf "ARCHER2: installation (and test) of superlu successful\n" } @@ -30,8 +31,10 @@ function superluBuildAocc { local install_root=${1} # Restore relavant PE/Compiler - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} + module list amd_version=$(moduleToCompilerMajorMinor) @@ -45,8 +48,9 @@ function superluBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} + module list cray_version=$(moduleToCompilerMajorMinor) @@ -60,8 +64,9 @@ function superluBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} + module list gnu_version=$(moduleToCompilerMajorMinor) @@ -129,6 +134,35 @@ function superluPackageConfigFiles { pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/superlu.pc" pcmap } +function superluInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/superlu ]]; then + mkdir ${module_dir}/superlu + fi + + local module_file=${module_dir}/superlu/${SUPERLU_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load superlu/${SUPERLU_VERSION} + + cc --cray-print-opts + + module unload superlu + module unuse ${module_dir} + +} + function superluInstallModuleFile { local module_template=${script_dir}/modulefile.tcl @@ -170,7 +204,8 @@ function superluTest { local version=${SUPERLU_VERSION} printf "Superlu test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load superlu/${version} diff --git a/archer2/libraries/superlu/module_boilerplate.lua b/archer2/libraries/superlu/module_boilerplate.lua new file mode 100755 index 0000000..05cb37b --- /dev/null +++ b/archer2/libraries/superlu/module_boilerplate.lua @@ -0,0 +1,164 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP is not required + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/libraries/superlu/module_preamble.lua b/archer2/libraries/superlu/module_preamble.lua new file mode 100755 index 0000000..9bfe46d --- /dev/null +++ b/archer2/libraries/superlu/module_preamble.lua @@ -0,0 +1,19 @@ +-- SuperLU preamble + +family("superlu") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "SuperLU version " .. productLevel .. "\n" +local help2 = "For details of SuperLU on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/superlu/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/libraries/trilinos/build-trilinos.sh b/archer2/libraries/trilinos/build-trilinos.sh index 04f4f24..5f1de08 100644 --- a/archer2/libraries/trilinos/build-trilinos.sh +++ b/archer2/libraries/trilinos/build-trilinos.sh @@ -14,24 +14,23 @@ function main { # Overall prefix must be supplied by command line - local install_root=${prefix}/libs/trilinos/${TRILINOS_VERSION} + local install_root=${install_root_libs}/trilinos/${TRILINOS_VERSION} ${build_amd} && trilinosBuildAocc ${install_root} ${build_cce} && trilinosBuildCray ${install_root} ${build_gnu} && trilinosBuildGnu ${install_root} - trilinosInstallModuleFile + trilinosInstallModuleFileLua trilinosInstallationTest } function trilinosLoadModuleDependencies { moduleUseLibs - module load cray-hdf5-parallel - module load cray-netcdf-hdf5parallel + + module load epcc-cray-hdf5-parallel + module load epcc-cray-netcdf-hdf5parallel - module load parmetis/${PARMETIS_VERSION} - module load scotch/${SCOTCH_VERSION} module load mumps/${MUMPS_VERSION} module load superlu/${SUPERLU_VERSION} module load superlu-dist/${SUPERLUDIST_VERSION} @@ -40,12 +39,25 @@ function trilinosLoadModuleDependencies { module load boost/${BOOST_VERSION} } +function trilinosUnloadModuleDependencies { + + module unload boost + module unload glm + module unload matio + module unload superlu-dist + module unload superlu + module unload mumps + + module unload epcc-cray-netcdf-hdf5parallel + module unload epcc-cray-hdf5-parallel +} + function trilinosBuildAocc { local install_root=${1} - module restore $(moduleCollection PrgEnv-aocc) - module swap aocc aocc/${PE_AOCC_AOCC_VERSION} + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} trilinosLoadModuleDependencies module list @@ -55,14 +67,16 @@ function trilinosBuildAocc { amd_prefix=${amd_root}/${amd_version} trilinosBuild ${amd_prefix} + + trilinosUnloadModuleDependencies } function trilinosBuildCray { local install_root=${1} - module restore $(moduleCollection PrgEnv-cray) - module swap cce cce/${PE_CRAY_CCE_VERSION} + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} trilinosLoadModuleDependencies module list @@ -72,14 +86,16 @@ function trilinosBuildCray { cray_prefix=${cray_root}/${cray_version} trilinosBuild ${cray_prefix} + + trilinosUnloadModuleDependencies } function trilinosBuildGnu { local install_root=${1} - module restore $(moduleCollection PrgEnv-gnu) - module swap gcc gcc/${PE_GNU_GCC_VERSION} + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} trilinosLoadModuleDependencies module list @@ -89,6 +105,8 @@ function trilinosBuildGnu { gnu_prefix=${gnu_root}/${gnu_version} trilinosBuild ${gnu_prefix} + + trilinosUnloadModuleDependencies } function trilinosBuild { @@ -134,8 +152,38 @@ function trilinosPackageConfigFile { # reported by the build system. A better way ... pcmap[requires]="piro trilinoscouplings stokhos_muelu stokhos_ifpack2 stokhos_amesos2_mp_16_openmp stokhos_amesos2 stokhos_xpetra stokhos_tpetra stokhos_sacado stokhos shylu_ddbddc rol shylu_ddfrosch muelu-adapters locaepetra locathyra localapack muelu-interface loca muelu noxepetra noxlapack nox teko ifpack2-adapters ifpack2 stratimikos fei_trilinos fei_base stratimikosamesos2 stratimikosml stratimikosaztecoo stratimikosamesos ModeLaplace stratimikosbelos stratimikosifpack anasazitpetra anasaziepetra anasazi belostpetra stk_balance_lib belosxpetra belosepetra moertel belos ml stk_balance_test_utils zoltan2 galeri-epetra galeri-xpetra xpetra-sup amesos2 xpetra optipack stk_tools_lib thyratpetra stk_transfer_utils_lib tpetrainout tpetraext stk_transfer_impl stk_search_util_base tpetra kokkostsqr stk_search kokkoskernels ifpack stk_mesh_fixtures stk_unit_test_utils thyraepetraext stk_io_util isorropia amesos stk_io epetraext thyraepetra rythmos stk_ngp Ionit stk_mesh_base Ioexo_fac Iofx komplex triutils aztecoo thyracore dpliris io_info_lib Iogn Iogs Iotr Iohb epetra Ioex Iovs Iopg Ioss phalanx stk_expreval intrepid globipack sacado tpetraclassicnodeapi rtop stk_topology tpetraclassiclinalg tpetraclassic teuchosnumerics stk_util_diag teuchoskokkoscomm teuchoscomm stk_util_env teuchoskokkoscompat stk_util_parallel stk_util_command_line teuchosparameterlist mapvarlib stk_util_util stk_util_registry zoltan aprepro_lib exodus_for exoIIv2for32 nemesis teuchosparser exodus pamgen teuchosremainder chaco teuchoscore suplib stk_ngp_test trilinosss kokkosalgorithms kokkoscontainers gtest stk_math kokkoscore suplib_cpp supes shards pamgen_extras suplib_c" - pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/trilinos-cxx.pc" pcmap - # Fortran? + pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/trilinos.pc" pcmap +} + +function trilinosInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectory) + + if [[ ! -d ${module_dir}/trilinos ]]; then + mkdir ${module_dir}/trilinos + fi + + local module_file=${module_dir}/trilinos/${TRILINOS_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + # Smoke test module file + + module use ${module_dir} + module load trilinos/${TRILIONS_VERSION} + + cc --cray-print-opts + + module unload trilinos + module unuse ${module_dir} + } function trilinosInstallModuleFile { @@ -188,7 +236,8 @@ function trilinosTest { local module_use=$(moduleInstallDirectory) printf "Trilinos test for %s\n" "${prgenv}" - module restore $(moduleCollection ${prgenv}) + + module load ${prgenv} module use ${module_use} module load trilinos/${TRILINOS_VERSION} diff --git a/archer2/libraries/trilinos/module_boilerplate.lua b/archer2/libraries/trilinos/module_boilerplate.lua new file mode 100755 index 0000000..b87e526 --- /dev/null +++ b/archer2/libraries/trilinos/module_boilerplate.lua @@ -0,0 +1,167 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/libs/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "libs/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/libs/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_CXX_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_CXX_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + +-- Fortran + +setenv(PE_PRODUCT .. "_FORTRAN_PKGCONFIG_LIBS", productName) +prepend_path("PE_FORTRAN_PKGCONFIG_LIBS", productName) + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/libraries/trilinos/module_preamble.lua b/archer2/libraries/trilinos/module_preamble.lua new file mode 100755 index 0000000..3f2ec30 --- /dev/null +++ b/archer2/libraries/trilinos/module_preamble.lua @@ -0,0 +1,28 @@ +-- Trilinos preamble + +family("trilinos") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +depends_on("glm/0.9.9.6") +depends_on("boost/1.72.0") +depends_on("matio/1.5.18") +depends_on("mumps/5.3.5") +depends_on("superlu/5.2.2") +depends_on("superlu-dist/6.4.0") +depends_on("epcc-cray-hdf5-parallel/1.12.0.3") +depends_on("epcc-cray-netcdf-hdf5parallel") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "Trilinos version " .. productLevel .. "\n" +local help2 = "For details of Trilinos on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/software-libraries/trilinos/" + +help ( help1 .. help2 .. help3 ) + diff --git a/archer2/module/21.04/defaults.sh b/archer2/module/21.04/defaults.sh index 7ef917e..a6a8645 100644 --- a/archer2/module/21.04/defaults.sh +++ b/archer2/module/21.04/defaults.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Programming environment defaults at April 2021 (16+cabinet). +# Programming environment defaults at October 2021 (23+cabinet). PE_CPE_VERSION=21.04 diff --git a/archer2/module/epcc-cray-hdf5-parallel/.version b/archer2/module/epcc-cray-hdf5-parallel/.version new file mode 100644 index 0000000..d0c8246 --- /dev/null +++ b/archer2/module/epcc-cray-hdf5-parallel/.version @@ -0,0 +1,2 @@ +#%Module +set ModulesVersion "1.12.0.3" diff --git a/archer2/module/epcc-cray-hdf5-parallel/1.12.0.3.lua b/archer2/module/epcc-cray-hdf5-parallel/1.12.0.3.lua new file mode 100755 index 0000000..68e4fad --- /dev/null +++ b/archer2/module/epcc-cray-hdf5-parallel/1.12.0.3.lua @@ -0,0 +1,144 @@ +-- Patch up cray-hdf5-parallel +-- Handle PE_ENV correctly to set pkgconfig stuff + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +depends_on("cray-hdf5-parallel/1.12.0.3") + +-- Help section + +help ( "Kludge-o-matic for cray-hdf5-parallel" ) + + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + + +local productName = "hdf5-parallel" +local productLevel = os.getenv("CRAY_HDF5_PARALLEL_VERSION") + +local sharedRoot = "/opt/cray/pe" + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + -- prepend_path("HDF5_PARALLEL_DIR", productPath) + -- prepend_path("HDF5_PARALLEL_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/module/epcc-cray-hdf5-parallel/1.12.0.7.lua b/archer2/module/epcc-cray-hdf5-parallel/1.12.0.7.lua new file mode 100755 index 0000000..c503987 --- /dev/null +++ b/archer2/module/epcc-cray-hdf5-parallel/1.12.0.7.lua @@ -0,0 +1,144 @@ +-- Patch up cray-hdf5-parallel +-- Handle PE_ENV correctly to set pkgconfig stuff + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +depends_on("cray-hdf5-parallel/1.12.0.7") + +-- Help section + +help ( "Kludge-o-matic for cray-hdf5-parallel" ) + + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + + +local productName = "hdf5-parallel" +local productLevel = os.getenv("CRAY_HDF5_PARALLEL_VERSION") + +local sharedRoot = "/opt/cray/pe" + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + -- prepend_path("HDF5_PARALLEL_DIR", productPath) + -- prepend_path("HDF5_PARALLEL_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/module/epcc-cray-netcdf-hdf5parallel/4.7.4.3.lua b/archer2/module/epcc-cray-netcdf-hdf5parallel/4.7.4.3.lua new file mode 100755 index 0000000..7e52b60 --- /dev/null +++ b/archer2/module/epcc-cray-netcdf-hdf5parallel/4.7.4.3.lua @@ -0,0 +1,144 @@ +-- Patch up cray-netcdf-hdf5parallel +-- Handle PE_ENV correctly to set pkgconfig stuff + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +depends_on("cray-netcdf-hdf5parallel") + +-- Help section + +help ( "Kludge-o-matic for cray-netcdf-hdf5parallel" ) + + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + + +local productName = "netcdf-hdf5parallel" +local productLevel = os.getenv("CRAY_NETCDF_HDF5PARALLEL_VERSION") + +local sharedRoot = "/opt/cray/pe" + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + -- prepend_path("NETCDF_DIR", productPath) + -- prepend_path("NETCDF_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/module/epcc-cray-netcdf-hdf5parallel/4.7.4.7.lua b/archer2/module/epcc-cray-netcdf-hdf5parallel/4.7.4.7.lua new file mode 100755 index 0000000..7e52b60 --- /dev/null +++ b/archer2/module/epcc-cray-netcdf-hdf5parallel/4.7.4.7.lua @@ -0,0 +1,144 @@ +-- Patch up cray-netcdf-hdf5parallel +-- Handle PE_ENV correctly to set pkgconfig stuff + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +depends_on("cray-netcdf-hdf5parallel") + +-- Help section + +help ( "Kludge-o-matic for cray-netcdf-hdf5parallel" ) + + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + + +local productName = "netcdf-hdf5parallel" +local productLevel = os.getenv("CRAY_NETCDF_HDF5PARALLEL_VERSION") + +local sharedRoot = "/opt/cray/pe" + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + -- prepend_path("NETCDF_DIR", productPath) + -- prepend_path("NETCDF_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + +end + diff --git a/archer2/utils/xthi/build-xthi.sh b/archer2/utils/xthi/build-xthi.sh new file mode 100644 index 0000000..b539320 --- /dev/null +++ b/archer2/utils/xthi/build-xthi.sh @@ -0,0 +1,198 @@ +#!/usr/bin/env bash + +set -e + +script="$(readlink -fm "$0")" +script_dir="$(dirname "${script}")" +script_root="$(dirname "${script%/*/*}")" + +source ${script_root}/pkgconfig-lib.sh +source ${script_root}/versions.sh +source ${script_root}/command_line.sh + +xthi_src_location=/work/z19/z19/kevin/xthi/src +XTHI_VERSION="1.2" + +function main { + + # Overall prefix must be supplied by command line + + local install_root=${install_root_utils}/xthi/${XTHI_VERSION} + + ${build_cce} && xthiBuildCray ${install_root} + ${build_gnu} && xthiBuildGnu ${install_root} + ${build_amd} && xthiBuildAocc ${install_root} + + xthiInstallModuleFileLua + xthiInstallationTest +} + +function xthiBuildAocc { + + local install_root=${1} + + # Restore relevant PE/Compiler + + module load PrgEnv-aocc + module load aocc/${PE_AOCC_AOCC_VERSION} + module list + + amd_version=$(moduleToCompilerMajorMinor) + amd_root=${install_root}/AOCC + amd_prefix=${amd_root}/${amd_version} + + xthiBuild ${amd_prefix} +} + +function xthiBuildCray { + + local install_root=${1} + + module load PrgEnv-cray + module load cce/${PE_CRAY_CCE_VERSION} + module list + + cray_version=$(moduleToCompilerMajorMinor) + cray_root=${install_root}/CRAYCLANG + cray_prefix=${cray_root}/${cray_version} + + xthiBuild ${cray_prefix} +} + +function xthiBuildGnu { + + local install_root=${1} + + module load PrgEnv-gnu + module load gcc/${PE_GNU_GCC_VERSION} + module list + + gnu_version=$(moduleToCompilerMajorMinor) + gnu_root=${install_root}/GNU + gnu_prefix=${gnu_root}/${gnu_version} + + xthiBuild ${gnu_prefix} +} + +function xthiBuild { + + local prefix=${1} + + # Build OpenMP first and then MPI (prevents clobbering serial version) + xthiClean + xthiBuildMPIOpenMP ${prefix} + + xthiPackageConfigFiles ${prefix} + + # Remove shared objects from package config stage + rm ${prefix}/lib/*.so + +} + +function xthiClean { + + make -C ${xthi_src_location} clean + +} + +function xthiBuildMPIOpenMP { + + # libxthi.a / .so generated by build + + local prefix=${1} + + local pe=$(peEnvLower) + + make -C ${xthi_src_location} xthi + make -C ${xthi_src_location} xthi_mp + PREFIX=${prefix} make -C ${xthi_src_location} install + + local name_mpi_mp=libxthi_${pe}_mpi_mp + + mv ${prefix}/lib/libxthi_mpi_mp.a ${prefix}/lib/${name_mpi_mp}.a + mv ${prefix}/lib/libxthi_mpi_mp.so ${prefix}/lib/${name_mpi_mp}.so + + local name_mpi=libxthi_${pe}_mpi + + mv ${prefix}/lib/libxthi_mpi.a ${prefix}/lib/${name_mpi}.a + mv ${prefix}/lib/libxthi_mpi.so ${prefix}/lib/${name_mpi}.so +} + +function xthiPackageConfigFiles { + + # Here we declare the necessary information required to generate + # pkgconfig files + + local prefix=${1} + local prgEnv=$(peEnvLower) + + declare -A pcmap + pcmap[name]="xthi" + pcmap[version]=${XTHI_VERSION} + pcmap[description]="xthi library for ${prgEnv} compiler" + pcmap[has_openmp]=1 + + pcmap[requires]="xthi_${prgEnv}_mpi" + + pcRefactorPackageConfigFiles ${prefix} pcmap + pcFileWriteOverallPackageFile "${prefix}/lib/pkgconfig/xthi.pc" pcmap +} + +function xthiInstallModuleFileLua { + + local module_preamble=${script_dir}/module_preamble.lua + local module_boilerplate=${script_dir}/module_boilerplate.lua + + # Destination + local module_dir=$(moduleInstallDirectoryUtils) + + if [[ ! -d ${module_dir}/xthi ]]; then + mkdir ${module_dir}/xthi + fi + + local module_file=${module_dir}/xthi/${XTHI_VERSION}.lua + + # Copy add update the template + + cat ${module_preamble} > ${module_file} + cat ${module_boilerplate} >> ${module_file} + + module use ${module_dir} + module load xthi/${XTHI_VERSION} + + cc --cray-print-opts + + module unload xthi + module unuse ${module_dir} +} + +function xthiInstallationTest { + + ${test_cce} && xthiTest PrgEnv-cray + ${test_gnu} && xthiTest PrgEnv-gnu + ${test_amd} && xthiTest PrgEnv-aocc + + printf "Completed xthi installation successfully\n" +} + +function xthiTest { + + local prgenv="${1}" + local module_use=$(moduleInstallDirectoryUtils) + + printf "xthi test for %s\n" "${prgenv}" + + module load ${prgenv} + module use ${module_use} + + module load xthi/${XTHI_VERSION} + printf "XTHI_DIR: %s\n" "${XTHI_DIR}" + + slurmAllocRun "srun -n 3 xthi_mpi" + + + slurmAllocRun "srun -n 2 --distribution=block:block --hint=nomultithread xthi_mpi_mp" + module unload xthi +} + +main diff --git a/archer2/utils/xthi/module_boilerplate.lua b/archer2/utils/xthi/module_boilerplate.lua new file mode 100755 index 0000000..1299b5c --- /dev/null +++ b/archer2/utils/xthi/module_boilerplate.lua @@ -0,0 +1,174 @@ + +-- EPCC FUNCTIONS + +-- Return currently loaded compiler environment (CRAYCLANG, GNU, or AOCC) + +function epccCompilerEnv() + + local compiler = "NONE" + local pe = os.getenv("PE_ENV") or "NONE" + + if (pe == "CRAY") then + compiler = "CRAYCLANG" + elseif (pe == "GNU") then + compiler = "GNU" + elseif (pe == "AOCC") then + compiler = "AOCC" + else + error("No compiler environment available") + end + + return compiler + +end + +-- Return currently loaded compiler version major.minor + +function epccCompilerVersion() + + local version = nil + local pe = epccCompilerEnv() + + if (pe == "CRAYCLANG") then + version = os.getenv("CRAY_CC_VERSION") or nil + elseif (pe == "GNU") then + version = os.getenv("GNU_VERSION") or nil + elseif (pe == "AOCC") then + version = os.getenv("CRAY_AOCC_VERSION") or nil + end + + local _, _, major, minor, patch = string.find(version, "(%d+)%.(%d+)%.(%d+)") + + return major .. "." .. minor + +end + +-- For relevant product, return a list of available compiler versions +-- A sorted list of numbers is returned (may be empty), e.g., +-- "9.3 10.2" + +function epccProductAvailableVersions(productRoot) + + require("lfs") + + local pe = epccCompilerEnv() + local vlist = {} + + for file in lfs.dir(productRoot) do + if (lfs.attributes(productRoot .. "/" .. file, "mode") == "directory") then + local _, _, version = string.find(file, "(%d+%.%d+)") + if (version ~= nil) then + table.insert(vlist, tonumber(version)) + end + end + end + + table.sort(vlist) + + return vlist + +end + +-- Find sharedRoot; typically /work/y07/shared +-- which must correspond to /work/y07/shared/archer2-lmod/utils/core +-- the last two parts of which are returned by hierarchy() + +function epccSharedRoot() + + local fullPath = myFileName() + + local i, j = string.find(fullPath, "/" .. "archer2-lmod", 1, true) + local sharedRoot = pathJoin(string.sub(fullPath, 1, i-1), "utils/core") + + return sharedRoot + +end + +-- Begin (more-or-less) generic section +-- At this point we must have: +-- productName e.g., "metis" +-- productLevel e.g., "5.1.0" (a.ka. "version") + +-- To which we add: +-- sharedRoot e.g. "/work/y07/shared/utils/core" +-- PE_PRODUCT e.g., "PE_METIS" as a convenience + +local sharedRoot = epccSharedRoot() +local PE_PRODUCT = "PE_" .. string.upper(productName) + +-- Cray integration via pkgconfig +-- Compiler environment and currently loaded compiler version + +local compilerEnv = epccCompilerEnv() +local compilerVersion = epccCompilerVersion() + +setenv(PE_PRODUCT .. "_MODULE_NAME", productName) +setenv(PE_PRODUCT .. "_PKGCONFIG_LIBS", productName) +setenv(PE_PRODUCT .. "_FIXED_PRGENV", compilerEnv) + +prepend_path("PE_PKGCONFIG_LIBS", productName) +prepend_path("PE_PKGCONFIG_PRODUCTS", PE_PRODUCT) + + +-- OpenMP is available + +setenv(PE_PRODUCT .. "_OMP_REQUIRES", "") +setenv(PE_PRODUCT .. "_OMP_REQUIRES_openmp", "_mp") +setenv(PE_PRODUCT .. "_PKGCONFIG_VARIABLES", PE_PRODUCT .. "_OMP_REQUIRES_@openmp@") + + + +-- If the currently loaded compiler version is not available, +-- look for the most recent previous version... + +local productRoot = pathJoin(sharedRoot, productName, productLevel) +local productRootEnv = pathJoin(productRoot, compilerEnv) + +local vlist = {} +local genCompiler = nil + +vlist = epccProductAvailableVersions(productRootEnv) + +if (#vlist == 0) then + + -- Fail + error("No installations available for " .. compilerEnv) + +else + + -- What's the most recent version in the list <= loaded compiler + + for _, candidate in pairs(vlist) do + if (candidate <= tonumber(compilerVersion)) then + genCompiler = tostring(candidate) + end + end + +end + +-- Set compiler-dependent information + +if (genCompiler == nil) then + error("Package not supported in the loaded compiler version") +else + -- OK, can now set up + + local productPath = pathJoin(productRootEnv, genCompiler) + + -- Set variables for root of installation (both "_DIR" and "_ROOT" + -- are made available) + + prepend_path(string.upper(productName) .. "_DIR", productPath) + prepend_path(string.upper(productName) .. "_ROOT", productPath) + + -- pkgconfig location + + local pkgconfig = pathJoin(productPath, "lib/pkgconfig") + prepend_path("PE_" .. compilerEnv .. "_FIXED_PKGCONFIG_PATH", pkgconfig) + + -- bin is required + + prepend_path("PATH", pathJoin(productPath, "bin")) + +end + diff --git a/archer2/utils/xthi/module_preamble.lua b/archer2/utils/xthi/module_preamble.lua new file mode 100755 index 0000000..7e46672 --- /dev/null +++ b/archer2/utils/xthi/module_preamble.lua @@ -0,0 +1,19 @@ +-- xthi preamble + +family("xthi") + +prereq_any("PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc") + +-- This is introspection; may want to set explicitly. + +local productName = myModuleName() +local productLevel = myModuleVersion() + +-- Help section + +local help1 = "xthi version " .. productLevel .. "\n" +local help2 = "For details of scheduling on ARCHER2 see: \n" +local help3 = "https://docs.archer2.ac.uk/user-guide/scheduler" + +help ( help1 .. help2 .. help3 ) +