pax_global_header00006660000000000000000000000064144530224070014513gustar00rootroot0000000000000052 comment=7a5f6752b887ec4f22ca8ee16abc76152f7a63d9 rocALUTION-rocm-5.7.1/000077500000000000000000000000001445302240700143025ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/.clang-format000066400000000000000000000065421445302240700166640ustar00rootroot00000000000000# Style file for MLSE Libraries based on the modified rocBLAS style # Common settings BasedOnStyle: WebKit TabWidth: 4 IndentWidth: 4 UseTab: Never ColumnLimit: 100 # Other languages JavaScript, Proto --- Language: Cpp # http://releases.llvm.org/6.0.1/tools/clang/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code # int formatted_code; # // clang-format off # void unformatted_code ; # // clang-format on # void formatted_code_again; DisableFormat: false Standard: Cpp11 AccessModifierOffset: -4 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: true AlignConsecutiveDeclarations: true AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: false AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: false AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: true BinPackArguments: false BinPackParameters: false # Configure each individual brace in BraceWrapping BreakBeforeBraces: Custom # Control of individual brace wrapping cases BraceWrapping: { AfterCaseLabel: 'true' AfterClass: 'true' AfterControlStatement: 'true' AfterEnum : 'true' AfterFunction : 'true' AfterNamespace : 'true' AfterStruct : 'true' AfterUnion : 'true' BeforeCatch : 'true' BeforeElse : 'true' IndentBraces : 'false' # AfterExternBlock : 'true' } #BreakAfterJavaFieldAnnotations: true #BreakBeforeInheritanceComma: false #BreakBeforeBinaryOperators: None #BreakBeforeTernaryOperators: true #BreakConstructorInitializersBeforeComma: true #BreakStringLiterals: true CommentPragmas: '^ IWYU pragma:' #CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true SpaceBeforeCpp11BracedList: false DerivePointerAlignment: false ExperimentalAutoDetectBinPacking: false ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] IndentCaseLabels: false IndentPPDirectives: None #FixNamespaceComments: true IndentWrappedFunctionNames: true KeepEmptyLinesAtTheStartOfBlocks: true MacroBlockBegin: '' MacroBlockEnd: '' #JavaScriptQuotes: Double MaxEmptyLinesToKeep: 1 NamespaceIndentation: All ObjCBlockIndentWidth: 4 #ObjCSpaceAfterProperty: true #ObjCSpaceBeforeProtocolList: true PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: Never SpaceInEmptyBlock: false SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false #SpaceAfterTemplateKeyword: true #SpaceBeforeInheritanceColon: true #SortUsingDeclarations: true SortIncludes: true # Comments are for developers, they should arrange them ReflowComments: false #IncludeBlocks: Preserve --- rocALUTION-rocm-5.7.1/.githooks/000077500000000000000000000000001445302240700162075ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/.githooks/install000077500000000000000000000002231445302240700176000ustar00rootroot00000000000000#!/usr/bin/env bash cd $(git rev-parse --git-dir) cd hooks echo "Installing hooks..." ln -fs ../../.githooks/pre-commit pre-commit echo "Done!" rocALUTION-rocm-5.7.1/.githooks/pre-commit000077500000000000000000000041201445302240700202060ustar00rootroot00000000000000#!/bin/bash # # This pre-commit hook checks if any versions of clang-format # are installed, and if so, uses the installed version to format # the staged changes. export PATH=/usr/bin:/bin set -x format=/opt/rocm/llvm/bin/clang-format # Redirect stdout to stderr. exec >&2 # Do everything from top - level cd $(git rev-parse --show-toplevel) if git rev-parse --verify HEAD >/dev/null 2>&1; then against=HEAD else # Initial commit: diff against an empty tree object against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi if [[ "$1" == "--reformat" ]]; then files=$(git ls-files --exclude-standard) else files=$(git diff-index --cached --name-only $against) fi [[ -z "$files" ]] && exit # Change the copyright date at the top of any text files for file in $files; do if [[ -e $file ]]; then /usr/bin/perl -pi -e 'INIT { exit 1 if !-f $ARGV[0] || -B $ARGV[0]; $year = (localtime)[5] + 1900 } s/^([*\/#[:space:]]*)Copyright\s+(?:\(C\)\s*)?(\d+)(?:\s*-\s*\d+)?/qq($1Copyright (c) $2@{[$year != $2 ? "-$year" : ""]})/ie if $. < 10' "$file" && git add -u "$file" fi done # do the formatting for file in $files; do if [[ -e $file ]] && echo $file | grep -Eq '\.c$|\.h$|\.hpp$|\.cpp$|\.cl$|\.in$|\.txt$|\.yaml$|\.sh$|\.py$|\.pl$|\.cmake$|\.md$|\.rst$|\.groovy$'; then sed -i -e 's/[[:space:]]*$//' "$file" # Remove whitespace at end of lines sed -i -e '$a\' "$file" # Add missing newline to end of file # Convert UTF8 non-ASCII to ASCII temp=$(mktemp) [[ -w $temp ]] || exit iconv -s -f utf-8 -t ascii//TRANSLIT "$file" > "$temp" || exit chmod --reference="$file" "$temp" || exit mv -f "$temp" "$file" || exit git add -u "$file" fi done # if clang-format exists, run it on C/C++ files if [[ -x $format ]]; then for file in $files; do if [[ -e $file ]] && echo $file | grep -Eq '\.c$|\.h$|\.hpp$|\.cpp$|\.cl$|\.h\.in$|\.hpp\.in$|\.cpp\.in$'; then echo "$format $file" "$format" -i -style=file "$file" git add -u "$file" fi done fi rocALUTION-rocm-5.7.1/.github/000077500000000000000000000000001445302240700156425ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/.github/CODEOWNERS000066400000000000000000000000451445302240700172340ustar00rootroot00000000000000* @ntrost57 @YvanMokwinski @jsandham rocALUTION-rocm-5.7.1/.github/dependabot.yml000066400000000000000000000010421445302240700204670ustar00rootroot00000000000000# To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates version: 2 updates: - package-ecosystem: "pip" # See documentation for possible values directory: "/docs/.sphinx" # Location of package manifests open-pull-requests-limit: 10 schedule: interval: "daily" rocALUTION-rocm-5.7.1/.gitignore000066400000000000000000000007471445302240700163020ustar00rootroot00000000000000# Compiled Object files *.slo *.lo *.o *.obj # Precompiled Headers *.gch *.pch # Compiled Dynamic libraries *.so *.dylib *.dll # Fortran module files *.mod # Compiled Static libraries *.lai *.la *.a *.lib # Executables *.exe *.out *.app # vim tags tags .tags .*.swp # Editors .vscode # build-in-source directory build # doc docBin _build # Visual Studio stuff *.vcxproj.user *.suo *.sdf *.pdb *.opensdf # documentation artifacts _build/ _images/ _static/ _templates/ _toc.yml rocALUTION-rocm-5.7.1/.jenkins/000077500000000000000000000000001445302240700160215ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/.jenkins/codecov.groovy000066400000000000000000000052251445302240700207160ustar00rootroot00000000000000#!/usr/bin/env groovy // This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/ @Library('rocJenkins@pong') _ // This is file for internal AMD use. // If you are interested in running your own Jenkins, please raise a github issue for assistance. import com.amd.project.* import com.amd.docker.* import java.nio.file.Path def runCI = { nodeDetails, jobName-> def prj = new rocProject('rocALUTION', 'CodeCov') // customize for project prj.paths.build_command = './install.sh -cg --codecoverage' prj.compiler.compiler_name = 'c++' prj.compiler.compiler_path = 'c++' prj.libraryDependencies = ['rocPRIM', 'rocBLAS-internal', 'rocSPARSE-internal', 'rocRAND'] prj.defaults.ccache = false // Define test architectures, optional rocm version argument is available def nodes = new dockerNodes(nodeDetails, jobName, prj) def commonGroovy boolean formatCheck = false def compileCommand = { platform, project-> project.paths.construct_build_prefix() commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" commonGroovy.runCompileCommand(platform, project) } def testCommand = { platform, project-> def gfilter = "**" commonGroovy.runCoverageCommand(platform, project, gfilter, "debug") } buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, testCommand, null) } ci: { String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) def propertyList = ["compute-rocm-dkms-no-npi":[pipelineTriggers([cron('0 1 * * 6')])], "compute-rocm-dkms-no-npi-hipclang":[pipelineTriggers([cron('0 1 * * 6')])] ] propertyList = auxiliary.appendPropertyList(propertyList) def jobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['gfx900']]), "compute-rocm-dkms-no-npi-hipclang":([ubuntu18:['gfx900']])] jobNameList = auxiliary.appendJobNameList(jobNameList) propertyList.each { jobName, property-> if (urlJobName == jobName) properties(auxiliary.addCommonProperties(property)) } jobNameList.each { jobName, nodeDetails-> if (urlJobName == jobName) stage(jobName) { runCI(nodeDetails, jobName) } } // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 if(!jobNameList.keySet().contains(urlJobName)) { properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) stage(urlJobName) { runCI([ubuntu18:['gfx900']], urlJobName) } } } rocALUTION-rocm-5.7.1/.jenkins/common.groovy000066400000000000000000000116411445302240700205630ustar00rootroot00000000000000// This file is for internal AMD use. // If you are interested in running your own Jenkins, please raise a github issue for assistance. import static groovy.io.FileType.FILES def runCompileCommand(platform, project, boolean sameOrg=false) { project.paths.construct_build_prefix() String centos7devtoolset = platform.jenkinsLabel.contains('centos7') ? 'source /etc/profile.d/modules.sh && source scl_source enable devtoolset-7 && module load mpi/openmpi-x86_64' : '' def getDependenciesCommand = "" if (project.installLibraryDependenciesFromCI) { project.libraryDependencies.each { libraryName -> getDependenciesCommand += auxiliary.getLibrary(libraryName, platform.jenkinsLabel, null, sameOrg) } } def command = """#!/usr/bin/env bash set -x cd ${project.paths.project_build_prefix} ${getDependenciesCommand} ${centos7devtoolset} ${project.paths.build_command} """ platform.runCommand(this, command) } def runTestCommand (platform, project, gfilter) { def hmmTestCommand= '' if (platform.jenkinsLabel.contains('gfx90a')) { hmmTestCommand = """ HSA_XNACK=0 GTEST_LISTENER=NO_PASS_LINE_IN_LOG ./rocalution-test --gtest_output=xml:test_detail_hmm_xnack_off.xml --gtest_color=yes --gtest_filter=** HSA_XNACK=1 GTEST_LISTENER=NO_PASS_LINE_IN_LOG ./rocalution-test --gtest_output=xml:test_detail_hmm_xnack_on.xml --gtest_color=yes --gtest_filter=** """ } String sudo = auxiliary.sudo(platform.jenkinsLabel) def command = """#!/usr/bin/env bash set -x cd ${project.paths.project_build_prefix}/build/release/clients/staging ${sudo} LD_LIBRARY_PATH=/opt/rocm/hcc/lib GTEST_LISTENER=NO_PASS_LINE_IN_LOG ./rocalution-test --gtest_output=xml --gtest_color=yes #--gtest_filter=${gfilter}-*known_bug* ${hmmTestCommand} """ platform.runCommand(this, command) junit "${project.paths.project_build_prefix}/build/release/clients/staging/*.xml" } def runCoverageCommand (platform, project, gfilter, String dirmode = "release") { //Temporary workaround due to bug in container String centos7Workaround = platform.jenkinsLabel.contains('centos7') ? 'export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/rocm/lib64/' : '' def command = """#!/usr/bin/env bash set -x cd ${project.paths.project_build_prefix}/build/${dirmode} export LD_LIBRARY_PATH=/opt/rocm/lib/ ${centos7Workaround} GTEST_LISTENER=NO_PASS_LINE_IN_LOG make coverage_cleanup coverage GTEST_FILTER=${gfilter}-*known_bug* """ platform.runCommand(this, command) publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: "${project.paths.project_build_prefix}/build/${dirmode}/lcoverage", reportFiles: "index.html", reportName: "Code coverage report", reportTitles: "Code coverage report"]) } def runPackageCommand(platform, project, jobName, label='') { def command label = label != '' ? '-' + label.toLowerCase() : '' if(platform.jenkinsLabel.contains('centos') || platform.jenkinsLabel.contains('sles')) { command = """ set -x cd ${project.paths.project_build_prefix}/build/release make package mkdir -p package if [ ! -z "$label" ] then for f in rocalution*.rpm do echo f mv "\$f" "rocalution${label}-\${f#*-}" ls done fi mv *.rpm package/ rpm -qlp package/*.rpm """ platform.runCommand(this, command) platform.archiveArtifacts(this, """${project.paths.project_build_prefix}/build/release/package/*.rpm""") } else { command = """ set -x cd ${project.paths.project_build_prefix}/build/release make package mkdir -p package if [ ! -z "$label" ] then for f in rocalution*.deb do echo f mv "\$f" "rocalution${label}-\${f#*-}" ls done fi mv *.deb package/ for pkg in package/*.deb; do dpkg -c \$pkg done """ platform.runCommand(this, command) platform.archiveArtifacts(this, """${project.paths.project_build_prefix}/build/release/package/*.deb""") } } return this rocALUTION-rocm-5.7.1/.jenkins/debug.groovy000066400000000000000000000062311445302240700203600ustar00rootroot00000000000000#!/usr/bin/env groovy // This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/ @Library('rocJenkins@pong') _ // This is file for internal AMD use. // If you are interested in running your own Jenkins, please raise a github issue for assistance. import com.amd.project.* import com.amd.docker.* import java.nio.file.Path def runCI = { nodeDetails, jobName, buildCommand -> def prj = new rocProject('rocALUTION', 'Debug') // customize for project prj.paths.build_command = buildCommand prj.compiler.compiler_name = 'c++' prj.compiler.compiler_path = 'c++' prj.libraryDependencies = ['rocPRIM', 'rocBLAS-internal', 'rocSPARSE-internal', 'rocRAND'] // Define test architectures, optional rocm version argument is available def nodes = new dockerNodes(nodeDetails, jobName, prj) def commonGroovy boolean formatCheck = false def compileCommand = { platform, project-> project.paths.construct_build_prefix() commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" commonGroovy.runCompileCommand(platform, project) } buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, null, null) } def setupCI(urlJobName, jobNameList, buildCommand, runCI, label) { jobNameList = auxiliary.appendJobNameList(jobNameList) jobNameList.each { jobName, nodeDetails-> if (urlJobName == jobName) stage(label + ' ' + jobName) { runCI(nodeDetails, jobName, buildCommand) } } // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 if(!jobNameList.keySet().contains(urlJobName)) { properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) stage(label + ' ' + urlJobName) { runCI([ubuntu18:['any']], urlJobName, buildCommand) } } } ci: { String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) def propertyList = ["compute-rocm-dkms-no-npi":[pipelineTriggers([cron('0 1 * * 0')])], "rocm-docker":[]] propertyList = auxiliary.appendPropertyList(propertyList) propertyList.each { jobName, property-> if (urlJobName == jobName) properties(auxiliary.addCommonProperties(property)) } def defaultJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['any']]), "rocm-docker":([ubuntu18:['any']])] def hostJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['any']]), "rocm-docker":([ubuntu18:['any']])] def mpiJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['any']]), "rocm-docker":([ubuntu18:['any']])] String defaultBuildCommand = './install.sh -c' String hostBuildCommand = './install.sh -c --host' String mpiBuildCommand = './install.sh -c --host --mpi=on --no-openmp' setupCI(urlJobName, defaultJobNameList, defaultBuildCommand, runCI, '') setupCI(urlJobName, hostJobNameList, hostBuildCommand, runCI, 'Host') setupCI(urlJobName, mpiJobNameList, mpiBuildCommand, runCI, 'MPI') } rocALUTION-rocm-5.7.1/.jenkins/extended.groovy000066400000000000000000000071451445302240700210770ustar00rootroot00000000000000#!/usr/bin/env groovy // This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/ @Library('rocJenkins@pong') _ // This is file for internal AMD use. // If you are interested in running your own Jenkins, please raise a github issue for assistance. import com.amd.project.* import com.amd.docker.* import java.nio.file.Path def runCI = { nodeDetails, jobName, buildCommand -> def prj = new rocProject('rocALUTION', 'Extended') // customize for project prj.paths.build_command = buildCommand prj.compiler.compiler_name = 'c++' prj.compiler.compiler_path = 'c++' prj.libraryDependencies = ['rocPRIM', 'rocBLAS-internal', 'rocSPARSE-internal', 'rocRAND'] // Define test architectures, optional rocm version argument is available def nodes = new dockerNodes(nodeDetails, jobName, prj) def commonGroovy boolean formatCheck = false def compileCommand = { platform, project-> project.paths.construct_build_prefix() commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" commonGroovy.runCompileCommand(platform, project) } def testCommand = { platform, project-> def gfilter = "*nightly*" commonGroovy.runTestCommand(platform, project, gfilter) } def packageCommand = { platform, project-> commonGroovy.runPackageCommand(platform, project, jobName) } buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, testCommand, packageCommand) } def setupCI(urlJobName, jobNameList, buildCommand, runCI, label) { jobNameList = auxiliary.appendJobNameList(jobNameList) jobNameList.each { jobName, nodeDetails-> if (urlJobName == jobName) stage(label + ' ' + jobName) { runCI(nodeDetails, jobName, buildCommand) } } // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 if(!jobNameList.keySet().contains(urlJobName)) { properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) stage(label + ' ' + urlJobName) { runCI([ubuntu18:['gfx906']], urlJobName, buildCommand) } } } ci: { String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) def propertyList = ["compute-rocm-dkms-no-npi":[pipelineTriggers([cron('0 1 * * 0')])], "rocm-docker":[]] propertyList = auxiliary.appendPropertyList(propertyList) propertyList.each { jobName, property-> if (urlJobName == jobName) properties(auxiliary.addCommonProperties(property)) } def defaultJobNameList = ["compute-rocm-dkms-no-npi-hipclang":([ubuntu18:['gfx900'],centos7:['gfx906'],centos8:['any'],sles15sp1:['gfx908']]), "rocm-docker":([ubuntu18:['gfx900'],centos7:['gfx906'],sles15sp1:['gfx908']])] def hostJobNameList = ["compute-rocm-dkms-no-npi-hipclang":([ubuntu18:['gfx900']]), "rocm-docker":([ubuntu18:['gfx900']])] def mpiJobNameList = ["compute-rocm-dkms-no-npi-hipclang":([ubuntu18:['gfx900']]), "rocm-docker":([ubuntu18:['gfx900']])] String defaultBuildCommand = './install.sh -c' String hostBuildCommand = './install.sh -c --host' String mpiBuildCommand = './install.sh -c --host --mpi=on --no-openmp' setupCI(urlJobName, defaultJobNameList, defaultBuildCommand, runCI, '') setupCI(urlJobName, hostJobNameList, hostBuildCommand, runCI, 'Host') setupCI(urlJobName, mpiJobNameList, mpiBuildCommand, runCI, 'MPI') } rocALUTION-rocm-5.7.1/.jenkins/precheckin.groovy000066400000000000000000000071611445302240700214100ustar00rootroot00000000000000#!/usr/bin/env groovy // This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/ @Library('rocJenkins@pong') _ // This is file for internal AMD use. // If you are interested in running your own Jenkins, please raise a github issue for assistance. import com.amd.project.* import com.amd.docker.* import java.nio.file.Path def runCI = { nodeDetails, jobName, buildCommand, label -> def prj = new rocProject('rocALUTION', 'PreCheckin') // customize for project prj.paths.build_command = buildCommand prj.compiler.compiler_name = 'c++' prj.compiler.compiler_path = 'c++' prj.libraryDependencies = ['rocPRIM', 'rocBLAS-internal', 'rocSPARSE-internal', 'rocRAND'] // Define test architectures, optional rocm version argument is available def nodes = new dockerNodes(nodeDetails, jobName, prj) def commonGroovy boolean formatCheck = false def compileCommand = { platform, project-> project.paths.construct_build_prefix() commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" commonGroovy.runCompileCommand(platform, project) } def testCommand = { platform, project-> def gfilter = "*checkin*" commonGroovy.runTestCommand(platform, project, gfilter) } def packageCommand = { platform, project-> commonGroovy.runPackageCommand(platform, project, jobName, label) } buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, testCommand, packageCommand) } def setupCI(urlJobName, jobNameList, buildCommand, runCI, label) { jobNameList = auxiliary.appendJobNameList(jobNameList) jobNameList.each { jobName, nodeDetails-> if (urlJobName == jobName) stage(label + ' ' + jobName) { runCI(nodeDetails, jobName, buildCommand, label) } } // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 if(!jobNameList.keySet().contains(urlJobName)) { properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) stage(label + ' ' + urlJobName) { runCI([ubuntu18:['gfx906']], urlJobName, buildCommand, label) } } } ci: { String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) def propertyList = ["compute-rocm-dkms-no-npi":[pipelineTriggers([cron('0 1 * * 0')])], "rocm-docker":[]] propertyList = auxiliary.appendPropertyList(propertyList) propertyList.each { jobName, property-> if (urlJobName == jobName) properties(auxiliary.addCommonProperties(property)) } def defaultJobNameList = ["compute-rocm-dkms-no-npi-hipclang":([ubuntu18:['gfx900'],centos7:['gfx906'],centos8:['any'],sles15sp1:['gfx908']]), "rocm-docker":([ubuntu18:['gfx900'],centos7:['gfx906'],sles15sp1:['gfx908']])] def hostJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['gfx900']]), "rocm-docker":([ubuntu18:['gfx900']])] def mpiJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['gfx900']]), "rocm-docker":([ubuntu18:['gfx900']])] String defaultBuildCommand = './install.sh -c' String hostBuildCommand = './install.sh -c --host' String mpiBuildCommand = './install.sh -c --host --mpi=on --no-openmp' setupCI(urlJobName, defaultJobNameList, defaultBuildCommand, runCI, '') setupCI(urlJobName, hostJobNameList, hostBuildCommand, runCI, 'Host') setupCI(urlJobName, mpiJobNameList, mpiBuildCommand, runCI, 'MPI') } rocALUTION-rocm-5.7.1/.jenkins/staticanalysis.groovy000066400000000000000000000023531445302240700223260ustar00rootroot00000000000000#!/usr/bin/env groovy // This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/ @Library('rocJenkins@pong') _ // This is file for internal AMD use. // If you are interested in running your own Jenkins, please raise a github issue for assistance. import com.amd.project.* import com.amd.docker.* import java.nio.file.Path def runCompileCommand(platform, project, jobName, boolean debug=false) { project.paths.construct_build_prefix() } def runCI = { nodeDetails, jobName-> def prj = new rocProject('rocALUTION-internal', 'StaticAnalysis') // Define test architectures, optional rocm version argument is available def nodes = new dockerNodes(nodeDetails, jobName, prj) boolean formatCheck = true boolean staticAnalysis = true def compileCommand = { platform, project-> runCompileCommand(platform, project, jobName, false) } buildProject(prj , formatCheck, nodes.dockerArray, compileCommand, null, null, staticAnalysis) } ci: { String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * 6')])])) stage(urlJobName) { runCI([ubuntu20:['cpu']], urlJobName) } } rocALUTION-rocm-5.7.1/.jenkins/staticlibrary.groovy000066400000000000000000000072301445302240700221460ustar00rootroot00000000000000#!/usr/bin/env groovy // This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/ @Library('rocJenkins@pong') _ // This is file for internal AMD use. // If you are interested in running your own Jenkins, please raise a github issue for assistance. import com.amd.project.* import com.amd.docker.* import java.nio.file.Path def runCI = { nodeDetails, jobName, buildCommand, label -> def prj = new rocProject('rocALUTION', 'Static Library PreCheckin') // customize for project prj.paths.build_command = buildCommand prj.compiler.compiler_name = 'hipcc' prj.compiler.compiler_path = '/opt/rocm/bin/hipcc' prj.libraryDependencies = ['rocPRIM', 'rocBLAS-internal', 'rocSPARSE-internal', 'rocRAND'] // Define test architectures, optional rocm version argument is available def nodes = new dockerNodes(nodeDetails, jobName, prj) def commonGroovy boolean formatCheck = true def compileCommand = { platform, project-> project.paths.construct_build_prefix() commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" commonGroovy.runCompileCommand(platform, project,true) } def testCommand = { platform, project-> def gfilter = "*checkin*" commonGroovy.runTestCommand(platform, project, gfilter) } def packageCommand = { platform, project-> commonGroovy.runPackageCommand(platform, project, jobName, label) } buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, testCommand, packageCommand) } def setupCI(urlJobName, jobNameList, buildCommand, runCI, label) { jobNameList = auxiliary.appendJobNameList(jobNameList) jobNameList.each { jobName, nodeDetails-> if (urlJobName == jobName) stage(label + ' ' + jobName) { runCI(nodeDetails, jobName, buildCommand, label) } } // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 if(!jobNameList.keySet().contains(urlJobName)) { properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) stage(label + ' ' + urlJobName) { runCI([ubuntu18:['gfx906']], urlJobName, buildCommand, label) } } } ci: { String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) def propertyList = ["compute-rocm-dkms-no-npi":[pipelineTriggers([cron('0 1 * * 0')])], "rocm-docker":[]] propertyList = auxiliary.appendPropertyList(propertyList) propertyList.each { jobName, property-> if (urlJobName == jobName) properties(auxiliary.addCommonProperties(property)) } def defaultJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['gfx900'],centos7:['gfx906'],sles15sp1:['gfx908']]), "rocm-docker":([ubuntu18:['gfx900'],centos7:['gfx906'],sles15sp1:['gfx908']])] def hostJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['gfx900']]), "rocm-docker":([ubuntu18:['gfx900']])] def mpiJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['gfx900']]), "rocm-docker":([ubuntu18:['gfx900']])] String defaultBuildCommand = './install.sh -c --static' String hostBuildCommand = './install.sh -c --host --static' String mpiBuildCommand = './install.sh -c --host --mpi=on --no-openmp --static' setupCI(urlJobName, defaultJobNameList, defaultBuildCommand, runCI, '') setupCI(urlJobName, hostJobNameList, hostBuildCommand, runCI, 'Host') setupCI(urlJobName, mpiJobNameList, mpiBuildCommand, runCI, 'MPI') } rocALUTION-rocm-5.7.1/.readthedocs.yaml000066400000000000000000000004171445302240700175330ustar00rootroot00000000000000# Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details version: 2 sphinx: configuration: docs/conf.py formats: [htmlzip] python: version: "3.8" install: - requirements: docs/.sphinx/requirements.txt rocALUTION-rocm-5.7.1/CHANGELOG.md000066400000000000000000000122001445302240700161060ustar00rootroot00000000000000# Change Log for rocALUTION Full documentation for rocALUTION is available at [rocalution.readthedocs.io](https://rocalution.readthedocs.io/en/latest/). ## rocALUTION 2.1.11 for ROCm 5.7.0 ### Added - Added support for gfx940, gfx941 and gfx942 ### Improved - Fixed OpenMP runtime issue with Windows toolchain ## rocALUTION 2.1.9 for ROCm 5.6.0 ### Improved - Fixed synchronization issues in level 1 routines ## rocALUTION 2.1.8 for ROCm 5.5.0 ### Added - Added build support for Navi32 ### Improved - Fixed a typo in MPI backend - Fixed a bug with the backend when HIP support is disabled - Fixed a bug in SAAMG hierarchy building on HIP backend - Improved SAAMG hierarchy build performance on HIP backend ### Changed - LocalVector::GetIndexValues(ValueType\*) is deprecated, use LocalVector::GetIndexValues(const LocalVector&, LocalVector\*) instead - LocalVector::SetIndexValues(const ValueType\*) is deprecated, use LocalVector::SetIndexValues(const LocalVector&, const LocalVector&) instead - LocalMatrix::RSDirectInterpolation(const LocalVector&, const LocalVector&, LocalMatrix\*, LocalMatrix\*) is deprecated, use LocalMatrix::RSDirectInterpolation(const LocalVector&, const LocalVector&, LocalMatrix\*) instead - LocalMatrix::RSExtPIInterpolation(const LocalVector&, const LocalVector&, bool, float, LocalMatrix\*, LocalMatrix\*) is deprecated, use LocalMatrix::RSExtPIInterpolation(const LocalVector&, const LocalVector&, bool, LocalMatrix\*) instead - LocalMatrix::RugeStueben() is deprecated - LocalMatrix::AMGSmoothedAggregation(ValueType, const LocalVector&, const LocalVector&, LocalMatrix\*, LocalMatrix\*, int) is deprecated, use LocalMatrix::AMGAggregation(ValueType, const LocalVector&, const LocalVector&, LocalMatrix\*, int) instead - LocalMatrix::AMGAggregation(const LocalVector&, LocalMatrix\*, LocalMatrix\*) is deprecated, use LocalMatrix::AMGAggregation(const LocalVector&, LocalMatrix\*) instead ## rocALUTION 2.1.3 for ROCm 5.4.0 ### Added - Added build support for Navi31 and Navi33 - Added support for non-squared global matrices ### Improved - Fixed a memory leak in MatrixMult on HIP backend - Global structures can now be used with a single process ### Changed - Switched GTest death test style to 'threadsafe' - GlobalVector::GetGhostSize() is deprecated and will be removed - ParallelManager::GetGlobalSize(), ParallelManager::GetLocalSize(), ParallelManager::SetGlobalSize() and ParallelManager::SetLocalSize() are deprecated and will be removed - Vector::GetGhostSize() is deprecated and will be removed - Multigrid::SetOperatorFormat(unsigned int) is deprecated and will be removed, use Multigrid::SetOperatorFormat(unsigned int, int) instead - RugeStuebenAMG::SetCouplingStrength(ValueType) is deprecated and will be removed, use SetStrengthThreshold(float) instead ## rocALUTION 2.1.0 for ROCm 5.3.0 ### Added - Benchmarking tool - Ext+I Interpolation with sparsify strategies added for RS-AMG ### Improved - ParallelManager ## rocALUTION 2.0.3 for ROCm 5.2.0 ### Added - Packages for test and benchmark executables on all supported OSes using CPack. ## rocALUTION 2.0.2 for ROCm 5.1.0 ### Added - Added out-of-place matrix transpose functionality - Added LocalVector ## rocALUTION 2.0.1 for ROCm 5.0.0 ### Changed - Removed deprecated GlobalPairwiseAMG class, please use PairwiseAMG instead. - Changed to C++ 14 Standard ### Improved - Added sanitizer option - Improved documentation ## rocALUTION 1.13.2 for ROCm 4.5.0 ### Added - Address sanitizer build option added - Enabling beta support for Windows 10 ### Changed - Deprecated GlobalPairwiseAMG, please use PairwiseAMG instead. GlobalPairwiseAMG will be removed in a future major release. - Packaging split into a runtime package called rocalution and a development package called rocalution-devel. The development package depends on runtime. The runtime package suggests the development package for all supported OSes except CentOS 7 to aid in the transition. The suggests feature in packaging is introduced as a deprecated feature and will be removed in a future rocm release. ### Improved - (A)MG smoothing and convergence rate improvement - Improved IDR Gram-Schmidt process - (A)MG solving phase optimization ## rocALUTION 1.12.1 for ROCm 4.3.0 ### Added - support for gfx90a target - support for gfx1030 target ### Improved - install script ### Known Issues - none ## rocALUTION 1.11.5 for ROCm 4.2.0 ### Added - none ### Known Issues - none ## rocALUTION 1.11.5 for ROCm 4.1.0 ### Added - none ### Known Issues - none ## rocALUTION 1.11.5 for ROCm 4.0.0 ### Added - Add changelog - Fixing NaN issues - update to debian package name - bcsr format support. - cmake files adjustments. ## rocALUTION 1.10 for ROCm 3.9 ### Added - rocRAND to support GPU sampling of random data. ### Known Issues - none ## rocALUTION 1.9.3 for ROCm 3.8 ### Added - csr2dense and dense2csr to HIP backend. ### Known Issues - none ## rocALUTION 1.9.1 for ROCm 3.7 ### Added - none ### Known Issues - none ## rocALUTION 1.9.1 for ROCm 3.6 ### Added - none ### Known Issues - none ## rocALUTION 1.9.1 for ROCm 3.5 ### Added - static build - BCSR matrix format for SpMV - Bug fixing in conversion from CSR to HYB format. ### Known Issues - none rocALUTION-rocm-5.7.1/CMakeLists.txt000066400000000000000000000177441445302240700170570ustar00rootroot00000000000000# ######################################################################## # Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ######################################################################## cmake_minimum_required(VERSION 3.5 FATAL_ERROR) # Consider removing this in the future # This should appear before the project command, because it does not use FORCE if(WIN32) set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories") else() set(CMAKE_INSTALL_PREFIX ${ROCM_PATH} CACHE PATH "Install path prefix, prepended onto install directories") endif() # Needed to pickup static library files list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/llvm ${ROCM_PATH}) # CMake modules list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${ROCM_PATH}/lib/cmake/hip ${ROCM_PATH}/hip/cmake) # Set a default build type if none was specified if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "" "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() # Honor per-config flags in try_compile() source-file signature. cmake v3.7 and up if(POLICY CMP0066) cmake_policy(SET CMP0066 NEW) endif() # rocALUTION project project(rocalution LANGUAGES CXX) # Build flags set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # Build options option(BUILD_SHARED_LIBS "Build rocALUTION as a shared library" ON) option(BUILD_CLIENTS_TESTS "Build tests (requires googletest)" OFF) option(BUILD_CLIENTS_BENCHMARKS "Build benchmarks (requires boost)" OFF) option(BUILD_CLIENTS_SAMPLES "Build examples" ON) option(BUILD_VERBOSE "Output additional build information" OFF) option(BUILD_CODE_COVERAGE "Build with code coverage enabled" OFF) option(BUILD_ADDRESS_SANITIZER "Build with address sanitizer enabled" OFF) option(BUILD_FILE_REORG_BACKWARD_COMPATIBILITY "Build with file/folder reorg with backward compatibility enabled" ON) # Dependencies include(cmake/Dependencies.cmake) # Availability of rocm_check_target_ids command assures that we can also build # for gfx90a target if(COMMAND rocm_check_target_ids) set(DEFAULT_AMDGPU_TARGETS "gfx803;gfx900:xnack-;gfx906:xnack-;gfx908:xnack-;gfx1030;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1100;gfx1101;gfx1102") else() set(DEFAULT_AMDGPU_TARGETS "gfx803;gfx900:xnack-;gfx906:xnack-;gfx908:xnack-;gfx1030;gfx1100;gfx1101;gfx1102") endif() set(AMDGPU_TARGETS "${DEFAULT_AMDGPU_TARGETS}" CACHE STRING "List of specific machine types for library to target") # Find HIP package find_package(HIP) if (NOT HIP_FOUND) message("-- HIP not found. Compiling WITHOUT HIP support.") else() option(SUPPORT_HIP "Compile WITH HIP support." ON) endif() # HIP related library dependencies if(SUPPORT_HIP) find_package(rocblas REQUIRED) find_package(rocsparse REQUIRED) find_package(rocprim REQUIRED) find_package(rocrand REQUIRED) endif() if(BUILD_CODE_COVERAGE) add_compile_options(-fprofile-arcs -ftest-coverage) add_link_options(--coverage -lgcov) endif() if(BUILD_ADDRESS_SANITIZER) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -shared-libasan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -shared-libasan") add_link_options(-fuse-ld=lld) endif() # Setup version set(VERSION_STRING "2.1.11") rocm_setup_version(VERSION ${VERSION_STRING}) set(rocalution_SOVERSION 0.1) if(BUILD_CLIENTS_SAMPLES OR BUILD_CLIENTS_BENCHMARKS OR BUILD_CLIENTS_TESTS) set( BUILD_CLIENTS ON ) rocm_package_setup_component(clients) if(BUILD_CLIENTS_TESTS) rocm_package_setup_client_component(tests) endif() if(BUILD_CLIENTS_BENCHMARKS) rocm_package_setup_client_component(benchmarks) endif() endif() # rocALUTION library add_subdirectory(src) # Trigger client builds if selected if(BUILD_CLIENTS) add_subdirectory(clients) endif() # Package specific CPACK vars if(SUPPORT_HIP) rocm_package_add_dependencies(DEPENDS "hip-rocclr >= 4.0.0" "rocsparse >= 1.12.10" "rocblas >= 2.22.0" "rocrand >= 0.0.1") endif() set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md") if(WIN32) set(CPACK_SOURCE_GENERATOR "ZIP") set(CPACK_GENERATOR "ZIP") set(CMAKE_INSTALL_PREFIX "C:/hipSDK" CACHE PATH "Install path" FORCE) set(INSTALL_PREFIX "C:/hipSDK") set(CPACK_SET_DESTDIR OFF) set(CPACK_PACKAGE_INSTALL_DIRECTORY "C:/hipSDK") set(CPACK_PACKAGING_INSTALL_PREFIX "") set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) else() if(NOT CPACK_PACKAGING_INSTALL_PREFIX) set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") endif() endif() set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "\${CPACK_PACKAGING_INSTALL_PREFIX}" ) # Package name set(package_name rocalution) set(ROCALUTION_CONFIG_DIR "\${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Path placed into ldconfig file") rocm_create_package( NAME ${package_name} DESCRIPTION "Radeon Open Compute library for sparse linear systems" MAINTAINER "rocALUTION Maintainer " LDCONFIG LDCONFIG_DIR ${ROCALUTION_CONFIG_DIR} ) # # ADDITIONAL TARGETS FOR CODE COVERAGE # if(BUILD_CODE_COVERAGE) # # > make coverage_cleanup (clean coverage related files.) # > make coverage GTEST_FILTER=<> # will run: # > make coverage_analysis GTEST_FILTER=<> (analyze tests) # > make coverage_output (generate html documentation) # # # Run coverage analysis # add_custom_target(coverage_analysis COMMAND echo Coverage GTEST_FILTER=\${GTEST_FILTER} COMMAND ./clients/staging/rocalution-test --gtest_filter=\"\${GTEST_FILTER}\" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) add_dependencies(coverage_analysis rocalution) # # Prepare coverage output # This little script is generated because the option '--gcov-tool ' of lcov cannot take arguments. # add_custom_target(coverage_output DEPENDS coverage_analysis COMMAND mkdir -p lcoverage COMMAND echo "\\#!/bin/bash" > llvm-gcov.sh COMMAND echo "\\# THIS FILE HAS BEEN GENERATED" >> llvm-gcov.sh COMMAND printf "exec /opt/rocm/llvm/bin/llvm-cov gcov $$\\@" >> llvm-gcov.sh COMMAND chmod +x llvm-gcov.sh ) # # Generate coverage output. # add_custom_command(TARGET coverage_output COMMAND lcov --directory . --base-directory . --gcov-tool ${CMAKE_BINARY_DIR}/llvm-gcov.sh --capture -o lcoverage/raw_main_coverage.info COMMAND lcov --remove lcoverage/raw_main_coverage.info "'/opt/*'" "'/usr/*'" -o lcoverage/main_coverage.info COMMAND genhtml lcoverage/main_coverage.info --output-directory lcoverage ) add_custom_target(coverage DEPENDS coverage_output) # # Coverage cleanup # add_custom_target(coverage_cleanup COMMAND find ${CMAKE_BINARY_DIR} -name *.gcda -delete WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) endif() rocALUTION-rocm-5.7.1/LICENSE.md000066400000000000000000000021271445302240700157100ustar00rootroot00000000000000MIT License Copyright (C) 2018-2023 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. rocALUTION-rocm-5.7.1/README.md000066400000000000000000000117731445302240700155720ustar00rootroot00000000000000# rocALUTION rocALUTION is a sparse linear algebra library with focus on exploring fine-grained parallelism on top of AMD's Radeon Open eCosystem Platform [ROCm][] runtime and toolchains, targeting modern CPU and GPU platforms. Based on C++ and [HIP][], it provides a portable, generic and flexible design that allows seamless integration with other scientific software packages. ## Documentation The latest rocALUTION documentation and API description can be found [here][]. ### How to build documentation Run the following steps to build documentation. ``` cd docs pip3 install -r .sphinx/requirements.txt python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html ``` ## Quickstart rocALUTION build #### CMake 3.5 or later All compiler specifications are determined automatically. The compilation process can be performed by ``` # Clone rocALUTION using git git clone https://github.com/ROCmSoftwarePlatform/rocALUTION.git # Go to rocALUTION directory, create and change to build directory cd rocALUTION; mkdir build; cd build # Configure rocALUTION # Build options: # SUPPORT_HIP - build rocALUTION with HIP support (ON) # SUPPORT_OMP - build rocALUTION with OpenMP support (ON) # SUPPORT_MPI - build rocALUTION with MPI (multi-node) support (OFF) # BUILD_SHARED_LIBS - build rocALUTION as shared library (ON, recommended) # BUILD_EXAMPLES - build rocALUTION examples (ON) cmake .. -DSUPPORT_HIP=ON -DROCM_PATH=/opt/rocm/ # Build make ``` #### Simple test You can test the installation by running a CG solver on a Laplace matrix: ``` cd rocALUTION; cd build wget ftp://math.nist.gov/pub/MatrixMarket2/Harwell-Boeing/laplace/gr_30_30.mtx.gz gzip -d gr_30_30.mtx.gz ./clients/staging/cg gr_30_30.mtx ``` ## Overview #### Backends rocALUTION offers various backends for different (parallel) hardware. * Host * [OpenMP][] - designed for multi-core CPUs * [HIP][] - designed for ROCm compatible devices * [MPI][] - designed for multi-node clusters and multi-GPU setups #### Easy to use Syntax and structure of the library provide fast learning curves. With the help of the examples, anyone can try out the library - no knowledge in multi-core or GPU programming is required. #### Requirements There are no hardware requirements to install and run rocALUTION. If GPU devices are available, rocALUTION will use them. In order to use rocALUTION on GPU devices, you will need to make sure that [rocBLAS][], [rocSPARSE][] and [rocRAND][] libraries are installed on your system. You can install them from ROCm repository, from github releases tab or manually compile them yourself. #### Iterative solvers * Fixed-Point iteration schemes - Jacobi, (Symmetric) Gauss-Seidel, SOR, SSOR * Krylov subspace methods - CR, CG, BiCGStab, BiCGStab(*l*), GMRES, IDR, QMRCGSTAB, Flexible CG/GMRES * Mixed-precision defect-correction scheme * Chebyshev iteration scheme * Multigrid - geometric and algebraic #### Preconditioners * Matrix splitting schemes - Jacobi, (multi-colored) (symmetric) Gauss-Seidel, SOR, SSOR * Factorization schemes - ILU(*0*), ILU(*p*) (based on levels), ILU(*p,q*) (power(*q*)-pattern method), multi-elimination ILU (nested/recursive), ILUT (based on threshold), IC(*0*) * Approximate Inverses - Chebyshev matrix-valued polynomial, SPAI, FSAI, TNS * Diagonal-based preconditioner for Saddle-point problems * Block-type of sub-preconditioners/solvers * (Restricted) Additive Schwarz * Variable type of preconditioners #### Sparse matrix formats * Compressed Sparse Row (CSR) * Modified Compressed Sparse Row (MCSR) * Dense (DENSE) * Coordinate (COO) * ELL * Diagonal (DIA) * Hybrid ELL+COO (HYB) #### Generic and robust design rocALUTION is based on a generic and robust design, allowing expansion in the direction of new solvers and preconditioners and support for various hardware types. Furthermore, the design of the library allows the use of all solvers as preconditioners in other solvers, for example you can define a CG solver with a multi-elimination preconditioner, where the last-block is preconditioned with another Chebyshev iteration method which is preconditioned with a multi-colored symmetric Gauss-Seidel scheme. #### Portable code and results All code based on rocALUTION is portable and independent of the hardware, it will compile and run on any supported platform. All solvers and preconditioners are based on a single source code implementation, which delivers portable results across all backends (variations are possible due to different rounding modes on the hardware). The only difference which you can see for a hardware change is the performance variation. [ROCm]: https://github.com/RadeonOpenCompute/ROCm [HIP]: https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/ [OpenMP]: http://www.openmp.org/ [MPI]: https://www.open-mpi.org/ [rocBLAS]: https://github.com/ROCmSoftwarePlatform/rocBLAS [rocSPARSE]: https://github.com/ROCmSoftwarePlatform/rocSPARSE [rocRAND]: https://github.com/ROCmSoftwarePlatform/rocRAND [here]: https://rocalution.readthedocs.io rocALUTION-rocm-5.7.1/clients/000077500000000000000000000000001445302240700157435ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/clients/CMakeLists.txt000066400000000000000000000064661445302240700205170ustar00rootroot00000000000000# ######################################################################## # Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ######################################################################## # The ROCm platform requires Ubuntu 16.04 or Fedora 24, which has cmake 3.5 cmake_minimum_required(VERSION 3.5 FATAL_ERROR) # Consider removing this in the future # This should appear before the project command, because it does not use FORCE if(WIN32) set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories") else() set(CMAKE_INSTALL_PREFIX ${ROCM_PATH} CACHE PATH "Install path prefix, prepended onto install directories") endif() # This has to be initialized before the project() command appears # Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE if(NOT DEFINED CMAKE_CONFIGURATION_TYPES AND NOT DEFINED CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel.") endif() # This option only works for make/nmake and the ninja generators, but no reason it shouldn't be on all the time # This tells cmake to create a compile_commands.json file that can be used with clang tooling or vim set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Build flags set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) if(NOT TARGET rocalution) # This project may compile dependencies for clients project(rocalution-clients LANGUAGES CXX) find_package(rocalution REQUIRED CONFIG PATHS ${ROCM_PATH}/rocalution) get_target_property(depends roc::rocalution INTERFACE_LINK_LIBRARIES) # Check for MPI build foreach(i ${depends}) if("MPI::MPI_CXX" STREQUAL ${i}) set(SUPPORT_MPI ON) find_package(MPI REQUIRED) endif() endforeach() option(BUILD_CLIENTS_SAMPLES "Build examples." ON) option(BUILD_CLIENTS_BENCHMARKS "Build benchmarks." OFF) option(BUILD_CLIENTS_TESTS "Build tests." OFF) endif() if(BUILD_CLIENTS_SAMPLES) add_subdirectory(samples) endif() if(BUILD_CLIENTS_BENCHMARKS) add_subdirectory(benchmarks) endif() if(BUILD_CLIENTS_TESTS) enable_testing() add_subdirectory(tests) endif() rocALUTION-rocm-5.7.1/clients/benchmarks/000077500000000000000000000000001445302240700200605ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/clients/benchmarks/CMakeLists.txt000066400000000000000000000047051445302240700226260ustar00rootroot00000000000000# ######################################################################## # Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ######################################################################## set(ROCALUTION_BENCHMARK_SOURCES client.cpp rocalution_arguments_config.cpp rocalution_bench.cpp rocalution_bench_solver_parameters.cpp rocalution_bench_solver_results.cpp rocalution_enum_coarsening_strategy.cpp rocalution_enum_directsolver.cpp rocalution_enum_itsolver.cpp rocalution_enum_matrix_init.cpp rocalution_enum_preconditioner.cpp rocalution_enum_smoother.cpp rocalution_bench_cmdlines.cpp rocalution_bench_app.cpp ) add_executable(rocalution-bench ${ROCALUTION_BENCHMARK_SOURCES} ${ROCALUTION_CLIENTS_COMMON}) # Target compile options target_compile_options(rocalution-bench PRIVATE -Wno-unused-command-line-argument -Wall) # Internal common header target_include_directories(rocalution-bench PRIVATE $) # Target link libraries target_link_libraries(rocalution-bench PRIVATE roc::rocalution) if(NOT TARGET rocalution) set_target_properties(rocalution-bench PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging") else() set_target_properties(rocalution-bench PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/clients/staging") endif() rocm_install(TARGETS rocalution-bench COMPONENT benchmarks) rocALUTION-rocm-5.7.1/clients/benchmarks/client.cpp000066400000000000000000000075541445302240700220550ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution/rocalution.hpp" #include "rocalution_bench.hpp" #include "utility.hpp" #include #include "rocalution_bench_app.hpp" // // REQUIRED ROUTINES: // bool rocalution_bench_record_results(const rocalution_bench_solver_parameters& params, const rocalution_bench_solver_results& results) { auto* s_bench_app = rocalution_bench_app::instance(); if(s_bench_app) { return s_bench_app->record_results(params, results); } else { params.WriteNicely(std::cout); results.WriteNicely(std::cout); return true; } } int device = 0; int main(int argc, char* argv[]) { if(rocalution_bench_app::applies(argc, argv)) { std::cout << "main " << std::endl; try { auto* s_bench_app = rocalution_bench_app::instance(argc, argv); // // RUN CASES. // bool success = s_bench_app->run_cases(); if(!success) { std::cout << "ERROR SUCCESS FAILURE client.cpp line " << __LINE__ << std::endl; return !success; } // // EXPORT FILE. // success = s_bench_app->export_file(); if(!success) { std::cout << "ERROR SUCCESS FAILURE client.cpp line " << __LINE__ << std::endl; return !success; } return !success; } catch(const bool& success) { std::cout << "ERROR SUCCESS EXCEPTION FAILURE client.cpp line " << __LINE__ << std::endl; return !success; } catch(const std::exception&) { std::cout << "ERROR UNKNOWN EXCEPTION FAILURE client.cpp line " << __LINE__ << std::endl; throw; } } else { try { rocalution_bench bench(argc, argv); // // Print info devices. // bench.info_devices(std::cout); // // Run benchmark. // bool success = bench.run(); if(!success) { std::cout << "ERROR SUCCESS FAILURE client.cpp line " << __LINE__ << std::endl; return !success; } return !success; } catch(const std::exception&) { std::cout << "ERROR UNKNOWN EXCEPTION FAILURE client.cpp line " << __LINE__ << std::endl; throw; } } return 0; } rocALUTION-rocm-5.7.1/clients/benchmarks/program_options.hpp000066400000000000000000000302341445302240700240150ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * ************************************************************************ */ // This emulates the required functionality of boost::program_options #pragma once #include #include #include #include #include #include #include #include #include #include // Regular expression for token delimiters (whitespace and commas) static const std::regex program_options_regex{"[, \\f\\n\\r\\t\\v]+", std::regex_constants::optimize}; // variables_map is a set of seen options using variables_map = std::set; // Polymorphic base class to use with dynamic_cast class value_base { protected: bool m_has_default = false; public: bool has_default() const { return m_has_default; } virtual ~value_base() = default; }; // Value parameters template class value : public value_base { T* m_var; // Pointer to variable to be modified public: // Constructor explicit value(T* var) : m_var(var) { } // Pointer to variable T* get_ptr() const { return m_var; } // Allows default_value() value* operator->() { return this; } // Set default value value& default_value(T val) { *m_var = std::move(val); m_has_default = true; return *this; } }; // bool_switch is a value, which is handled specially using bool_switch = value; class options_description { // desc_option describes a particular option class desc_option { std::string m_opts; value_base* m_val; std::string m_desc; public: // Constructor with options, value and description template desc_option(std::string opts, value val, std::string desc) : m_opts(std::move(opts)) , m_val(new auto(std::move(val))) , m_desc(std::move(desc)) { } // Constructor with options and description desc_option(std::string opts, std::string desc) : m_opts(std::move(opts)) , m_val(nullptr) , m_desc(std::move(desc)) { } // Copy constructor is deleted desc_option(const desc_option&) = delete; // Move constructor desc_option(desc_option&& other) : m_opts(std::move(other.m_opts)) , m_val(other.m_val) , m_desc(std::move(other.m_desc)) { other.m_val = nullptr; } // Destructor ~desc_option() { delete m_val; } // Accessors const std::string& get_opts() const { return m_opts; } const value_base* get_val() const { return m_val; } const std::string& get_desc() const { return m_desc; } // Set a value void set_val(int& argc, char**& argv) const { // We test all supported types with dynamic_cast and parse accordingly bool match = false; if(dynamic_cast*>(m_val)) { auto* val = dynamic_cast*>(m_val)->get_ptr(); match = argc && sscanf(*argv, "%" SCNd32, val) == 1; } else if(dynamic_cast*>(m_val)) { auto* val = dynamic_cast*>(m_val)->get_ptr(); match = argc && sscanf(*argv, "%" SCNu32, val) == 1; } else if(dynamic_cast*>(m_val)) { auto* val = dynamic_cast*>(m_val)->get_ptr(); match = argc && sscanf(*argv, "%" SCNd64, val) == 1; } else if(dynamic_cast*>(m_val)) { auto* val = dynamic_cast*>(m_val)->get_ptr(); match = argc && sscanf(*argv, "%" SCNu64, val) == 1; } else if(dynamic_cast*>(m_val)) { auto* val = dynamic_cast*>(m_val)->get_ptr(); match = argc && sscanf(*argv, "%f", val) == 1; } else if(dynamic_cast*>(m_val)) { auto* val = dynamic_cast*>(m_val)->get_ptr(); match = argc && sscanf(*argv, "%lf", val) == 1; } else if(dynamic_cast*>(m_val)) { auto* val = dynamic_cast*>(m_val)->get_ptr(); match = argc && sscanf(*argv, " %c", val) == 1; } else if(dynamic_cast*>(m_val)) { // We handle bool specially, setting the value to true without argument auto* val = dynamic_cast*>(m_val)->get_ptr(); *val = true; return; } else if(dynamic_cast*>(m_val)) { if(argc) { *dynamic_cast*>(m_val)->get_ptr() = *argv; match = true; } } else { throw std::logic_error("Internal error: Unsupported data type"); } if(!match) throw std::invalid_argument(argc ? *argv : "Missing required argument"); // Skip past the argument's value ++argv; --argc; } }; // Description and option list std::string m_desc; std::vector m_optlist; // desc_optionlist allows chains of options to be parenthesized class desc_optionlist { std::vector& m_list; public: explicit desc_optionlist(std::vector& list) : m_list(list) { } template desc_optionlist operator()(Ts&&... arg) { m_list.push_back(desc_option(std::forward(arg)...)); return *this; } }; public: // Constructor explicit options_description(std::string desc) : m_desc(std::move(desc)) { } // Start a desc_optionlist chain desc_optionlist add_options() & { return desc_optionlist(m_optlist); } // Parse an option at the current (argc, argv) position void parse_option(int& argc, char**& argv, variables_map& vm, bool ignoreUnknown = false) const { // Iterate across all options for(const auto& opt : m_optlist) { // Canonical name used for map std::string canonical_name; // Iterate across tokens in the opts for(std::sregex_token_iterator tok{ opt.get_opts().begin(), opt.get_opts().end(), program_options_regex, -1}; tok != std::sregex_token_iterator(); ++tok) { // The first option in a list of options is the canonical name if(!canonical_name.length()) canonical_name = tok->str(); // If the length of the option is 1, it is single-dash; otherwise double-dash const char* prefix = tok->length() == 1 ? "-" : "--"; // If option matches if(*argv == prefix + tok->str()) { ++argv; --argc; // If option has a value, set it; otherwise indicate option in set if(opt.get_val()) opt.set_val(argc, argv); else vm.insert(canonical_name); return; // Return successfully } } } // No options were matched if(ignoreUnknown) { ++argv; --argc; } else { throw std::invalid_argument(*argv); } } // Formatted output of command-line arguments description friend std::ostream& operator<<(std::ostream& os, const options_description& d) { // Iterate across all options for(const auto& opt : d.m_optlist) { bool first = true; const char* delim = ""; std::ostringstream left; // Iterate across tokens in the opts for(std::sregex_token_iterator tok{opt.get_opts().begin(), opt.get_opts().end(), program_options_regex, -1}; tok != std::sregex_token_iterator(); ++tok, first = false, delim = " ") { // If the length of the option is 1, it is single-dash; otherwise double-dash const char* prefix = tok->length() == 1 ? "-" : "--"; left << delim << (first ? "" : "[ ") << prefix << tok->str() << (first ? "" : " ]"); } // Print the default value of the variable type if it exists // We do not print the default value for bool const value_base* val = opt.get_val(); if(val && !dynamic_cast*>(val)) { left << " arg"; if(val->has_default()) { // We test all supported types with dynamic_cast and print accordingly left << " (="; if(dynamic_cast*>(val)) left << *dynamic_cast*>(val)->get_ptr(); else if(dynamic_cast*>(val)) left << *dynamic_cast*>(val)->get_ptr(); else if(dynamic_cast*>(val)) left << *dynamic_cast*>(val)->get_ptr(); else if(dynamic_cast*>(val)) left << *dynamic_cast*>(val)->get_ptr(); else if(dynamic_cast*>(val)) left << *dynamic_cast*>(val)->get_ptr(); else if(dynamic_cast*>(val)) left << *dynamic_cast*>(val)->get_ptr(); else if(dynamic_cast*>(val)) left << *dynamic_cast*>(val)->get_ptr(); else if(dynamic_cast*>(val)) left << *dynamic_cast*>(val)->get_ptr(); else throw std::logic_error("Internal error: Unsupported data type"); left << ")"; } } os << std::setw(36) << std::left << left.str() << " " << opt.get_desc() << "\n\n"; } return os << std::flush; } }; // Class representing command line parser class parse_command_line { variables_map m_vm; public: parse_command_line(int argc, char** argv, const options_description& desc, bool ignoreUnknown = false) { ++argv; // Skip argv[0] --argc; while(argc) desc.parse_option(argc, argv, m_vm, ignoreUnknown); } // Copy the variables_map friend void store(const parse_command_line& p, variables_map& vm) { vm = p.m_vm; } // Move the variables_map friend void store(parse_command_line&& p, variables_map& vm) { vm = std::move(p.m_vm); } }; // We can define the notify() function as a no-op for our purposes inline void notify(const variables_map&) {} rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_arguments_config.cpp000066400000000000000000000257171445302240700263710ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_arguments_config.hpp" #include "rocalution_bench_solver.hpp" // // // rocalution_arguments_config::rocalution_arguments_config() {} std::string make_option(const char* name) { std::string s(name); for(size_t i = 0; i < s.length(); ++i) { if(s[i] == '_') s[i] = '-'; } return s; } // // // void rocalution_arguments_config::set_description(options_description& desc) { desc.add_options()("help,h", "produces this help message"); #define ADD_OPTION(type_, e_, x_default_, x_desc_) \ desc.add_options()(make_option(rocalution_bench_solver_parameters::GetName(e_)), \ value(this->GetPointer(e_))->default_value(x_default_), \ x_desc_) for(auto e : rocalution_bench_solver_parameters::e_double_all) { switch(e) { case rocalution_bench_solver_parameters::abs_tol: { ADD_OPTION(double, e, 1.0e-6, "absolute tolerance"); break; } case rocalution_bench_solver_parameters::rel_tol: { ADD_OPTION(double, e, 0.0, "relative tolerance"); break; } case rocalution_bench_solver_parameters::div_tol: { ADD_OPTION(double, e, 1e+8, "divide tolerance"); break; } case rocalution_bench_solver_parameters::residual_tol: { ADD_OPTION(double, e, 1.0e-8, "residual tolerance"); break; } case rocalution_bench_solver_parameters::ilut_tol: { ADD_OPTION(double, e, 0.05, "ilut tolerance"); break; } case rocalution_bench_solver_parameters::mcgs_relax: { ADD_OPTION(double, e, 1.0, "relaxation coefficient"); break; } case rocalution_bench_solver_parameters::solver_over_interp: { ADD_OPTION(double, e, 1.2, "over interp coefficient for multigrid"); break; } case rocalution_bench_solver_parameters::solver_coupling_strength: { ADD_OPTION(double, e, 0.005, "coupling strength coefficient for multigrid"); break; } } } for(auto e : rocalution_bench_solver_parameters::e_int_all) { switch(e) { case rocalution_bench_solver_parameters::krylov_basis: { ADD_OPTION(int, e, 30, "dimension of the Krylov basis."); break; } case rocalution_bench_solver_parameters::max_iter: { ADD_OPTION(int, e, 2000, "default maximum number of iterations."); break; } case rocalution_bench_solver_parameters::ndim: { ADD_OPTION(int, e, 200, "dimension"); break; } case rocalution_bench_solver_parameters::solver_pre_smooth: { ADD_OPTION(int, e, 2, "number of iteration of pre-smoother"); break; } case rocalution_bench_solver_parameters::solver_post_smooth: { ADD_OPTION(int, e, 2, "number of iteration of post-smoother"); break; } case rocalution_bench_solver_parameters::solver_ordering: { ADD_OPTION(int, e, 1, "ordering type"); break; } case rocalution_bench_solver_parameters::rebuild_numeric: { ADD_OPTION(int, e, 0, "rebuild numeric"); break; } case rocalution_bench_solver_parameters::cycle: { ADD_OPTION(int, e, 0, "Number of cycle"); break; } case rocalution_bench_solver_parameters::ilut_n: { ADD_OPTION(int, e, 4, "number of elements per row kept"); break; } case rocalution_bench_solver_parameters::mcilu_p: { ADD_OPTION(int, e, 0, "multicolored ilu parameter p."); break; } case rocalution_bench_solver_parameters::mcilu_q: { ADD_OPTION(int, e, 0, "multicolored ilu parameter q."); break; } case rocalution_bench_solver_parameters::solver_coarsest_level: { ADD_OPTION(int, e, 200, "multigrid coarsest_level."); break; } case rocalution_bench_solver_parameters::blockdim: { ADD_OPTION(int, e, 3, "block dimension."); break; } } } for(auto e : rocalution_bench_solver_parameters::e_string_all) { switch(e) { case rocalution_bench_solver_parameters::matrix_filename: { ADD_OPTION(std::string, e, "", "read from matrix " "market (.mtx) format. This will override parameters -m, -n, and -z."); break; } case rocalution_bench_solver_parameters::smoother: { ADD_OPTION(std::string, e, "", "solver smoother"); break; } case rocalution_bench_solver_parameters::iterative_solver: { ADD_OPTION(std::string, e, "", "iterative solver"); break; } case rocalution_bench_solver_parameters::direct_solver: { ADD_OPTION(std::string, e, "", "direct solver"); break; } case rocalution_bench_solver_parameters::preconditioner: { ADD_OPTION(std::string, e, "", "preconditioner"); break; } case rocalution_bench_solver_parameters::coarsening_strategy: { ADD_OPTION(std::string, e, "", "coarsening strategy"); break; } case rocalution_bench_solver_parameters::matrix: { ADD_OPTION(std::string, e, "", "matrix initialization"); break; } } } for(auto e : rocalution_bench_solver_parameters::e_uint_all) { switch(e) { case rocalution_bench_solver_parameters::format: { ADD_OPTION(unsigned int, e, CSR, "matrix format"); break; } } } for(auto e : rocalution_bench_solver_parameters::e_bool_all) { switch(e) { case rocalution_bench_solver_parameters::verbose: { ADD_OPTION(bool, e, false, "verbose"); break; } case rocalution_bench_solver_parameters::mcilu_use_level: { ADD_OPTION(bool, e, false, "use level in mcilu"); break; } } } } // // // int rocalution_arguments_config::parse(int& argc, char**& argv, options_description& desc) { variables_map vm; store(parse_command_line(argc, argv, desc, sizeof(rocalution_arguments_config)), vm); notify(vm); if(vm.count("help")) { std::cout << desc << std::endl; return 0; } // // Init enums. // for(auto e : rocalution_bench_solver_parameters::e_string_all) { switch(e) { case rocalution_bench_solver_parameters::matrix_filename: { break; } case rocalution_bench_solver_parameters::smoother: { auto smoother_string = this->Get(rocalution_bench_solver_parameters::smoother); if(smoother_string != "") { this->m_enum_smoother(smoother_string.c_str()); } break; } case rocalution_bench_solver_parameters::iterative_solver: { auto iterative_solver_string = this->Get(rocalution_bench_solver_parameters::iterative_solver); if(iterative_solver_string != "") { this->m_enum_itsolver(iterative_solver_string.c_str()); } break; } case rocalution_bench_solver_parameters::direct_solver: { auto direct_solver_string = this->Get(rocalution_bench_solver_parameters::direct_solver); if(direct_solver_string != "") { this->m_enum_directsolver(direct_solver_string.c_str()); } break; } case rocalution_bench_solver_parameters::preconditioner: { auto preconditioner_string = this->Get(rocalution_bench_solver_parameters::preconditioner); if(preconditioner_string != "") { this->m_enum_preconditioner(preconditioner_string.c_str()); } break; } case rocalution_bench_solver_parameters::coarsening_strategy: { auto coarsening_strategy_string = this->Get(rocalution_bench_solver_parameters::coarsening_strategy); if(coarsening_strategy_string != "") { this->m_enum_coarsening_strategy(coarsening_strategy_string.c_str()); } break; } case rocalution_bench_solver_parameters::matrix: { auto matrix_init_string = this->Get(rocalution_bench_solver_parameters::matrix); if(matrix_init_string != "") { this->m_enum_matrix_init(matrix_init_string.c_str()); } break; } } } return 0; } // // // int rocalution_arguments_config::parse_no_default(int& argc, char**& argv, options_description& desc) { variables_map vm; store(parse_command_line(argc, argv, desc), vm); notify(vm); if(vm.count("help")) { std::cout << desc << std::endl; return 0; } return 0; } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_arguments_config.hpp000066400000000000000000000042311445302240700263620ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include #include #include "program_options.hpp" #include "utility.hpp" #include "rocalution_bench_solver_parameters.hpp" // // @brief Class as an extension of Arguments to deal with the rocalution_bench. // struct rocalution_arguments_config : rocalution_bench_solver_parameters { char precision; char indextype; std::string function; int device_id; // // @brief Default constructor. // rocalution_arguments_config(); // // @brief Set the description. // void set_description(options_description& desc); // // @brief Parse command line arguments. // int parse(int& argc, char**& argv, options_description& desc); // // @brief Parse command line arguments with no default value. // int parse_no_default(int& argc, char**& argv, options_description& desc); }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench.cpp000066400000000000000000000063461445302240700241130ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_bench.hpp" #include "rocalution_bench_template.hpp" #define TO_STR2(x) #x #define TO_STR(x) TO_STR2(x) std::string rocalution_get_version() { int rocalution_ver = __ROCALUTION_VER; char rocalution_rev[64]; static constexpr char v[] = TO_STR(__ROCALUTION_VER_TWEAK); memcpy(rocalution_rev, v, sizeof(v)); std::ostringstream os; os << rocalution_ver / 100000 << "." << rocalution_ver / 100 % 1000 << "." << rocalution_ver % 100 << "-" << rocalution_rev; return os.str(); } // // // void rocalution_bench::parse(int& argc, char**& argv, rocalution_arguments_config& config) { config.set_description(this->desc); config.precision = 's'; config.indextype = 's'; config.parse(argc, argv, this->desc); } // // // rocalution_bench::rocalution_bench() : desc("rocalution client command line options") { } // // Execute the benchmark. // bool rocalution_bench::execute() { // // Set up rocalution. // set_device_rocalution(device); init_rocalution(); // // Run the benchmark. // bool success; success = rocalution_bench_template(this->config); if(!success) { rocalution_bench_errmsg << "rocalution_bench_template failed." << std::endl; } // // Stop rocalution. // stop_rocalution(); return success; } // // // rocalution_bench::rocalution_bench(int& argc, char**& argv) : desc("rocalution client command line options") { // // Parse the command line for configuration. // this->parse(argc, argv, this->config); } rocalution_bench& rocalution_bench::operator()(int& argc, char**& argv) { this->parse(argc, argv, this->config); return *this; } // // Run (execute). // bool rocalution_bench::run() { return this->execute(); } int rocalution_bench::get_device_id() const { return this->config.device_id; } void rocalution_bench::info_devices(std::ostream& out_) const {} rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench.hpp000066400000000000000000000051261445302240700241130ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_arguments_config.hpp" #include "rocalution_enum_itsolver.hpp" // // @brief Class responsible of configuring the benchmark from parsing command line arguments // and execute it. // class rocalution_bench { public: // // @brief Default contructor. // rocalution_bench(); // // @brief Contructor with command line arguments. // rocalution_bench(int& argc, char**& argv); // // @brief Parenthesis operator equivalent to the contructor. // rocalution_bench& operator()(int& argc, char**& argv); // // @brief Run the benchmark. // bool run(); // // @brief Execute the benchmark. // bool execute(); // // @brief Get device id. // int get_device_id() const; // // @brief Get info devices. // void info_devices(std::ostream& out_) const; private: // // @brief Convert the command line arguments to rocalution_arguments_config. // void parse(int& argc, char**& argv, rocalution_arguments_config& config); // // @brief Description of the command line options. // options_description desc; // // @brief Configuration of the benchmark. // rocalution_arguments_config config; }; // // @brief Get rocalution version. // std::string rocalution_get_version(); rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_app.cpp000066400000000000000000000363241445302240700247520ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_bench_app.hpp" #include "rocalution_bench.hpp" #include #include #include rocalution_bench_app* rocalution_bench_app::s_instance = nullptr; rocalution_bench_app_base::rocalution_bench_app_base(int argc, char** argv) : m_initial_argc(rocalution_bench_app_base::save_initial_cmdline(argc, argv, &m_initial_argv)) , m_bench_cmdlines(argc, argv) , m_bench_timing(m_bench_cmdlines.get_nsamples(), m_bench_cmdlines.get_nruns()) {}; bool rocalution_bench_app_base::run_case(int isample, int irun, int argc, char** argv) { rocalution_bench bench(argc, argv); return bench.run(); } bool rocalution_bench_app_base::run_cases() { int sample_argc; char** sample_argv = nullptr; // // Loop over cases. // int nruns = this->m_bench_cmdlines.get_nruns(); int nsamples = this->m_bench_cmdlines.get_nsamples(); this->m_stdout_skip_legend = false; if(is_stdout_disabled()) { printf("// start benchmarking ... (nsamples = %d, nruns = %d)\n", nsamples, nruns); } bool status = true; for(int isample = 0; isample < nsamples; ++isample) { this->m_isample = isample; // // Add an item to collect data through rocalution_record_timing // for(int irun = 0; irun < nruns; ++irun) { this->m_irun = irun; if(false == this->m_stdout_skip_legend) { this->m_stdout_skip_legend = (irun > 0 && isample == 0); } // // Get command line arguments, copy each time since it is mutable afterwards. // if(sample_argv == nullptr) { this->m_bench_cmdlines.get_argc(this->m_isample, sample_argc); sample_argv = new char*[sample_argc]; } this->m_bench_cmdlines.get(this->m_isample, sample_argc, sample_argv); // // Run the case. // status &= this->run_case(this->m_isample, this->m_irun, sample_argc, sample_argv); if(!status) { rocalution_bench_errmsg << "run_cases::run_case failed at line " << __LINE__ << std::endl; break; } if(is_stdout_disabled()) { if((isample * nruns + irun) % 10 == 0) { fprintf(stdout, "\r// %2.0f%%", (double(isample * nruns + irun + 1) / double(nsamples * nruns)) * 100); fflush(stdout); } } } } if(is_stdout_disabled()) { printf("\r// benchmarking done.\n"); } if(sample_argv != nullptr) { delete[] sample_argv; } return status; }; rocalution_bench_app::rocalution_bench_app(int argc, char** argv) : rocalution_bench_app_base(argc, argv) { } rocalution_bench_app::~rocalution_bench_app() {} void rocalution_bench_app::confidence_interval(const double alpha, const int resize, const int nboots, const std::vector& v, double interval[2]) { const size_t size = v.size(); std::vector medians(nboots); std::vector resample(resize); #define median_value(n__, s__) \ ((n__ % 2 == 0) ? (s__[n__ / 2 - 1] + s__[n__ / 2]) * 0.5 : s__[n__ / 2]) std::srand(0); for(int iboot = 0; iboot < nboots; ++iboot) { for(int i = 0; i < resize; ++i) { const int j = (std::rand() % size); resample[i] = v[j]; } std::sort(resample.begin(), resample.end()); medians[iboot] = median_value(resize, resample); } std::sort(medians.begin(), medians.end()); interval[0] = medians[int(floor(nboots * 0.5 * (1.0 - alpha)))]; interval[1] = medians[int(ceil(nboots * (1.0 - 0.5 * (1.0 - alpha))))]; #undef median_value } void rocalution_bench_app::series_lower_upper(int N, const std::vector& r, rocalution_bench_solver_results::e_double e, double& median, double& lower, double& upper) { static constexpr double alpha = 0.95; std::vector s(N); for(int i = 0; i < N; ++i) { s[i] = r[i].Get(e); } std::sort(s.begin(), s.end()); double interval[2]; static constexpr int nboots = 200; confidence_interval(alpha, 10, nboots, s, interval); median = (N % 2 == 0) ? (s[N / 2 - 1] + s[N / 2]) * 0.5 : s[N / 2]; lower = interval[0]; upper = interval[1]; } void rocalution_bench_app::export_item(std::ostream& out, rocalution_bench_timing_t::item_t& item) { out << " \"setup\" : { "; item.m_parameters.WriteJson(out); out << " }," << std::endl; // // // auto N = item.m_nruns; if(N > 1) { rocalution_bench_solver_results res; rocalution_bench_solver_results res_low; rocalution_bench_solver_results res_up; for(auto e : rocalution_bench_solver_results::e_bool_all) { for(int i = 0; i < N; ++i) { if(item.m_results[i].Get(e) != item.m_results[0].Get(e)) { std::cerr << "WARNING/ERROR Boolean result '" << rocalution_bench_solver_results::Name(e) << "' is not constant over runs." << std::endl; } } res.Set(e, item.m_results[0].Get(e)); res_low.Set(e, item.m_results[0].Get(e)); res_up.Set(e, item.m_results[0].Get(e)); } for(auto e : rocalution_bench_solver_results::e_int_all) { for(int i = 0; i < N; ++i) { if(item.m_results[i].Get(e) != item.m_results[0].Get(e)) { std::cerr << "WARNING/ERROR Integer result '" << rocalution_bench_solver_results::Name(e) << "' is not constant over runs." << std::endl; } } res.Set(e, item.m_results[0].Get(e)); res_low.Set(e, item.m_results[0].Get(e)); res_up.Set(e, item.m_results[0].Get(e)); } for(auto e : rocalution_bench_solver_results::e_double_all) { double median; double lower; double upper; series_lower_upper(N, item.m_results, e, median, lower, upper); res.Set(e, median); res_low.Set(e, lower); res_up.Set(e, upper); } out << " \"nsamples\": \"" << N << "\"," << std::endl; out << " \"median\" : { "; res.WriteJson(out); out << " }," << std::endl; out << " \"low\" : { "; res_low.WriteJson(out); out << " }," << std::endl; out << " \"up\" : { "; res_up.WriteJson(out); out << " }" << std::endl; } else { out << " \"nsamples\": \"" << N << "\"," << std::endl; out << " \"median\" : { "; item.m_results[0].WriteJson(out); out << " }," << std::endl; out << " \"low\" : { "; item.m_results[0].WriteJson(out); out << " }," << std::endl; out << " \"up\" : { "; item.m_results[0].WriteJson(out); out << " }" << std::endl; } } bool rocalution_bench_app::export_file() { const char* ofilename = this->m_bench_cmdlines.get_ofilename(); if(ofilename == nullptr) { std::cerr << "//" << std::endl; std::cerr << "// rocalution_bench_app warning: no output filename has been specified," << std::endl; std::cerr << "// default output filename is 'a.json'." << std::endl; std::cerr << "//" << std::endl; ofilename = "a.json"; } std::ofstream out(ofilename); int sample_argc; char* sample_argv[64]; bool status; // // Write header. // status = define_results_json(out); if(!status) { rocalution_bench_errmsg << "run_cases failed at line " << __LINE__ << std::endl; return status; } // // Loop over cases. // const int nsamples = m_bench_cmdlines.get_nsamples(); const int bench_timing_size = m_bench_timing.size(); if(nsamples != bench_timing_size) { rocalution_bench_errmsg << "incompatible sizes at line " << __LINE__ << " " << nsamples << " " << bench_timing_size << std::endl; if(bench_timing_size == 0) { rocalution_bench_errmsg << "No data has been harvested from running case" << std::endl; } exit(1); } for(int isample = 0; isample < nsamples; ++isample) { this->m_bench_cmdlines.get(isample, sample_argc, sample_argv); this->define_case_json(out, isample, sample_argc, sample_argv); out << "{ "; { this->export_item(out, this->m_bench_timing[isample]); } out << " }"; this->close_case_json(out, isample, sample_argc, sample_argv); } // // Write footer. // status = this->close_results_json(out); if(!status) { rocalution_bench_errmsg << "run_cases failed at line " << __LINE__ << std::endl; return status; } out.close(); return true; } bool rocalution_bench_app::define_case_json(std::ostream& out, int isample, int argc, char** argv) { if(isample > 0) out << "," << std::endl; out << std::endl; out << "{ \"cmdline\": \""; out << argv[0]; for(int i = 1; i < argc; ++i) out << " " << argv[i]; out << " \"," << std::endl; out << " \"timing\": "; return true; } bool rocalution_bench_app::close_case_json(std::ostream& out, int isample, int argc, char** argv) { out << " }"; return true; } bool rocalution_bench_app::define_results_json(std::ostream& out) { out << "{" << std::endl; auto end = std::chrono::system_clock::now(); std::time_t end_time = std::chrono::system_clock::to_time_t(end); char* str = std::ctime(&end_time); for(int i = 0; i >= 0; ++i) if(str[i] == '\n') { str[i] = '\0'; break; } out << "\"date\": \"" << str << "\"," << std::endl; out << std::endl << "\"cmdline\": \"" << this->m_initial_argv[0]; for(int i = 1; i < this->m_initial_argc; ++i) { out << " " << this->m_initial_argv[i]; } out << "\"," << std::endl; int option_index_x = this->m_bench_cmdlines.get_option_index_x(); out << std::endl << "\"xargs\": \["; for(int j = 0; j < this->m_bench_cmdlines.get_option_nargs(option_index_x); ++j) { auto arg = this->m_bench_cmdlines.get_option_arg(option_index_x, j); if(j > 0) out << ", "; out << "\"" << arg << "\""; } out << "]," << std::endl; out << std::endl << "\"yargs\":"; // // Harvest expanded options. // std::vector y_options_size; std::vector y_options_index; for(int k = 0; k < this->m_bench_cmdlines.get_noptions(); ++k) { if(k != option_index_x) { if(this->m_bench_cmdlines.get_option_nargs(k) > 1) { y_options_index.push_back(k); y_options_size.push_back(this->m_bench_cmdlines.get_option_nargs(k)); } } } const int num_y_options = y_options_index.size(); if(num_y_options > 0) { std::vector> indices(num_y_options); for(int k = 0; k < num_y_options; ++k) { indices[k].resize(y_options_size[k], 0); } } int nplots = this->m_bench_cmdlines.get_nsamples() / this->m_bench_cmdlines.get_option_nargs(option_index_x); std::vector plot_titles(nplots); if(plot_titles.size() == 1) { plot_titles.push_back(""); } else { int n = y_options_size[0]; auto argname0 = this->m_bench_cmdlines.get_option_name(y_options_index[0]); for(int iplot = 0; iplot < nplots; ++iplot) { std::string title(""); int p = n; { int jref = iplot % p; auto arg0 = this->m_bench_cmdlines.get_option_arg(y_options_index[0], jref); title += std::string(argname0 + ((argname0[1] == '-') ? 2 : 1)) + std::string("=") + arg0; } for(int k = 1; k < num_y_options; ++k) { int kref = iplot / p; p *= this->m_bench_cmdlines.get_option_nargs(y_options_index[k]); auto arg = this->m_bench_cmdlines.get_option_arg(y_options_index[k], kref); auto argname = this->m_bench_cmdlines.get_option_name(y_options_index[k]); title += std::string(",") + std::string(argname + ((argname[1] == '-') ? 2 : 1)) + std::string("=") + arg; } plot_titles[iplot] = title; } } out << "["; { out << "\"" << plot_titles[0] << "\""; for(int iplot = 1; iplot < nplots; ++iplot) out << ", \"" << plot_titles[iplot] << "\""; } out << "]," << std::endl << std::endl; ; out << "\"" << "results" << "\": ["; return true; } bool rocalution_bench_app::close_results_json(std::ostream& out) { out << "]" << std::endl; out << "}" << std::endl; return true; } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_app.hpp000066400000000000000000000203631445302240700247530ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_arguments_config.hpp" #include "rocalution_bench_cmdlines.hpp" // // only for status // #include "rocalution_bench_solver_results.hpp" struct rocalution_benchfile_format { typedef enum value_type_ : int { json = 0, yaml } value_type; protected: value_type value{json}; public: inline constexpr operator value_type() const { return this->value; }; inline constexpr rocalution_benchfile_format(){}; inline constexpr rocalution_benchfile_format(int ival) : value((value_type)ival) { } static constexpr value_type all[2] = {rocalution_benchfile_format::json, rocalution_benchfile_format::yaml}; inline bool is_invalid() const { switch(this->value) { case json: case yaml: { return false; } } return true; }; inline rocalution_benchfile_format(const char* ext) { if(!strcmp(ext, ".json")) { value = json; } else if(!strcmp(ext, ".JSON")) { value = json; } else if(!strcmp(ext, ".yaml")) { value = yaml; } else if(!strcmp(ext, ".YAML")) { value = yaml; } else value = (value_type)-1; }; inline const char* to_string() const { switch(this->value) { #define CASE(case_name) \ case case_name: \ { \ return #case_name; \ } CASE(json); CASE(yaml); #undef CASE } return "unknown"; } }; // // Struct collecting benchmark timing results. // struct rocalution_bench_timing_t { // // Local item. // struct item_t { int m_nruns{}; std::vector m_results; rocalution_bench_solver_parameters m_parameters{}; item_t(){}; item_t(int nruns_) : m_nruns(nruns_) , m_results(nruns_){}; item_t& operator()(int nruns_) { this->m_nruns = nruns_; this->m_results.resize(nruns_); return *this; }; bool record(const rocalution_bench_solver_parameters& parameters) { m_parameters = parameters; return true; } bool record(int irun, const rocalution_bench_solver_results& results) { if(irun >= 0 && irun < m_nruns) { this->m_results[irun] = results; return true; } else { rocalution_bench_errmsg << "out of bounds from item_t::record " << std::endl; return false; } } }; size_t size() const { return this->m_items.size(); }; item_t& operator[](size_t i) { return this->m_items[i]; } const item_t& operator[](size_t i) const { return this->m_items[i]; } rocalution_bench_timing_t(int nsamples, int nruns_per_sample) : m_items(nsamples) { for(int i = 0; i < nsamples; ++i) { m_items[i](nruns_per_sample); } } private: std::vector m_items; }; class rocalution_bench_app_base { protected: // // Record initial command line. // int m_initial_argc; char** m_initial_argv; // // Set of command lines. // rocalution_bench_cmdlines m_bench_cmdlines; // // // rocalution_bench_timing_t m_bench_timing; bool m_stdout_skip_legend{}; bool m_stdout_disabled{true}; static int save_initial_cmdline(int argc, char** argv, char*** argv_) { argv_[0] = new char*[argc]; for(int i = 0; i < argc; ++i) { argv_[0][i] = argv[i]; } return argc; } // // @brief Constructor. // rocalution_bench_app_base(int argc, char** argv); // // @brief Run case. // bool run_case(int isample, int irun, int argc, char** argv); // // For internal use, to get the current isample and irun. // int m_isample; int m_irun; int get_isample() const { return this->m_isample; }; int get_irun() const { return this->m_irun; }; public: bool is_stdout_disabled() const { return m_bench_cmdlines.is_stdout_disabled(); } bool stdout_skip_legend() const { return this->m_stdout_skip_legend; } // // @brief Run cases. // bool run_cases(); }; class rocalution_bench_app : public rocalution_bench_app_base { private: static rocalution_bench_app* s_instance; public: static rocalution_bench_app* instance(int argc, char** argv) { s_instance = new rocalution_bench_app(argc, argv); return s_instance; } static rocalution_bench_app* instance() { return s_instance; } rocalution_bench_app(const rocalution_bench_app&) = delete; rocalution_bench_app& operator=(const rocalution_bench_app&) = delete; static bool applies(int argc, char** argv) { return rocalution_bench_cmdlines::applies(argc, argv); } rocalution_bench_app(int argc, char** argv); ~rocalution_bench_app(); bool export_file(); bool record_results(const rocalution_bench_solver_parameters& parameters, const rocalution_bench_solver_results& results) { if(this->m_irun == 0) { this->m_bench_timing[this->m_isample].record(parameters); } return this->m_bench_timing[this->m_isample].record(this->m_irun, results); } protected: void export_item(std::ostream& out, rocalution_bench_timing_t::item_t& item); bool define_case_json(std::ostream& out, int isample, int argc, char** argv); bool close_case_json(std::ostream& out, int isample, int argc, char** argv); bool define_results_json(std::ostream& out); bool close_results_json(std::ostream& out); static void confidence_interval(const double alpha, const int resize, const int nboots, const std::vector& v, double interval[2]); static void series_lower_upper(int N, const std::vector& r, rocalution_bench_solver_results::e_double e, double& median, double& lower, double& upper); }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_cmdlines.cpp000066400000000000000000000054321445302240700257640ustar00rootroot00000000000000#include "rocalution_bench_cmdlines.hpp" // // @brief Get the output filename. // const char* rocalution_bench_cmdlines::get_ofilename() const { return this->m_cmd.get_ofilename(); } // // @brief Get the number of samples.. // int rocalution_bench_cmdlines::get_nsamples() const { return this->m_cmd.get_nsamples(); }; int rocalution_bench_cmdlines::get_option_index_x() const { return this->m_cmd.get_option_index_x(); }; int rocalution_bench_cmdlines::get_option_nargs(int i) { return this->m_cmd.get_option_nargs(i); } const char* rocalution_bench_cmdlines::get_option_arg(int i, int j) { return this->m_cmd.get_option_arg(i, j); } const char* rocalution_bench_cmdlines::get_option_name(int i) { return this->m_cmd.get_option_name(i); } int rocalution_bench_cmdlines::get_noptions_x() const { return this->m_cmd.get_noptions_x(); }; int rocalution_bench_cmdlines::get_noptions() const { return this->m_cmd.get_noptions(); }; bool rocalution_bench_cmdlines::is_stdout_disabled() const { return this->m_cmd.is_stdout_disabled(); }; // // @brief Get the number of runs per sample. // int rocalution_bench_cmdlines::get_nruns() const { return this->m_cmd.get_nruns(); }; // // @brief Copy the command line arguments corresponding to a given sample. // void rocalution_bench_cmdlines::get(int isample, int& argc, char** argv) const { const auto& cmdsample = this->m_cmdset[isample]; for(int j = 0; j < cmdsample.argc; ++j) { argv[j] = cmdsample.argv[j]; } argc = cmdsample.argc; } void rocalution_bench_cmdlines::get_argc(int isample, int& argc_) const { argc_ = this->m_cmdset[isample].argc; } // // @brief Constructor. // rocalution_bench_cmdlines::rocalution_bench_cmdlines(int argc, char** argv) : m_cmd(argc, argv) { // // Expand the command line . // this->m_cmdset = new val[this->m_cmd.get_nsamples()]; this->m_cmd.expand(this->m_cmdset); } bool rocalution_bench_cmdlines::applies(int argc, char** argv) { for(int i = 1; i < argc; ++i) { if(!strcmp(argv[i], "--bench-x") || !strcmp(argv[i], "--bench-o") || !strcmp(argv[i], "--bench-n") || !strcmp(argv[i], "--bench-std")) { return true; } } return false; } void rocalution_bench_cmdlines::info() const { int nsamples = this->m_cmd.get_nsamples(); for(int isample = 0; isample < nsamples; ++isample) { const auto& cmdsample = this->m_cmdset[isample]; const auto argc = cmdsample.argc; const auto argv = cmdsample.argv; std::cout << "sample[" << isample << "/" << nsamples << "], argc = " << argc << std::endl; for(int jarg = 0; jarg < argc; ++jarg) { std::cout << " " << argv[jarg]; } std::cout << std::endl; } } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_cmdlines.hpp000066400000000000000000000442411445302240700257720ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include #include #include #include // // @brief The role of this class is to expand a command line into multiple command lines. // @details // // What is expanding a command line into multiple command lines? // Let's consider the following command line './foo -m 10' where option '-m' of ./foo // takes only one argument, here 10. // // An expansion mechanism is implemented in this class to provide the set of command lines // './foo -m 10', // './foo -m 2', // './foo -m 7', // './foo -m -4' // // from: ./foo -m 10 2 7 -4 // // It allows to generate a set of command lines to be useful in a benchmarking context. // // Rules: // - any keyword starting with '-' is considered as an option. // - each option having exactly one argument is subject to a possible expansion, there is no limit on the number of options to expand. // // // Number of command lines generated : product of all the options' number (>=1) of arguments // examples: // cmd: './foo -m 10 2 7 -k 32 -l f -v' gives // './foo -m 10 -k 32 -l f' // './foo -m 2 -k 32 -l f' // './foo -m 7 -k 32 -l f' // num cmds: max(1,3) * max(1,1) * max(1,0) = 3 // cmd: './foo -m 10 2 7 -k 32 64 -l f g' gives // './foo -m 10 -k 32 -l f' // './foo -m 2 -k 32 -l f' // './foo -m 7 -k 32 -l f' // './foo -m 10 -k 64 -l f' // './foo -m 2 -k 64 -l f' // './foo -m 7 -k 64 -l f' // './foo -m 10 -k 32 -l g' // './foo -m 2 -k 32 -l g' // './foo -m 7 -k 32 -l g' // './foo -m 10 -k 64 -l g' // './foo -m 2 -k 64 -l g' // './foo -m 7 -k 64 -l g' // num cmds: max(1,3) * max(1,2) * max(1,2) = 12 // // Specific options: // // option: --bench-x, to precede the option the user want to be the first one. // example // cmd: './foo -m 10 2 7 --bench-x -k 32 64 -l f g' gives // './foo -m 32 -k 10 -l f' // './foo -m 64 -k 10 -l f' // './foo -m 32 -k 2 -l f' // './foo -m 64 -k 2 -l f' // './foo -m 32 -k 7 -l f' // './foo -m 64 -k 7 -l f' // './foo -m 32 -k 10 -l g' // './foo -m 64 -k 10 -l g' // './foo -m 32 -k 2 -l g' // './foo -m 64 -k 2 -l g' // './foo -m 32 -k 7 -l g' // './foo -m 64 -k 7 -l g' // // option: --bench-o, output filename. // option: --bench-n, number of runs. // option: --bench-std, prevent from standard output to be disabled. // class rocalution_bench_cmdlines { private: struct val { // // Everything is public. // public: int argc{}; char** argv{}; ~val() { if(this->argv != nullptr) { delete[] this->argv; this->argv = nullptr; } } val(){}; val(int n) : argc(n) { this->argv = new char*[this->argc]; } val& operator()(int n) { this->argc = n; if(this->argv) { delete[] this->argv; } this->argv = new char*[this->argc]; return *this; } }; struct cmdline { public: // // @brief Return the output filename. // const char* get_ofilename() const { return this->m_ofilename; }; // // @brief Return the number of plots. // int get_nplots() const { return this->get_nsamples() / this->m_options[this->m_option_index_x].args.size(); }; int get_noptions_x() const { return this->m_options[this->m_option_index_x].args.size(); }; int get_noptions() const { return this->m_options.size(); }; int get_option_nargs(int i) { return this->m_options[i].args.size(); } const char* get_option_arg(int i, int j) { return this->m_options[i].args[j].name; } const char* get_option_name(int i) { return this->m_options[i].name; } int get_nsamples() const { return this->m_nsamples; } int get_option_index_x() const { return this->m_option_index_x; } int get_nruns() const { return this->m_bench_nruns; } bool is_stdout_disabled() const { return this->m_is_stdout_disabled; } // // Constructor. // cmdline(int argc, char** argv) { // // Any option --bench-? // // // Try to get the option --bench-n. // int detected_option_bench_n = detect_option(argc, argv, "--bench-n", this->m_bench_nruns); if(detected_option_bench_n == -1) { std::cerr << "missing parameter ?" << std::endl; exit(1); } // // Try to get the option --bench-o. // int detected_option_bench_o = detect_option_string(argc, argv, "--bench-o", this->m_ofilename); if(detected_option_bench_o == -1) { std::cerr << "missing parameter ?" << std::endl; exit(1); } // // Try to get the option --bench-x. // const char* option_x = nullptr; int detected_option_bench_x = detect_option_string(argc, argv, "--bench-x", option_x); if(detected_option_bench_x == -1 || false == is_option(option_x)) { std::cerr << "wrong position of option --bench-x ?" << std::endl; exit(1); } this->m_name = argv[0]; this->m_has_bench_option = (detected_option_bench_x || detected_option_bench_o || detected_option_bench_n); this->m_is_stdout_disabled = (false == detect_flag(argc, argv, "--bench-std")); int jarg = -1; for(int iarg = 1; iarg < argc; ++iarg) { if(argv[iarg] == option_x) { jarg = iarg; break; } } int iarg = 1; while(iarg < argc) { // // Any argument starting with the character '-' is considered as an option. // if(is_option(argv[iarg])) { if(!strcmp(argv[iarg], "--bench-std")) { ++iarg; } else if(!strcmp(argv[iarg], "--bench-o")) { iarg += 2; } else if(!strcmp(argv[iarg], "--bench-x")) { ++iarg; } else if(!strcmp(argv[iarg], "--bench-n")) { iarg += 2; } else { // // Create the option. // cmdline_option option(argv[iarg]); // // Calculate the number of arguments based on the position of the next option, if any. // const int option_nargs = count_option_nargs(iarg, argc, argv); const int next_option_index = iarg + 1 + option_nargs; for(int k = iarg + 1; k < next_option_index; ++k) { option.args.push_back(cmdline_arg(argv[k])); } // // If this option has been flagged being the 'X' field. // otherwise, other ('Y') options will be classified from the order of their appearances as Y1, Y2, Y3. // if(jarg == iarg) // { this->m_option_index_x = this->m_options.size(); } // // Insert the option created. // this->m_options.push_back(option); iarg = next_option_index; } } else { // // Regular argument. // this->m_args.push_back(cmdline_arg(argv[iarg])); ++iarg; } } this->m_nsamples = 1; for(size_t ioption = 0; ioption < this->m_options.size(); ++ioption) { size_t n = this->m_options[ioption].args.size(); this->m_nsamples *= std::max(n, static_cast(1)); } } void expand(val* p) { const int num_options = this->m_options.size(); const auto num_samples = this->m_nsamples; for(int i = 0; i < num_samples; ++i) { p[i](1 + this->m_args.size() + num_options * 2); p[i].argc = 0; } // // Program name. // for(int i = 0; i < num_samples; ++i) { p[i].argv[p[i].argc++] = this->m_name; } // // Arguments without options // for(auto& arg : this->m_args) { for(int i = 0; i < num_samples; ++i) p[i].argv[p[i].argc++] = arg.name; } const int option_x_nargs = this->m_options[this->m_option_index_x].args.size(); int N = option_x_nargs; for(int iopt = 0; iopt < num_options; ++iopt) { cmdline_option& option = this->m_options[iopt]; // // // for(int isample = 0; isample < num_samples; ++isample) { p[isample].argv[p[isample].argc++] = option.name; } if(iopt == this->m_option_index_x) { // // // { const int ngroups = num_samples / option_x_nargs; for(int jgroup = 0; jgroup < ngroups; ++jgroup) { for(int ix = 0; ix < option_x_nargs; ++ix) { const int flat_index = jgroup * option_x_nargs + ix; p[flat_index].argv[p[flat_index].argc++] = option.args[ix].name; } } } // // // for(int isample = 0; isample < num_samples; ++isample) { if(p[isample].argc != p[0].argc) { std::cerr << "invalid struct line " << __LINE__ << std::endl; } } } else { const int option_narg = option.args.size(); if(option_narg > 1) { const int ngroups = num_samples / (N * option_narg); for(int jgroup = 0; jgroup < ngroups; ++jgroup) { for(int option_iarg = 0; option_iarg < option_narg; ++option_iarg) { for(int i = 0; i < N; ++i) { const int flat_index = N * (jgroup * option_narg + option_iarg) + i; p[flat_index].argv[p[flat_index].argc++] = option.args[option_iarg].name; } } } N *= std::max(option_narg, 1); } else { if(option_narg == 1) { for(int isample = 0; isample < num_samples; ++isample) { p[isample].argv[p[isample].argc++] = option.args[0].name; } } } } } } private: static inline int count_option_nargs(int iarg, int argc, char** argv) { int c = 0; for(int j = iarg + 1; j < argc; ++j) { if(is_option(argv[j])) { return c; } ++c; } return c; } static bool detect_flag(int argc, char** argv, const char* option_name) { for(int iarg = 1; iarg < argc; ++iarg) { if(!strcmp(argv[iarg], option_name)) { return true; } } return false; } template static int detect_option(int argc, char** argv, const char* option_name, T& value) { for(int iarg = 1; iarg < argc; ++iarg) { if(!strcmp(argv[iarg], option_name)) { ++iarg; if(iarg < argc) { std::istringstream iss(argv[iarg]); iss >> value; return 1; } else { std::cerr << "missing value for option --bench-n " << std::endl; return -1; } } } return 0; } static int detect_option_string(int argc, char** argv, const char* option_name, const char*& value) { for(int iarg = 1; iarg < argc; ++iarg) { if(!strcmp(argv[iarg], option_name)) { ++iarg; if(iarg < argc) { value = argv[iarg]; return 1; } else { std::cerr << "missing value for option " << option_name << std::endl; return -1; } } } return 0; } // // argument name. // struct cmdline_arg { char* name{}; cmdline_arg(char* name_) : name(name_){}; }; // // argument option. // struct cmdline_option { char* name{}; std::vector args{}; cmdline_option(char* name_) : name(name_){}; }; static inline bool is_option(const char* arg) { return arg[0] == '-'; } // // Name. // char* m_name; // // set of options. // std::vector m_options; // // set of arguments. // std::vector m_args; bool m_has_bench_option{}; int m_bench_nruns{1}; int m_option_index_x; int m_nsamples; bool m_is_stdout_disabled{true}; const char* m_ofilename{}; }; private: cmdline m_cmd; val* m_cmdset{}; public: // // @brief Get the output filename. // const char* get_ofilename() const; // // @brief Get the number of samples.. // int get_nsamples() const; int get_option_index_x() const; int get_option_nargs(int i); const char* get_option_arg(int i, int j); const char* get_option_name(int i); int get_noptions_x() const; int get_noptions() const; bool is_stdout_disabled() const; // // @brief Get the number of runs per sample. // int get_nruns() const; void get(int isample, int& argc, char** argv) const; void get_argc(int isample, int& argc_) const; // // @brief Constructor. // rocalution_bench_cmdlines(int argc, char** argv); static bool applies(int argc, char** argv); // // @brief Some info. // void info() const; }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_itsolver.hpp000066400000000000000000000200251445302240700260350ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_bench_solver_results.hpp" #include // // @brief Simple struct to hold the definition of a linear system. // template struct rocalution_linear_system { LocalMatrix A{}; LocalVector B{}; LocalVector X{}; LocalVector S{}; }; // // @brief Base struct for rocalution_bench. // @details This structure is a base structure that contains the linear system to solve. template struct rocalution_bench_itsolver { public: using results_t = rocalution_bench_solver_results; private: rocalution_linear_system m_linsys; protected: static constexpr bool s_verbose = false; // // @brief Import the linear system Ax=b // @param[out] // A matrix to import. // @param[out] // B right-hand-side to import. // @param[out] // S solution to import. // @return true if successful, false otherwise. // virtual bool ImportLinearSystem(LocalMatrix& A, LocalVector& B, LocalVector& S) = 0; // // @brief Presolve the linear system. // @note This should only be call once. // virtual bool AnalyzeLinearSystem(LocalMatrix& A, LocalVector& B, LocalVector& X) = 0; // // @brief Solve the linear system. // virtual bool SolveLinearSystem(LocalMatrix& A, LocalVector& B, LocalVector& X, results_t& results) = 0; // // @brief Log bench results. // virtual bool LogBenchResults(LocalMatrix& A, LocalVector& B, LocalVector& X, LocalVector& S, results_t& results) = 0; // // Compute error approximation. // bool ComputeErrorApproximation(const LocalVector& X, const LocalVector& S, LocalVector& E, results_t& results) { const auto N = X.GetSize(); E.CopyFrom(X, 0, 0, N); E.ScaleAdd(-1.0, S); const T nrm2 = E.Norm(); results.Set(results_t::norm_residual, nrm2); // // Compute some statistics about the error distribution. // { E.MoveToHost(); T* v = new T[N]; for(auto i = 0; i < N; ++i) { v[i] = T(std::abs(E[i])); } std::sort(v, v + N); results.Set(results_t::nrmmax_err, v[N - 1]); results.Set(results_t::nrmmax95_err, v[((N - 1) * 95) / 100]); results.Set(results_t::nrmmax75_err, v[((N - 1) * 75) / 100]); results.Set(results_t::nrmmax50_err, v[((N - 1) * 50) / 100]); delete[] v; E.MoveToAccelerator(); } return true; }; public: virtual ~rocalution_bench_itsolver(){}; bool Run(results_t& results) { #define TIC(var_) double var_ = rocalution_time() #define TAC(var_) var_ = ((rocalution_time() - var_) / 1e3) TIC(t_run); // // Import the linear system. // if(s_verbose) { std::cout << "Import linear system ..." << std::endl; } TIC(t_import_linear_system); { bool success = this->ImportLinearSystem(this->m_linsys.A, this->m_linsys.B, this->m_linsys.S); if(!success) { rocalution_bench_errmsg << "ImportLinearSystem failed." << std::endl; return false; } } TAC(t_import_linear_system); if(s_verbose) { std::cout << "Import linear system done." << std::endl; } // // Create unknown vector. // this->m_linsys.X.MoveToAccelerator(); this->m_linsys.X.Allocate("x", this->m_linsys.A.GetN()); this->m_linsys.X.Zeros(); // // Analyze the linear system. // if(s_verbose) { std::cout << "Analyze linear system ..." << std::endl; } TIC(t_analyze_linear_system); { bool success = this->AnalyzeLinearSystem(this->m_linsys.A, this->m_linsys.B, this->m_linsys.X); if(!success) { rocalution_bench_errmsg << "AnalyzeLinearSystem failed." << std::endl; return false; } } TAC(t_analyze_linear_system); if(s_verbose) { std::cout << "Analyze linear system done." << std::endl; } // // Solve the linear system. // if(s_verbose) { std::cout << "Solve linear system ..." << std::endl; } TIC(t_solve_linear_system); { bool success = this->SolveLinearSystem( this->m_linsys.A, this->m_linsys.B, this->m_linsys.X, results); if(!success) { rocalution_bench_errmsg << "SolveLinearSystem failed." << std::endl; return false; } } TAC(t_solve_linear_system); if(s_verbose) { std::cout << "Solve linear system done." << std::endl; } // // Compute Error Approximation. // if(s_verbose) { std::cout << "Compute error approximation ..." << std::endl; } { LocalVector E; E.MoveToAccelerator(); E.Allocate("e", this->m_linsys.X.GetSize()); bool success = this->ComputeErrorApproximation(this->m_linsys.X, this->m_linsys.S, E, results); if(!success) { rocalution_bench_errmsg << "ComputeErrorApproximation failed." << std::endl; return false; } } if(s_verbose) { std::cout << "Compute error approximation done." << std::endl; } TAC(t_run); // // LOG RESULTS. // results.Set(results_t::time_import, t_import_linear_system); results.Set(results_t::time_analyze, t_analyze_linear_system); results.Set(results_t::time_solve, t_solve_linear_system); results.Set(results_t::time_global, t_run); { bool success = this->LogBenchResults( this->m_linsys.A, this->m_linsys.B, this->m_linsys.X, this->m_linsys.S, results); if(!success) { rocalution_bench_errmsg << "LogBenchResults failed." << std::endl; return false; } } return true; } }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_itsolver_impl.hpp000066400000000000000000000166421445302240700270700ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include using namespace rocalution; #include "rocalution_bench_itsolver.hpp" #include "rocalution_driver_itsolver_fgmres.hpp" #include "rocalution_driver_itsolver_gmres.hpp" #include "rocalution_driver_itsolver_uaamg.hpp" static constexpr bool s_verbose = true; bool rocalution_bench_record_results(const rocalution_bench_solver_parameters&, const rocalution_bench_solver_results&); // // @brief This structure is an implementation of \ref rocalution_bench_itsolver. // template struct rocalution_bench_itsolver_impl : public rocalution_bench_itsolver { using driver_traits_t = rocalution_driver_itsolver_traits; using solver_t = typename driver_traits_t::solver_t; using results_t = rocalution_bench_solver_results; using params_t = rocalution_bench_solver_parameters; private: // // @brief Input parameters. // const rocalution_bench_solver_parameters* m_params{}; // // @brief Output results. // results_t* m_results{}; // // @brief Solver. // solver_t m_solver{}; // // @brief Iterative Driver. // rocalution_driver_itsolver m_driver{}; public: rocalution_bench_itsolver_impl(const params_t* parameters, results_t* results) : m_params(parameters) , m_results(results){}; virtual ~rocalution_bench_itsolver_impl() { this->m_solver.Clear(); }; // // @copydoc rocalution_bench_itsolver::ImportLinearSystem // virtual bool ImportLinearSystem(LocalMatrix& A, LocalVector& B, LocalVector& S) override { // // Import linear system. // bool success = this->m_driver.ImportLinearSystem(A, B, S, *this->m_params); if(!success) { rocalution_bench_errmsg << "import linear system failed." << std::endl; return false; } // // Move to accelerator. // A.MoveToAccelerator(); S.MoveToAccelerator(); B.MoveToAccelerator(); // // Finalize the import. // success = this->m_driver.PostprocessImportLinearSystem(A, B, S, *this->m_params); if(!success) { rocalution_bench_errmsg << "post process Import linear system failed." << std::endl; return false; } return true; } // // @copydoc rocalution_bench_itsolver::LogBenchResults // virtual bool LogBenchResults(LocalMatrix& A, LocalVector& B, LocalVector& X, LocalVector& S, results_t& results) override { return rocalution_bench_record_results(*this->m_params, results); } // // @copydoc rocalution_bench_itsolver::AnalyzeLinearSystem // virtual bool AnalyzeLinearSystem(LocalMatrix& A, LocalVector& B, LocalVector& X) override { // // Configure linear solver. // { if(s_verbose) { std::cout << "AnalyzeLinearSystem ConfigureLinearSolver ..." << std::endl; std::cout << "A.M = " << A.GetM() << std::endl; std::cout << "A.N = " << A.GetN() << std::endl; std::cout << "A.NNZ = " << A.GetNnz() << std::endl; } { bool success = this->m_driver.ConfigureLinearSolver( A, B, X, this->m_solver, *this->m_params); if(!success) { rocalution_bench_errmsg << "configure linear solver failed." << std::endl; return false; } } if(s_verbose) { std::cout << "AnalyzeLinearSystem ConfigureLinearSolver done." << std::endl; } } // // Convert the matrix to the required format. // { if(s_verbose) { std::cout << "AnalyzeLinearSystem ConvertTo..." << std::endl; } { auto format = this->m_params->Get(params_t::format); if(s_verbose) { std::cout << "AnalyzeLinearSystem ConvertTo ... format = " << format << " ... " << std::endl; } const auto blockdim = this->m_params->Get(params_t::blockdim); A.ConvertTo(format, format == BCSR ? blockdim : 1); } if(s_verbose) { std::cout << "AnalyzeLinearSystem ConvertTo done." << std::endl; } } return true; } // // @copydoc rocalution_bench_itsolver::SolveLinearSystem // virtual bool SolveLinearSystem(LocalMatrix& A, LocalVector& B, LocalVector& X, results_t& results) override { // // Pre-solve. // if(!this->m_driver.PreprocessLinearSolve(A, B, X, this->m_solver, *this->m_params)) { rocalution_bench_errmsg << "preprocess linear solve failed." << std::endl; return false; } // // Solve // this->m_solver.Solve(B, &X); // // Post solve. // if(!this->m_driver.PostprocessLinearSolve(A, B, X, this->m_solver, *this->m_params)) { rocalution_bench_errmsg << "postprocess linear solve failed." << std::endl; return false; } // // Record results. // results.Set(results_t::iter, this->m_solver.GetIterationCount()); results.Set(results_t::norm_residual, this->m_solver.GetCurrentResidual()); { auto status = this->m_solver.GetSolverStatus(); results.Set(results_t::convergence, (status == 1) ? true : false); } return true; } }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_solver.hpp000066400000000000000000000072241445302240700255060ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_bench_itsolver_impl.hpp" // // @brief Core structure responsible of configuring the benchmark from parsing command line arguments // and execute it. // template struct rocalution_bench_solver { private: rocalution_bench_itsolver* m_itsolver{}; rocalution_bench_solver_results m_output_results{}; const rocalution_bench_solver_parameters* m_input_parameters{}; public: ~rocalution_bench_solver() { if(this->m_itsolver) { delete this->m_itsolver; this->m_itsolver = nullptr; } } rocalution_bench_solver(const rocalution_bench_solver_parameters* config) : m_input_parameters(config) { // // Try to config iterative solver. // const rocalution_enum_itsolver enum_itsolver = this->m_input_parameters->GetEnumIterativeSolver(); if(enum_itsolver.is_invalid()) { rocalution_bench_errmsg << "invalid iterative solver." << std::endl; throw false; } this->m_itsolver = nullptr; switch(enum_itsolver.value) { // // Define cases. // #define ROCALUTION_ENUM_ITSOLVER_TRANSFORM(x_) \ case rocalution_enum_itsolver::x_: \ { \ this->m_itsolver = new rocalution_bench_itsolver_impl( \ this->m_input_parameters, &this->m_output_results); \ break; \ } // // Generate cases. // ROCALUTION_ENUM_ITSOLVER_TRANSFORM_EACH; // // Undefine cases. // #undef ROCALUTION_ENUM_ITSOLVER_TRANSFORM } if(this->m_itsolver == nullptr) { rocalution_bench_errmsg << "iterative solver instantiation failed." << std::endl; throw false; } } bool Run() { if(this->m_itsolver != nullptr) { return this->m_itsolver->Run(this->m_output_results); } return false; } }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_solver_parameters.cpp000066400000000000000000000150251445302240700277220ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_bench_solver_parameters.hpp" rocalution_enum_smoother rocalution_bench_solver_parameters::GetEnumSmoother() const { return this->m_enum_smoother; }; rocalution_enum_coarsening_strategy rocalution_bench_solver_parameters::GetEnumCoarseningStrategy() const { return this->m_enum_coarsening_strategy; }; rocalution_enum_preconditioner rocalution_bench_solver_parameters::GetEnumPreconditioner() const { return this->m_enum_preconditioner; }; rocalution_enum_itsolver rocalution_bench_solver_parameters::GetEnumIterativeSolver() const { return this->m_enum_itsolver; }; rocalution_enum_directsolver rocalution_bench_solver_parameters::GetEnumDirectSolver() const { return this->m_enum_directsolver; }; rocalution_enum_matrix_init rocalution_bench_solver_parameters::GetEnumMatrixInit() const { return this->m_enum_matrix_init; }; constexpr rocalution_bench_solver_parameters::e_bool rocalution_bench_solver_parameters::e_bool_all[]; constexpr rocalution_bench_solver_parameters::e_int rocalution_bench_solver_parameters::e_int_all[]; constexpr rocalution_bench_solver_parameters::e_string rocalution_bench_solver_parameters::e_string_all[]; constexpr rocalution_bench_solver_parameters::e_uint rocalution_bench_solver_parameters::e_uint_all[]; constexpr rocalution_bench_solver_parameters::e_double rocalution_bench_solver_parameters::e_double_all[]; constexpr const char* rocalution_bench_solver_parameters::e_bool_names[]; constexpr const char* rocalution_bench_solver_parameters::e_int_names[]; constexpr const char* rocalution_bench_solver_parameters::e_string_names[]; constexpr const char* rocalution_bench_solver_parameters::e_uint_names[]; constexpr const char* rocalution_bench_solver_parameters::e_double_names[]; bool rocalution_bench_solver_parameters::Get(e_bool v) const { return this->bool_values[v]; } void rocalution_bench_solver_parameters::Set(e_bool v, bool s) { this->bool_values[v] = s; } std::string rocalution_bench_solver_parameters::Get(e_string v) const { return this->string_values[v]; } void rocalution_bench_solver_parameters::Set(e_string v, const std::string& s) { this->string_values[v] = s; } unsigned int rocalution_bench_solver_parameters::Get(e_uint v) const { return this->uint_values[v]; } void rocalution_bench_solver_parameters::Set(e_uint v, unsigned int s) { this->uint_values[v] = s; } int rocalution_bench_solver_parameters::Get(e_int v) const { return this->int_values[v]; } void rocalution_bench_solver_parameters::Set(e_int v, int s) { this->int_values[v] = s; } double rocalution_bench_solver_parameters::Get(e_double v) const { return this->double_values[v]; } void rocalution_bench_solver_parameters::Set(e_double v, double s) { this->double_values[v] = s; } bool* rocalution_bench_solver_parameters::GetPointer(e_bool v) { return &this->bool_values[v]; } std::string* rocalution_bench_solver_parameters::GetPointer(e_string v) { return &this->string_values[v]; } unsigned int* rocalution_bench_solver_parameters::GetPointer(e_uint v) { return &this->uint_values[v]; } int* rocalution_bench_solver_parameters::GetPointer(e_int v) { return &this->int_values[v]; } double* rocalution_bench_solver_parameters::GetPointer(e_double v) { return &this->double_values[v]; } void rocalution_bench_solver_parameters::WriteNicely(std::ostream& out) const { out.precision(2); out.setf(std::ios::fixed); out.setf(std::ios::left); out << std::scientific; for(auto e : e_bool_all) { out << std::setw(20) << e_bool_names[e] << " " << std::setw(20) << bool_values[e]; out << std::endl; } for(auto e : e_int_all) { out << std::setw(20) << e_int_names[e] << " " << std::setw(20) << int_values[e]; out << std::endl; } for(auto e : e_double_all) { out << std::setw(20) << e_double_names[e] << " " << std::setw(20) << double_values[e]; out << std::endl; } for(auto e : e_uint_all) { out << std::setw(20) << e_uint_names[e] << " " << std::setw(20) << uint_values[e]; out << std::endl; } for(auto e : e_string_all) { out << std::setw(20) << e_string_names[e] << " " << std::setw(20) << string_values[e]; out << std::endl; } } void rocalution_bench_solver_parameters::WriteJson(std::ostream& out) const { bool first = false; for(auto e : e_bool_all) { if(!first) first = true; else out << "," << std::endl; out << "\"" << e_bool_names[e] << "\" : " << "\"" << bool_values[e] << "\""; } for(auto e : e_int_all) { out << "," << std::endl; out << "\"" << e_int_names[e] << "\" : " << "\"" << int_values[e] << "\""; } for(auto e : e_double_all) { out << "," << std::endl; out << "\"" << e_double_names[e] << "\" : " << "\"" << double_values[e] << "\""; } for(auto e : e_uint_all) { out << "," << std::endl; out << "\"" << e_uint_names[e] << "\" : " << "\"" << uint_values[e] << "\""; } for(auto e : e_string_all) { out << "," << std::endl; out << "\"" << e_string_names[e] << "\" : " << "\"" << string_values[e] << "\""; } } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_solver_parameters.hpp000066400000000000000000000261171445302240700277330ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_enum_coarsening_strategy.hpp" #include "rocalution_enum_directsolver.hpp" #include "rocalution_enum_itsolver.hpp" #include "rocalution_enum_matrix_init.hpp" #include "rocalution_enum_preconditioner.hpp" #include "rocalution_enum_smoother.hpp" #include // // @brief Structure responsible of the parameter definitions and values. // struct rocalution_bench_solver_parameters { protected: // // @brief Which matrix initialization. // rocalution_enum_matrix_init m_enum_matrix_init{}; // // @brief Which iterative solver. // rocalution_enum_itsolver m_enum_itsolver{}; // // @brief Which preconditioner. // rocalution_enum_preconditioner m_enum_preconditioner{}; // // @brief Which smoother. // rocalution_enum_smoother m_enum_smoother{}; // // @brief Which direct solver. // rocalution_enum_directsolver m_enum_directsolver{}; // // @brief Which coarsening_strategy. // rocalution_enum_coarsening_strategy m_enum_coarsening_strategy{}; public: // // @brief Get which direct solver. // rocalution_enum_directsolver GetEnumDirectSolver() const; // // @brief Get which smoother. // rocalution_enum_smoother GetEnumSmoother() const; // // @brief Get which coarsening_strategy. // rocalution_enum_coarsening_strategy GetEnumCoarseningStrategy() const; // // @brief Get which preconditioner // rocalution_enum_preconditioner GetEnumPreconditioner() const; // // @brief Get which iterative solver. // rocalution_enum_itsolver GetEnumIterativeSolver() const; // // @brief Get which matrix initialization // rocalution_enum_matrix_init GetEnumMatrixInit() const; // // @brief Define Boolean parameters // // clang-format off #define PBOOL_TRANSFORM_EACH \ PBOOL_TRANSFORM(verbose) \ PBOOL_TRANSFORM(mcilu_use_level) // clang-format on #define PBOOL_TRANSFORM(x_) x_, typedef enum e_bool_ : int { PBOOL_TRANSFORM_EACH } e_bool; static constexpr e_bool e_bool_all[] = {PBOOL_TRANSFORM_EACH}; #undef PBOOL_TRANSFORM // // @brief Define Integer parameters // // clang-format off #define PINT_TRANSFORM_EACH \ PINT_TRANSFORM(krylov_basis) \ PINT_TRANSFORM(ndim) \ PINT_TRANSFORM(ilut_n) \ PINT_TRANSFORM(mcilu_p) \ PINT_TRANSFORM(mcilu_q) \ PINT_TRANSFORM(max_iter) \ PINT_TRANSFORM(solver_pre_smooth) \ PINT_TRANSFORM(solver_post_smooth) \ PINT_TRANSFORM(solver_ordering) \ PINT_TRANSFORM(rebuild_numeric) \ PINT_TRANSFORM(cycle) \ PINT_TRANSFORM(solver_coarsest_level) \ PINT_TRANSFORM(blockdim) // clang-format on #define PINT_TRANSFORM(x_) x_, typedef enum e_int_ : int { PINT_TRANSFORM_EACH } e_int; static constexpr e_int e_int_all[] = {PINT_TRANSFORM_EACH}; #undef PINT_TRANSFORM // // @brief Define String parameters // // clang-format off #define PSTRING_TRANSFORM_EACH \ PSTRING_TRANSFORM(coarsening_strategy) \ PSTRING_TRANSFORM(direct_solver) \ PSTRING_TRANSFORM(iterative_solver) \ PSTRING_TRANSFORM(matrix) \ PSTRING_TRANSFORM(matrix_filename) \ PSTRING_TRANSFORM(preconditioner) \ PSTRING_TRANSFORM(smoother) // clang-format on #define PSTRING_TRANSFORM(x_) x_, typedef enum e_string_ : int { PSTRING_TRANSFORM_EACH } e_string; static constexpr e_string e_string_all[] = {PSTRING_TRANSFORM_EACH}; #undef PSTRING_TRANSFORM // // @brief Define Unsigned integer parameters // // clang-format off #define PUINT_TRANSFORM_EACH \ PUINT_TRANSFORM(format) // clang-format on #define PUINT_TRANSFORM(x_) x_, typedef enum e_uint_ : int { PUINT_TRANSFORM_EACH } e_uint; static constexpr e_uint e_uint_all[] = {PUINT_TRANSFORM_EACH}; #undef PUINT_TRANSFORM // // @brief Define Double parameters // // clang-format off #define PDOUBLE_TRANSFORM_EACH \ PDOUBLE_TRANSFORM(abs_tol) \ PDOUBLE_TRANSFORM(rel_tol) \ PDOUBLE_TRANSFORM(div_tol) \ PDOUBLE_TRANSFORM(residual_tol) \ PDOUBLE_TRANSFORM(ilut_tol) \ PDOUBLE_TRANSFORM(mcgs_relax) \ PDOUBLE_TRANSFORM(solver_over_interp) \ PDOUBLE_TRANSFORM(solver_coupling_strength) \ // clang-format on #define PDOUBLE_TRANSFORM(x_) x_, typedef enum e_double_ : int { PDOUBLE_TRANSFORM_EACH } e_double; static constexpr e_double e_double_all[] = {PDOUBLE_TRANSFORM_EACH}; #undef PDOUBLE_TRANSFORM private: // // @brief Number of string parameters // static constexpr std::size_t e_string_size = countof(e_string_all); // // @brief Number of unsigned integer parameters // static constexpr std::size_t e_uint_size = countof(e_uint_all); // // @brief Number of Boolean parameters // static constexpr std::size_t e_bool_size = countof(e_bool_all); // // @brief Number of integer parameters // static constexpr std::size_t e_int_size = countof(e_int_all); // // @brief Number of double parameters // static constexpr std::size_t e_double_size = countof(e_double_all); // // @brief Array of Boolean parameter names. // #define PBOOL_TRANSFORM(x_) #x_, static constexpr const char* e_bool_names[e_bool_size]{PBOOL_TRANSFORM_EACH}; #undef PBOOL_TRANSFORM // // @brief Array of unsigned integer parameter names. // #define PUINT_TRANSFORM(x_) #x_, static constexpr const char* e_uint_names[e_uint_size]{PUINT_TRANSFORM_EACH}; #undef PUINT_TRANSFORM // // @brief Array of string parameter names. // #define PSTRING_TRANSFORM(x_) #x_, static constexpr const char* e_string_names[e_string_size]{PSTRING_TRANSFORM_EACH}; #undef PSTRING_TRANSFORM // // @brief Array of integer parameter names. // #define PINT_TRANSFORM(x_) #x_, static constexpr const char* e_int_names[e_int_size]{PINT_TRANSFORM_EACH}; #undef PINT_TRANSFORM // // @brief Array of Double parameter names. // #define PDOUBLE_TRANSFORM(x_) #x_, static constexpr const char* e_double_names[e_double_size]{PDOUBLE_TRANSFORM_EACH}; #undef PDOUBLE_TRANSFORM // // @brief Array of Boolean parameter values. // bool bool_values[e_bool_size]{}; // // @brief Array of Unsigned integer parameter values. // unsigned int uint_values[e_uint_size]{}; // // @brief Array of Integer parameter values. // int int_values[e_int_size]{}; // // @brief Array of string parameter values. // std::string string_values[e_string_size]{}; // // @brief Array of Double parameter values. // double double_values[e_double_size]{}; public: static const char* GetName(e_bool v) { return e_bool_names[v]; } static const char* GetName(e_int v) { return e_int_names[v]; } static const char* GetName(e_uint v) { return e_uint_names[v]; } static const char* GetName(e_double v) { return e_double_names[v]; } static const char* GetName(e_string v) { return e_string_names[v]; } // // @brief Get pointer to string parameter value. // std::string* GetPointer(e_string v); // // @brief Get string parameter value. // std::string Get(e_string v) const; // // @brief Set string parameter value. // void Set(e_string v, const std::string& s); // // @brief Get unsigned int parameter value. // unsigned int Get(e_uint v) const; // // @brief Get pointer to unsigned int parameter value. // unsigned int* GetPointer(e_uint v); // // @brief Set unsigned int parameter value. // void Set(e_uint v, unsigned int s); // // @brief Get Boolean parameter value. // bool Get(e_bool v) const; // // @brief Get pointer to Boolean parameter value. // bool* GetPointer(e_bool v); // // @brief Set Boolean parameter value. // void Set(e_bool v, bool s); // // @brief Get integer parameter value. // int Get(e_int v) const; // // @brief Get pointer to integer parameter value. // int* GetPointer(e_int v); // // @brief Set integer parameter value. // void Set(e_int v, int s); // // @brief Get double parameter value. // double Get(e_double v) const; // // @brief Get pointer to double parameter value. // double* GetPointer(e_double v); // // @brief Set double parameter value. // void Set(e_double v, double s); // // @brief Write information // void Info(std::ostream& out) const { out.setf(std::ios::left); out << "bool: " << std::endl; for(auto e : e_bool_all) { out << std::setw(20) << e_bool_names[e] << std::setw(20) << bool_values[e] << std::endl; } out << "int: " << std::endl; for(auto e : e_int_all) { out << std::setw(20) << e_int_names[e] << std::setw(20) << int_values[e] << std::endl; } out << "uint: " << std::endl; for(auto e : e_uint_all) { out << std::setw(20) << e_uint_names[e] << std::setw(20) << uint_values[e] << std::endl; } out << "double: " << std::endl; for(auto e : e_double_all) { out << std::setw(20) << e_double_names[e] << std::setw(20) << double_values[e] << std::endl; } out << "string: " << std::endl; for(auto e : e_string_all) { out << std::setw(20) << e_string_names[e] << "'" << string_values[e] << "'" << std::endl; } } void WriteJson(std::ostream& out) const; void WriteNicely(std::ostream& out) const; }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_solver_results.cpp000066400000000000000000000075541445302240700272700ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_bench_solver_results.hpp" constexpr rocalution_bench_solver_results::e_bool rocalution_bench_solver_results::e_bool_all[]; constexpr rocalution_bench_solver_results::e_int rocalution_bench_solver_results::e_int_all[]; constexpr rocalution_bench_solver_results::e_double rocalution_bench_solver_results::e_double_all[]; constexpr const char* rocalution_bench_solver_results::e_bool_names[]; constexpr const char* rocalution_bench_solver_results::e_int_names[]; constexpr const char* rocalution_bench_solver_results::e_double_names[]; bool rocalution_bench_solver_results::Get(e_bool v) const { return bool_values[v]; } void rocalution_bench_solver_results::Set(e_bool v, bool s) { bool_values[v] = s; } int rocalution_bench_solver_results::Get(e_int v) const { return int_values[v]; } void rocalution_bench_solver_results::Set(e_int v, int s) { int_values[v] = s; } double rocalution_bench_solver_results::Get(e_double v) const { return double_values[v]; } void rocalution_bench_solver_results::Set(e_double v, double s) { double_values[v] = s; } void rocalution_bench_solver_results::WriteJson(std::ostream& out) const { bool first = false; for(auto e : e_bool_all) { if(!first) first = true; else out << ","; out << "\"" << e_bool_names[e] << "\" : " << "\"" << bool_values[e] << "\""; } for(auto e : e_int_all) { if(!first) first = true; else out << ","; out << "\"" << e_int_names[e] << "\" : " << "\"" << int_values[e] << "\""; } for(auto e : e_double_all) { if(!first) first = true; else out << ","; out << "\"" << e_double_names[e] << "\" : " << "\"" << double_values[e] << "\""; } } void rocalution_bench_solver_results::WriteNicely(std::ostream& out) const { out.precision(2); out.setf(std::ios::fixed); out.setf(std::ios::left); out << std::scientific; for(auto e : e_bool_all) { out << std::setw(14) << e_bool_names[e]; } for(auto e : e_int_all) { out << std::setw(14) << e_int_names[e]; } for(auto e : e_double_all) { out << std::setw(14) << e_double_names[e]; } out << std::endl; for(auto e : e_bool_all) { out << std::setw(14) << bool_values[e]; } for(auto e : e_int_all) { out << std::setw(14) << int_values[e]; } for(auto e : e_double_all) { out << std::setw(14) << double_values[e]; } out << std::endl; } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_solver_results.hpp000066400000000000000000000113111445302240700272570ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_enum_itsolver.hpp" #include "rocalution_enum_preconditioner.hpp" #include "rocalution_enum_smoother.hpp" #include struct rocalution_bench_solver_results { // clang-format off #define RESBOOL_TRANSFORM_EACH \ RESBOOL_TRANSFORM(convergence) // clang-format on #define RESBOOL_TRANSFORM(x_) x_, typedef enum e_bool_ : int { RESBOOL_TRANSFORM_EACH } e_bool; static constexpr e_bool e_bool_all[] = {RESBOOL_TRANSFORM_EACH}; #undef RESBOOL_TRANSFORM // clang-format off #define RESINT_TRANSFORM_EACH \ RESINT_TRANSFORM(iter) // clang-format on #define RESINT_TRANSFORM(x_) x_, typedef enum e_int_ : int { RESINT_TRANSFORM_EACH } e_int; static constexpr e_int e_int_all[] = {RESINT_TRANSFORM_EACH}; #undef RESINT_TRANSFORM // clang-format off #define RESDOUBLE_TRANSFORM_EACH \ RESDOUBLE_TRANSFORM(time_import) \ RESDOUBLE_TRANSFORM(time_analyze) \ RESDOUBLE_TRANSFORM(time_solve) \ RESDOUBLE_TRANSFORM(time_global) \ RESDOUBLE_TRANSFORM(norm_residual) \ RESDOUBLE_TRANSFORM(nrmmax_err) \ RESDOUBLE_TRANSFORM(nrmmax95_err) \ RESDOUBLE_TRANSFORM(nrmmax75_err) \ RESDOUBLE_TRANSFORM(nrmmax50_err) // clang-format on #define RESDOUBLE_TRANSFORM(x_) x_, typedef enum e_double_ : int { RESDOUBLE_TRANSFORM_EACH } e_double; static constexpr e_double e_double_all[] = {RESDOUBLE_TRANSFORM_EACH}; #undef RESDOUBLE_TRANSFORM private: static constexpr std::size_t e_bool_size = countof(e_bool_all); static constexpr std::size_t e_int_size = countof(e_int_all); static constexpr std::size_t e_double_size = countof(e_double_all); #define RESBOOL_TRANSFORM(x_) #x_, static constexpr const char* e_bool_names[e_bool_size]{RESBOOL_TRANSFORM_EACH}; #undef RESBOOL_TRANSFORM #define RESINT_TRANSFORM(x_) #x_, static constexpr const char* e_int_names[e_int_size]{RESINT_TRANSFORM_EACH}; #undef RESINT_TRANSFORM #define RESDOUBLE_TRANSFORM(x_) #x_, static constexpr const char* e_double_names[e_double_size]{RESDOUBLE_TRANSFORM_EACH}; #undef RESDOUBLE_TRANSFORM bool bool_values[e_bool_size]{}; int int_values[e_int_size]{}; double double_values[e_double_size]{}; public: static const char* Name(e_bool v) { return e_bool_names[v]; }; static const char* Name(e_double v) { return e_double_names[v]; }; static const char* Name(e_int v) { return e_int_names[v]; }; bool Get(e_bool v) const; void Set(e_bool v, bool s); int Get(e_int v) const; void Set(e_int v, int s); double Get(e_double v) const; void Set(e_double v, double s); void Info(std::ostream& out) const { out << "bool: " << std::endl; for(auto e : e_bool_all) { out << std::setw(20) << e_bool_names[e] << std::setw(20) << bool_values[e] << std::endl; } out << "int: " << std::endl; for(auto e : e_int_all) { out << std::setw(20) << e_int_names[e] << std::setw(20) << int_values[e] << std::endl; } out << "double: " << std::endl; for(auto e : e_double_all) { out << std::setw(20) << e_double_names[e] << std::setw(20) << double_values[e] << std::endl; } } void WriteJson(std::ostream& out) const; void WriteNicely(std::ostream& out) const; }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_bench_template.hpp000066400000000000000000000037121445302240700260050ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_bench_solver.hpp" // // @brief One function to call the bench execution. // template bool rocalution_bench_template(const rocalution_arguments_config& config) { try { rocalution_bench_solver bench_solver(&config); bool success = bench_solver.Run(); return success; } catch(bool) { rocalution_bench_errmsg << "rocalution_bench_template failure" << std::endl; ; return false; } catch(std::exception&) { rocalution_bench_errmsg << "rocalution_bench_template unknown failure" << std::endl; ; return false; } } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_driver_itsolver.hpp000066400000000000000000000311441445302240700262550ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_driver_itsolver_template.hpp" // // @brief This structure is responsible of providing a base implementation // of \ref rocalution_driver_itsolver_template. // template struct rocalution_driver_itsolver_base : rocalution_driver_itsolver_template { protected: using traits_t = rocalution_driver_itsolver_traits; using solver_t = typename traits_t::solver_t; using preconditioner_t = typename traits_t::preconditioner_t; using params_t = rocalution_bench_solver_parameters; protected: T* cache_csr_val{}; preconditioner_t* m_preconditioner{}; // // Option for caching. // void Cache(int m, int n, int nnz, const int* csr_ptr, const int* csr_ind, const T* csr_val, const params_t& parameters) { this->cache_csr_val = new T[nnz]; for(int i = 0; i < nnz; i++) { this->cache_csr_val[i] = csr_val[i]; } } public: // // @brief Destructor. // ~rocalution_driver_itsolver_base() { if(this->cache_csr_val != nullptr) { delete[] this->cache_csr_val; this->cache_csr_val = nullptr; } if(this->m_preconditioner != nullptr) { delete m_preconditioner; m_preconditioner = nullptr; } } virtual const preconditioner_t* GetPreconditioner() const override { return this->m_preconditioner; }; virtual preconditioner_t* GetPreconditioner() override { return this->m_preconditioner; }; virtual void SetPreconditioner(preconditioner_t* preconditioner) override { this->m_preconditioner = preconditioner; }; // @brief Import matrix. // @param[in] // A local matrix. // @param[in] // parameters parameters to configure the operation. // @return true if successful, false otherwise. virtual bool ImportMatrix(LocalMatrix& A, const params_t& parameters) { auto matrix_init = parameters.GetEnumMatrixInit(); if(matrix_init.is_invalid()) { rocalution_bench_errmsg << "matrix initialization is invalid" << std::endl; return false; } const auto rebuild_numeric = parameters.Get(params_t::rebuild_numeric); switch(matrix_init.value) { case rocalution_enum_matrix_init::laplacian: { int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; const int ndim = parameters.Get(params_t::ndim); auto nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); if(rebuild_numeric) { this->Cache(nrow, nrow, csr_ptr[nrow], csr_ptr, csr_col, csr_val, parameters); } A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", csr_ptr[nrow], nrow, nrow); return true; } case rocalution_enum_matrix_init::permuted_identity: { int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; const int ndim = parameters.Get(params_t::ndim); auto nrow = gen_permuted_identity(ndim, &csr_ptr, &csr_col, &csr_val); if(rebuild_numeric) { this->Cache(nrow, nrow, csr_ptr[nrow], csr_ptr, csr_col, csr_val, parameters); } A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", csr_ptr[nrow], nrow, nrow); return true; } case rocalution_enum_matrix_init::file: { const std::string matrix_filename = parameters.Get(params_t::matrix_filename); if(matrix_filename == "") { rocalution_bench_errmsg << "no filename for matrix file initialization." << std::endl; return false; } else { A.ReadFileMTX(matrix_filename); // Apply reordering ? // LocalVector rcmk; // A.RCMK(&rcmk); // A.Permute(rcmk); if(rebuild_numeric) { // // Since we want to cache // // Convert to csr format. // A.ConvertTo(1); // // Grab csr data. // int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; auto nrow = A.GetM(); auto ncol = A.GetN(); auto nnz = A.GetNnz(); // // Leave pointers, A is not usable after this until we re-set the pointers. // A.LeaveDataPtrCSR(&csr_ptr, &csr_col, &csr_val); // // Cache. // this->Cache(nrow, ncol, nnz, csr_ptr, csr_col, csr_val, parameters); // // Re-set the pointers. // A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); } return true; } } } return true; } virtual bool ImportLinearSystem(LocalMatrix& A, LocalVector& B, LocalVector& X, const params_t& parameters) override { // // Import matrix. // this->ImportMatrix(A, parameters); return true; } }; // // @Brief Default implementation. // template struct rocalution_driver_itsolver_default : rocalution_driver_itsolver_base { using params_t = rocalution_bench_solver_parameters; virtual bool CreatePreconditioner(LocalMatrix& A, LocalVector& B, LocalVector& X, const params_t& parameters) override { auto enum_preconditioner = parameters.GetEnumPreconditioner(); if(enum_preconditioner.is_invalid()) { rocalution_bench_errmsg << "enum preconditioner is invalid." << std::endl; return false; } this->m_preconditioner = nullptr; switch(enum_preconditioner.value) { case rocalution_enum_preconditioner::none: { return true; } case rocalution_enum_preconditioner::chebyshev: { // Chebyshev preconditioner // Determine min and max eigenvalues T lambda_min; T lambda_max; A.Gershgorin(lambda_min, lambda_max); auto* p = new rocalution:: AIChebyshev, rocalution::LocalVector, T>; p->Set(3, lambda_max / 7.0, lambda_max); this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::FSAI: { auto* p = new rocalution::FSAI, rocalution::LocalVector, T>; this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::SPAI: { auto* p = new rocalution::SPAI, rocalution::LocalVector, T>; this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::TNS: { auto* p = new rocalution::TNS, rocalution::LocalVector, T>; this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::Jacobi: { auto* p = new rocalution::Jacobi, rocalution::LocalVector, T>; // // no specific parameters // this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::GS: { auto* p = new rocalution::GS, rocalution::LocalVector, T>; // // no specific parameters // this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::SGS: { auto* p = new rocalution::SGS, rocalution::LocalVector, T>; // // no specific parameters // this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::ILU: { auto* p = new rocalution::ILU, rocalution::LocalVector, T>; // // no specific parameters // this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::ILUT: { auto* p = new rocalution::ILUT, rocalution::LocalVector, T>; p->Set(parameters.Get(params_t::ilut_tol), parameters.Get(params_t::ilut_n)); this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::IC: { auto* p = new rocalution::IC, rocalution::LocalVector, T>; // // no specific parameters // this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::MCGS: { auto* p = new rocalution:: MultiColoredGS, rocalution::LocalVector, T>; p->SetRelaxation(parameters.Get(params_t::mcgs_relax)); this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::MCSGS: { auto* p = new rocalution:: MultiColoredSGS, rocalution::LocalVector, T>; // // no specific parameters // this->m_preconditioner = p; return true; } case rocalution_enum_preconditioner::MCILU: { auto* p = new rocalution:: MultiColoredILU, rocalution::LocalVector, T>; p->Set(parameters.Get(params_t::mcilu_p), parameters.Get(params_t::mcilu_q), parameters.Get(params_t::mcilu_use_level)); this->m_preconditioner = p; return true; } } return false; } }; // // @Brief Default definition. // template struct rocalution_driver_itsolver : rocalution_driver_itsolver_default { }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_driver_itsolver_fgmres.hpp000066400000000000000000000043731445302240700276240ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_driver_itsolver.hpp" template struct rocalution_driver_itsolver : rocalution_driver_itsolver_default { static constexpr auto ITSOLVER = rocalution_enum_itsolver::fgmres; using traits_t = rocalution_driver_itsolver_traits; using solver_t = typename traits_t::solver_t; using params_t = rocalution_bench_solver_parameters; virtual bool PreprocessSolverBuild(LocalMatrix& A, LocalVector& B, LocalVector& X, solver_t& solver, const params_t& parameters) override { const auto krylov_basis = parameters.Get(params_t::krylov_basis); solver.SetBasisSize(krylov_basis); return true; }; }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_driver_itsolver_gmres.hpp000066400000000000000000000043671445302240700274610ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_driver_itsolver.hpp" template struct rocalution_driver_itsolver : rocalution_driver_itsolver_default { static constexpr auto ITSOLVER = rocalution_enum_itsolver::gmres; using traits_t = rocalution_driver_itsolver_traits; using solver_t = typename traits_t::solver_t; using params_t = rocalution_bench_solver_parameters; virtual bool PreprocessSolverBuild(LocalMatrix& A, LocalVector& B, LocalVector& X, solver_t& solver, const params_t& parameters) override { const auto krylov_basis = parameters.Get(params_t::krylov_basis); solver.SetBasisSize(krylov_basis); return true; }; }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_driver_itsolver_template.hpp000066400000000000000000000270761445302240700301610ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_bench_solver_parameters.hpp" #include "rocalution_driver_itsolver_traits.hpp" // // @brief This structure is responsible of defining a driver to configure an iterative linear solver. // template struct rocalution_driver_itsolver_template { protected: static constexpr bool s_verbose = true; using traits_t = rocalution_driver_itsolver_traits; using solver_t = typename traits_t::solver_t; using preconditioner_t = typename traits_t::preconditioner_t; using params_t = rocalution_bench_solver_parameters; // // Pure protected virtual methods. // ______________________________ protected: // @brief Get the preconditioner. // @return constant pointer to the preconditioner. virtual const preconditioner_t* GetPreconditioner() const = 0; // @brief Get the preconditioner. // @return pointer to the preconditioner. virtual preconditioner_t* GetPreconditioner() = 0; // @brief Set the preconditioner. // @param[in] // preconditioner pointer to the preconditioner. virtual void SetPreconditioner(preconditioner_t* preconditioner) = 0; // @brief Create preconditioner. // @param[in] // A matrix of the linear system. // @param[in] // B right-hand-side vector of the linear system. // @param[in] // X unknown vector of the linear system. // @param[in] // parameters parameters to configure the operation. // @return true if successful, false otherwise. virtual bool CreatePreconditioner(LocalMatrix& A, LocalVector& B, LocalVector& X, const params_t& parameters) = 0; // // Protected virtual methods. // _________________________ protected: // // @brief Method called before the Build method from the solver being called. // @param[inout] // A matrix of the linear system. // @param[inout] // B right-hand-side vector of the linear system. // @param[inout] // X unknown vector of the linear system. // @param[inout] // solver linear solver. // @param[inout] // parameters parameters to configure the operation. // @return true if successful, false otherwise. // virtual bool PreprocessSolverBuild(LocalMatrix& A, LocalVector& B, LocalVector& X, solver_t& solver, const params_t& parameters) { // // by default do nothing. // return true; } // // @brief Method called after the Build method from the solver being called. // @param[inout] // A matrix of the linear system. // @param[inout] // B right-hand-side vector of the linear system. // @param[inout] // X unknown vector of the linear system. // @param[inout] // solver linear solver. // @param[inout] // parameters parameters to configure the operation. // @return true if successful, false otherwise. // virtual bool PostprocessSolverBuild(LocalMatrix& A, LocalVector& B, LocalVector& X, solver_t& solver, const params_t& parameters) { // // by default do nothing. // return true; } // // Public pure virtual methods. // ______________________ public: // // @brief Import the linear system Ax=b // @param[out] // A matrix to import. // @param[out] // B right-hand-side to import. // @param[out] // S solution to import. // @param[in] // parameters parameters to set up the import. // @return true if successful, false otherwise. // virtual bool ImportLinearSystem(LocalMatrix& A, LocalVector& B, LocalVector& S, const params_t& parameters) = 0; // // Public virtual methods. // ______________________ public: // // @brief Method called before the execution linear solver. // @param[inout] // A matrix of the linear system. // @param[inout] // B right-hand-side vector of the linear system. // @param[inout] // X unknown vector of the linear system. // @param[inout] // solver linear solver. // @param[inout] // parameters parameters to configure the operation. // @return true if successful, false otherwise. // virtual bool PreprocessLinearSolve(LocalMatrix& A, LocalVector& B, LocalVector& X, solver_t& solver, const params_t& parameters) { return true; } // // @brief Method called after the execution linear solver. // @param[inout] // A matrix of the linear system. // @param[inout] // B right-hand-side vector of the linear system. // @param[inout] // X unknown vector of the linear system. // @param[inout] // solver linear solver. // @param[inout] // parameters parameters to configure the operation. // @return true if successful, false otherwise. // virtual bool PostprocessLinearSolve(LocalMatrix& A, LocalVector& B, LocalVector& X, solver_t& solver, const params_t& parameters) { return true; } // // @brief Postprocess the import, A, B and X are moved to accelerator. // @param[inout] // A matrix of the linear system. // @param[inout] // B right-hand-side vector of the linear system. // @param[inout] // S solution vector of the linear system. // @param[inout] // solver parameters to set up the import. // @param[inout] // parameters parameters to configure the operation. // @return true if successful, false otherwise. // virtual bool PostprocessImportLinearSystem(LocalMatrix& A, LocalVector& B, LocalVector& S, const params_t& parameters) { S.Allocate("s", A.GetN()); B.Allocate("b", A.GetM()); // // Get a temp vector and set it to one. // S.Ones(); // // Matrix vector product to build B. // A.Apply(S, &B); return true; } // // @brief Configure the linear solver. // // @param[inout] // A matrix of the linear system. // @param[inout] // B right-hand-side vector of the linear system. // @param[inout] // X unknown vector of the linear system. // @param[inout] // solver linear solver // @param[inout] // parameters parameters to configure the operation. // @return true if successful, false otherwise. // bool ConfigureLinearSolver(LocalMatrix& A, LocalVector& B, LocalVector& X, solver_t& solver, const params_t& parameters) { // // Get parameters. // const auto abs_tol = parameters.Get(params_t::abs_tol); const auto rel_tol = parameters.Get(params_t::rel_tol); const auto div_tol = parameters.Get(params_t::div_tol); const auto max_iter = parameters.Get(params_t::max_iter); // // Create preconditioner. // if(s_verbose) { std::cout << "ConfigureLinearSolver CreatePreconditioner ..." << std::endl; } bool success = this->CreatePreconditioner(A, B, X, parameters); if(!success) { rocalution_bench_errmsg << "create preconditioner failed.." << std::endl; return false; } if(s_verbose) { std::cout << "ConfigureLinearSolver CreatePreconditioner done." << std::endl; } // // Initialize the solver. // solver.Verbose(0); solver.SetOperator(A); solver.Init(abs_tol, rel_tol, div_tol, max_iter); // // Get preconditioner. // auto* preconditioner = this->GetPreconditioner(); if(preconditioner != nullptr) { solver.SetPreconditioner(*preconditioner); } // // Preprocess solver build. // if(s_verbose) { std::cout << "ConfigureLinearSolver PreprocessSolverBuild ..." << std::endl; } success = this->PreprocessSolverBuild(A, B, X, solver, parameters); if(!success) { rocalution_bench_errmsg << "preprocess solver build failed.." << std::endl; return false; } if(s_verbose) { std::cout << "ConfigureLinearSolver PreprocessSolverBuild done." << std::endl; } // // solver build. // solver.Build(); // // Postprocess solver build. // if(s_verbose) { std::cout << "ConfigureLinearSolver PostprocessSolverBuild ..." << std::endl; } success = this->PostprocessSolverBuild(A, B, X, solver, parameters); if(!success) { rocalution_bench_errmsg << "postprocess solver build failed.." << std::endl; return false; } if(s_verbose) { std::cout << "ConfigureLinearSolver PostprocessSolverBuild ..." << std::endl; } return success; } }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_driver_itsolver_traits.hpp000066400000000000000000000110211445302240700276330ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_bench_itsolver.hpp" #include "rocalution_bench_solver_parameters.hpp" using namespace rocalution; template struct rocalution_driver_itsolver_traits; template struct rocalution_driver_itsolver_traits { using solver_t = BiCGStab, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = FCG, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = FCG, LocalVector, T>; using preconditioner_t = UAAMG, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = QMRCGStab, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = CG, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = IDR, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = FCG, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = CR, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = CG, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = GMRES, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = FGMRES, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; template struct rocalution_driver_itsolver_traits { using solver_t = BiCGStab, LocalVector, T>; using preconditioner_t = Preconditioner, LocalVector, T>; }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_driver_itsolver_uaamg.hpp000066400000000000000000000171301445302240700274260ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_driver_itsolver.hpp" template struct rocalution_driver_itsolver : rocalution_driver_itsolver_base { static constexpr auto ITSOLVER = rocalution_enum_itsolver::uaamg; using params_t = rocalution_bench_solver_parameters; using traits_t = rocalution_driver_itsolver_traits; using solver_t = typename traits_t::solver_t; LocalVector b2; LocalVector e; FCG, LocalVector, T> cgs; IterativeLinearSolver, LocalVector, T>** sm; Preconditioner, LocalVector, T>** smooth; virtual bool PreprocessLinearSolve(LocalMatrix& A, LocalVector& B, LocalVector& X, solver_t& solver, const rocalution_bench_solver_parameters& parameters) override { const auto rebuild_numeric = parameters.Get(params_t::rebuild_numeric); const auto format = parameters.Get(params_t::format); if(rebuild_numeric) { b2.MoveToAccelerator(); e.MoveToAccelerator(); b2.Allocate("b2", A.GetM()); e.Allocate("e", A.GetN()); if(this->cache_csr_val) { A.UpdateValuesCSR(this->cache_csr_val); delete[] this->cache_csr_val; this->cache_csr_val = nullptr; } // b2 = A * 1 e.Ones(); A.Apply(e, &b2); solver.ReBuildNumeric(); } // Matrix format const auto blockdim = parameters.Get(params_t::blockdim); A.ConvertTo(format, format == BCSR ? blockdim : 1); return true; } virtual bool PostprocessLinearSolve(LocalMatrix& A, LocalVector& B, LocalVector& X, solver_t& solver, const rocalution_bench_solver_parameters& parameters) override { return true; } virtual bool CreatePreconditioner(LocalMatrix& A, LocalVector& B, LocalVector& X, const rocalution_bench_solver_parameters& parameters) override { const auto pre_smooth = parameters.Get(params_t::solver_pre_smooth); const auto post_smooth = parameters.Get(params_t::solver_post_smooth); const auto cycle = parameters.Get(params_t::cycle); const auto scaling = parameters.Get(params_t::solver_ordering); const auto format = parameters.Get(params_t::format); const auto couplingStrength = parameters.Get(params_t::solver_coupling_strength); const auto overInterp = parameters.Get(params_t::solver_over_interp); const auto coarsestLevel = parameters.Get(params_t::solver_coarsest_level); const auto enum_coarsening_strategy = parameters.GetEnumCoarseningStrategy(); if(enum_coarsening_strategy.is_invalid()) { rocalution_bench_errmsg << "coarsening strategy is invalid" << std::endl; return false; } const auto enum_smoother = parameters.GetEnumSmoother(); if(enum_smoother.is_invalid()) { rocalution_bench_errmsg << "smoother is invalid" << std::endl; return false; } auto* preconditioner = new UAAMG, LocalVector, T>(); preconditioner->SetCoarsestLevel(coarsestLevel); preconditioner->SetCycle(cycle); preconditioner->SetOperator(A); preconditioner->SetManualSmoothers(true); preconditioner->SetManualSolver(true); preconditioner->SetScaling(scaling); switch(enum_coarsening_strategy.value) { case rocalution_enum_coarsening_strategy::Greedy: { preconditioner->SetCoarseningStrategy(CoarseningStrategy::Greedy); break; } case rocalution_enum_coarsening_strategy::PMIS: { preconditioner->SetCoarseningStrategy(CoarseningStrategy::PMIS); break; } } preconditioner->SetCouplingStrength(couplingStrength); preconditioner->SetOverInterp(overInterp); preconditioner->BuildHierarchy(); // Get number of hierarchy levels int levels = preconditioner->GetNumLevels(); // Coarse grid solver this->cgs.Verbose(0); // Smoother for each level this->sm = new IterativeLinearSolver, LocalVector, T>*[levels - 1]; this->smooth = new Preconditioner, LocalVector, T>*[levels - 1]; for(int i = 0; i < levels - 1; ++i) { this->sm[i] = new FixedPoint, LocalVector, T>; switch(enum_smoother.value) { case rocalution_enum_smoother::FSAI: { this->smooth[i] = new FSAI, LocalVector, T>; break; } case rocalution_enum_smoother::ILU: { this->smooth[i] = new ILU, LocalVector, T>; break; } } this->sm[i]->SetPreconditioner(*(this->smooth[i])); this->sm[i]->Verbose(0); } preconditioner->SetSmoother(sm); preconditioner->SetSolver(cgs); preconditioner->SetSmootherPreIter(pre_smooth); preconditioner->SetSmootherPostIter(post_smooth); preconditioner->SetOperatorFormat(format); preconditioner->InitMaxIter(1); preconditioner->Verbose(0); this->SetPreconditioner(preconditioner); return true; } }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_coarsening_strategy.cpp000066400000000000000000000061121445302240700301210ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_enum_coarsening_strategy.hpp" constexpr const char* rocalution_enum_coarsening_strategy::names[rocalution_enum_coarsening_strategy::size]; constexpr rocalution_enum_coarsening_strategy::value_type rocalution_enum_coarsening_strategy::all[rocalution_enum_coarsening_strategy::size]; #include bool rocalution_enum_coarsening_strategy::is_invalid() const { for(auto v : all) { if(this->value == v) { return false; } } return true; } rocalution_enum_coarsening_strategy::rocalution_enum_coarsening_strategy(const char* name_) { for(auto v : all) { if(!strcmp(name_, names[v])) { this->value = v; return; } } rocalution_bench_errmsg << "coarsening_strategy '" << name_ << "' is invalid, the list of valid coarsening_strategys is" << std::endl; for(auto v : all) { rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; } throw false; }; // // Default contructor. // rocalution_enum_coarsening_strategy::rocalution_enum_coarsening_strategy() : value((value_type)-1){}; // // // rocalution_enum_coarsening_strategy& rocalution_enum_coarsening_strategy::operator()(const char* name_) { this->value = (value_type)-1; for(auto v : all) { if(!strcmp(name_, names[v])) { this->value = v; return *this; } } rocalution_bench_errmsg << "coarsening_strategy '" << name_ << "' is invalid, the list of valid coarsening_strategys is" << std::endl; for(auto v : all) { rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; } throw false; } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_coarsening_strategy.hpp000066400000000000000000000045021445302240700301270ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution/rocalution.hpp" #include "utility.hpp" #include struct rocalution_enum_coarsening_strategy { #define LIST_ROCALUTION_ENUM_COARSENING_STRATEGY \ ENUM_COARSENING_STRATEGY(Greedy) \ ENUM_COARSENING_STRATEGY(PMIS) // // // #define ENUM_COARSENING_STRATEGY(x_) x_, typedef enum rocalution_enum_coarsening_strategy__ : int { LIST_ROCALUTION_ENUM_COARSENING_STRATEGY } value_type; static constexpr value_type all[]{LIST_ROCALUTION_ENUM_COARSENING_STRATEGY}; static constexpr std::size_t size = countof(all); #undef ENUM_COARSENING_STRATEGY // // // #define ENUM_COARSENING_STRATEGY(x_) #x_, static constexpr const char* names[size]{LIST_ROCALUTION_ENUM_COARSENING_STRATEGY}; #undef ENUM_COARSENING_STRATEGY bool is_invalid() const; rocalution_enum_coarsening_strategy(); rocalution_enum_coarsening_strategy& operator()(const char* name_); rocalution_enum_coarsening_strategy(const char* name_); value_type value{}; }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_directsolver.cpp000066400000000000000000000055441445302240700265640ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_enum_directsolver.hpp" #include constexpr const char* rocalution_enum_directsolver::names[rocalution_enum_directsolver::size]; constexpr rocalution_enum_directsolver::value_type rocalution_enum_directsolver::all[]; const char* rocalution_enum_directsolver::to_string() const { return rocalution_enum_directsolver::to_string(this->value); } bool rocalution_enum_directsolver::is_invalid() const { for(auto v : all) { if(this->value == v) { return false; } } return true; } rocalution_enum_directsolver::rocalution_enum_directsolver(const char* name) { this->value = (value_type)-1; for(auto v : all) { const char* str = names[v]; if(!strcmp(name, str)) { this->value = v; break; } } rocalution_bench_errmsg << "direct solver '" << name << "' is invalid, the list of valid direct solvers is" << std::endl; for(auto v : all) { const char* str = names[v]; rocalution_bench_errmsg << " - '" << str << "'" << std::endl; } throw false; } // // Default contructor. // rocalution_enum_directsolver::rocalution_enum_directsolver() : value((value_type)-1){}; // // // rocalution_enum_directsolver& rocalution_enum_directsolver::operator()(const char* function) { this->value = (value_type)-1; for(auto v : all) { const char* str = names[v]; if(!strcmp(function, str)) { this->value = v; break; } } return *this; } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_directsolver.hpp000066400000000000000000000064321445302240700265660ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "utility.hpp" #include // // List the enumeration values. // // clang-format off #define ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM_EACH \ ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(inversion) \ ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(lu) \ ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(qr) // clang-format on struct rocalution_enum_directsolver { private: public: #define ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(x_) x_, typedef enum rocalution_enum_directsolver__ : int { ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM_EACH } value_type; static constexpr value_type all[] = {ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM_EACH}; #undef ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM static constexpr std::size_t size = countof(all); value_type value{}; private: #define ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(x_) #x_, static constexpr const char* names[size]{ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM_EACH}; #undef ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM public: operator value_type() const { return this->value; }; rocalution_enum_directsolver(); rocalution_enum_directsolver& operator()(const char* function); rocalution_enum_directsolver(const char* function); const char* to_string() const; bool is_invalid() const; static inline const char* to_string(rocalution_enum_directsolver::value_type value) { // // switch for checking inconsistency. // switch(value) { /// #define ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(x_) \ case x_: \ { \ if(strcmp(#x_, names[value])) \ return nullptr; \ break; \ } ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM_EACH; #undef ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM /// } return names[value]; } }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_directsolver_traits.hpp000066400000000000000000000040461445302240700301530ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution_bench_solver_template_base.hpp" #include "rocalution_enum_directsolver.hpp" using namespace rocalution; template struct rocalution_enum_directsolver_traits; template struct rocalution_enum_directsolver_traits { using solver_t = LU, LocalVector, T>; }; template struct rocalution_enum_directsolver_traits { using solver_t = QR, LocalVector, T>; }; template struct rocalution_enum_directsolver_traits { using solver_t = Inversion, LocalVector, T>; }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_itsolver.cpp000066400000000000000000000062301445302240700257170ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_enum_itsolver.hpp" #include constexpr const char* rocalution_enum_itsolver::names[rocalution_enum_itsolver::size]; constexpr rocalution_enum_itsolver::value_type rocalution_enum_itsolver::all[]; const char* rocalution_enum_itsolver::to_string() const { return rocalution_enum_itsolver::to_string(this->value); } bool rocalution_enum_itsolver::is_invalid() const { for(auto v : all) { if(this->value == v) { return false; } } return true; } rocalution_enum_itsolver::rocalution_enum_itsolver(const char* itsolver_name) { this->value = (value_type)-1; for(auto v : all) { const char* str = names[v]; if(!strcmp(itsolver_name, str)) { this->value = v; return; } } rocalution_bench_errmsg << "iterative solver '" << itsolver_name << "' is invalid, the list of valid iterative solvers is" << std::endl; for(auto v : all) { const char* str = names[v]; rocalution_bench_errmsg << " - '" << str << "'" << std::endl; } throw false; } // // Default contructor. // rocalution_enum_itsolver::rocalution_enum_itsolver() : value((value_type)-1){}; // // // rocalution_enum_itsolver& rocalution_enum_itsolver::operator()(const char* itsolver_name) { this->value = (value_type)-1; for(auto v : all) { const char* str = names[v]; if(!strcmp(itsolver_name, str)) { this->value = v; return *this; } } rocalution_bench_errmsg << "iterative solver '" << itsolver_name << "' is invalid, the list of valid iterative solvers is" << std::endl; for(auto v : all) { const char* str = names[v]; rocalution_bench_errmsg << " - '" << str << "'" << std::endl; } throw false; } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_itsolver.hpp000066400000000000000000000072021445302240700257240ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "utility.hpp" #include // // List the enumeration values. // // clang-format off #define ROCALUTION_ENUM_ITSOLVER_TRANSFORM_EACH \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(gmres) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(bicgstab) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(fgmres) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(cg) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(cr) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(fcg) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(idr) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(pairwise_amg) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(qmrcgstab) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(ruge_stueben_amg) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(saamg) \ ROCALUTION_ENUM_ITSOLVER_TRANSFORM(uaamg) // clang-format on struct rocalution_enum_itsolver { private: public: #define ROCALUTION_ENUM_ITSOLVER_TRANSFORM(x_) x_, typedef enum rocalution_enum_itsolver__ : int { ROCALUTION_ENUM_ITSOLVER_TRANSFORM_EACH } value_type; static constexpr value_type all[] = {ROCALUTION_ENUM_ITSOLVER_TRANSFORM_EACH}; #undef ROCALUTION_ENUM_ITSOLVER_TRANSFORM static constexpr std::size_t size = countof(all); value_type value{}; private: #define ROCALUTION_ENUM_ITSOLVER_TRANSFORM(x_) #x_, static constexpr const char* names[size]{ROCALUTION_ENUM_ITSOLVER_TRANSFORM_EACH}; #undef ROCALUTION_ENUM_ITSOLVER_TRANSFORM public: operator value_type() const { return this->value; }; rocalution_enum_itsolver(); rocalution_enum_itsolver& operator()(const char* function); rocalution_enum_itsolver(const char* function); const char* to_string() const; bool is_invalid() const; static inline const char* to_string(rocalution_enum_itsolver::value_type value) { // // switch for checking inconsistency. // switch(value) { /// #define ROCALUTION_ENUM_ITSOLVER_TRANSFORM(x_) \ case x_: \ { \ if(strcmp(#x_, names[value])) \ return nullptr; \ break; \ } ROCALUTION_ENUM_ITSOLVER_TRANSFORM_EACH; #undef ROCALUTION_ENUM_ITSOLVER_TRANSFORM /// } return names[value]; } }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_matrix_init.cpp000066400000000000000000000057371445302240700264120ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_enum_matrix_init.hpp" constexpr const char* rocalution_enum_matrix_init::names[rocalution_enum_matrix_init::size]; constexpr rocalution_enum_matrix_init::value_type rocalution_enum_matrix_init::all[rocalution_enum_matrix_init::size]; #include bool rocalution_enum_matrix_init::is_invalid() const { for(auto v : all) { if(this->value == v) { return false; } } return true; } rocalution_enum_matrix_init::rocalution_enum_matrix_init(const char* name_) { for(auto v : all) { if(!strcmp(name_, names[v])) { this->value = v; return; } } rocalution_bench_errmsg << "matrix initialization '" << name_ << "' is invalid, the list of valid matrix initialization is" << std::endl; for(auto v : all) { rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; } throw false; }; // // Default contructor. // rocalution_enum_matrix_init::rocalution_enum_matrix_init() : value((value_type)-1){}; // // // rocalution_enum_matrix_init& rocalution_enum_matrix_init::operator()(const char* name_) { this->value = (value_type)-1; for(auto v : all) { if(!strcmp(name_, names[v])) { this->value = v; return *this; } } rocalution_bench_errmsg << "matrix initialization '" << name_ << "' is invalid, the list of valid matrix initialization is" << std::endl; for(auto v : all) { rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; } throw false; } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_matrix_init.hpp000066400000000000000000000043651445302240700264130ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution/rocalution.hpp" #include "utility.hpp" #include struct rocalution_enum_matrix_init { #define LIST_ROCALUTION_ENUM_MATRIX_INIT \ ENUM_MATRIX_INIT(laplacian) \ ENUM_MATRIX_INIT(permuted_identity) \ ENUM_MATRIX_INIT(file) // // // #define ENUM_MATRIX_INIT(x_) x_, typedef enum rocalution_enum_matrix_init__ : int { LIST_ROCALUTION_ENUM_MATRIX_INIT } value_type; static constexpr value_type all[]{LIST_ROCALUTION_ENUM_MATRIX_INIT}; static constexpr std::size_t size = countof(all); #undef ENUM_MATRIX_INIT // // // #define ENUM_MATRIX_INIT(x_) #x_, static constexpr const char* names[size]{LIST_ROCALUTION_ENUM_MATRIX_INIT}; #undef ENUM_MATRIX_INIT bool is_invalid() const; rocalution_enum_matrix_init(); rocalution_enum_matrix_init& operator()(const char* name_); rocalution_enum_matrix_init(const char* name_); value_type value{}; }; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_preconditioner.cpp000066400000000000000000000056651445302240700271070ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_enum_preconditioner.hpp" constexpr const char* rocalution_enum_preconditioner::names[rocalution_enum_preconditioner::size]; constexpr rocalution_enum_preconditioner::value_type rocalution_enum_preconditioner::all[rocalution_enum_preconditioner::size]; #include bool rocalution_enum_preconditioner::is_invalid() const { for(auto v : all) { if(this->value == v) { return false; } } return true; } rocalution_enum_preconditioner::rocalution_enum_preconditioner(const char* name_) { for(auto v : all) { if(!strcmp(name_, names[v])) { this->value = v; return; } } rocalution_bench_errmsg << "preconditioner '" << name_ << "' is invalid, the list of valid preconditioners is" << std::endl; for(auto v : all) { rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; } throw false; }; // // Default contructor. // rocalution_enum_preconditioner::rocalution_enum_preconditioner() : value((value_type)-1){}; // // // rocalution_enum_preconditioner& rocalution_enum_preconditioner::operator()(const char* name_) { this->value = (value_type)-1; for(auto v : all) { if(!strcmp(name_, names[v])) { this->value = v; return *this; } } rocalution_bench_errmsg << "preconditioner '" << name_ << "' is invalid, the list of valid preconditioners is" << std::endl; for(auto v : all) { rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; } throw false; } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_preconditioner.hpp000066400000000000000000000060131445302240700271000ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution/rocalution.hpp" #include "utility.hpp" #include struct rocalution_enum_preconditioner { #define LIST_ROCALUTION_ENUM_PRECONDITIONER \ ENUM_PRECONDITIONER(none) \ ENUM_PRECONDITIONER(chebyshev) \ ENUM_PRECONDITIONER(FSAI) \ ENUM_PRECONDITIONER(SPAI) \ ENUM_PRECONDITIONER(TNS) \ ENUM_PRECONDITIONER(Jacobi) \ ENUM_PRECONDITIONER(GS) \ ENUM_PRECONDITIONER(SGS) \ ENUM_PRECONDITIONER(ILU) \ ENUM_PRECONDITIONER(ILUT) \ ENUM_PRECONDITIONER(IC) \ ENUM_PRECONDITIONER(MCGS) \ ENUM_PRECONDITIONER(MCSGS) \ ENUM_PRECONDITIONER(MCILU) // // // #define ENUM_PRECONDITIONER(x_) x_, typedef enum rocalution_enum_preconditioner__ : int { LIST_ROCALUTION_ENUM_PRECONDITIONER } value_type; static constexpr value_type all[]{LIST_ROCALUTION_ENUM_PRECONDITIONER}; static constexpr std::size_t size = countof(all); #undef ENUM_PRECONDITIONER // // // #define ENUM_PRECONDITIONER(x_) #x_, static constexpr const char* names[size]{LIST_ROCALUTION_ENUM_PRECONDITIONER}; #undef ENUM_PRECONDITIONER bool is_invalid() const; rocalution_enum_preconditioner(); rocalution_enum_preconditioner& operator()(const char* name_); rocalution_enum_preconditioner(const char* name_); value_type value{}; }; // constexpr const char * rocalution_enum_preconditioner::names[rocalution_enum_preconditioner::size]; // constexpr rocalution_enum_preconditioner::value_type rocalution_enum_preconditioner::all[rocalution_enum_preconditioner::size]; rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_smoother.cpp000066400000000000000000000055171445302240700257170ustar00rootroot00000000000000/*! \file */ /* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "rocalution_enum_smoother.hpp" constexpr const char* rocalution_enum_smoother::names[rocalution_enum_smoother::size]; constexpr rocalution_enum_smoother::value_type rocalution_enum_smoother::all[rocalution_enum_smoother::size]; #include bool rocalution_enum_smoother::is_invalid() const { for(auto v : all) { if(this->value == v) { return false; } } return true; } rocalution_enum_smoother::rocalution_enum_smoother(const char* name_) { for(auto v : all) { if(!strcmp(name_, names[v])) { this->value = v; return; } } rocalution_bench_errmsg << "smoother '" << name_ << "' is invalid, the list of valid smoothers is" << std::endl; for(auto v : all) { rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; } throw false; }; // // Default contructor. // rocalution_enum_smoother::rocalution_enum_smoother() : value((value_type)-1){}; // // // rocalution_enum_smoother& rocalution_enum_smoother::operator()(const char* name_) { this->value = (value_type)-1; for(auto v : all) { if(!strcmp(name_, names[v])) { this->value = v; return *this; } } rocalution_bench_errmsg << "smoother '" << name_ << "' is invalid, the list of valid smoothers is" << std::endl; for(auto v : all) { rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; } throw false; } rocALUTION-rocm-5.7.1/clients/benchmarks/rocalution_enum_smoother.hpp000066400000000000000000000042341445302240700257170ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #include "rocalution/rocalution.hpp" #include "utility.hpp" #include struct rocalution_enum_smoother { #define LIST_ROCALUTION_ENUM_SMOOTHER \ ENUM_SMOOTHER(FSAI) \ ENUM_SMOOTHER(ILU) // // // #define ENUM_SMOOTHER(x_) x_, typedef enum rocalution_enum_smoother__ : int { LIST_ROCALUTION_ENUM_SMOOTHER } value_type; static constexpr value_type all[]{LIST_ROCALUTION_ENUM_SMOOTHER}; static constexpr std::size_t size = countof(all); #undef ENUM_SMOOTHER // // // #define ENUM_SMOOTHER(x_) #x_, static constexpr const char* names[size]{LIST_ROCALUTION_ENUM_SMOOTHER}; #undef ENUM_SMOOTHER bool is_invalid() const; rocalution_enum_smoother(); rocalution_enum_smoother& operator()(const char* name_); rocalution_enum_smoother(const char* name_); value_type value{}; }; rocALUTION-rocm-5.7.1/clients/include/000077500000000000000000000000001445302240700173665ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/clients/include/common.hpp000066400000000000000000000316471445302240700214020ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; template void distribute_matrix(const MPI_Comm* comm, LocalMatrix* lmat, GlobalMatrix* gmat, ParallelManager* pm) { int rank; int num_procs; MPI_Comm_rank(*comm, &rank); MPI_Comm_size(*comm, &num_procs); size_t global_nrow = lmat->GetM(); size_t global_ncol = lmat->GetN(); size_t global_nnz = lmat->GetNnz(); int* global_row_offset = NULL; int* global_col = NULL; ValueType* global_val = NULL; lmat->LeaveDataPtrCSR(&global_row_offset, &global_col, &global_val); // If we have only a single MPI rank, we are done if(num_procs == 1) { pm->SetMPICommunicator(comm); pm->SetGlobalNrow(global_nrow); pm->SetGlobalNcol(global_ncol); pm->SetLocalNrow(global_nrow); pm->SetLocalNcol(global_ncol); gmat->SetParallelManager(*pm); gmat->SetLocalDataPtrCSR(&global_row_offset, &global_col, &global_val, "mat", global_nnz); return; } // Compute local matrix sizes std::vector local_size(num_procs); for(int i = 0; i < num_procs; ++i) { local_size[i] = global_nrow / num_procs; } if(global_nrow % num_procs != 0) { for(size_t i = 0; i < global_nrow % num_procs; ++i) { ++local_size[i]; } } // Compute index offsets std::vector index_offset(num_procs + 1); index_offset[0] = 0; for(int i = 0; i < num_procs; ++i) { index_offset[i + 1] = index_offset[i] + local_size[i]; } // Read sub matrix - row_offset int local_nrow = local_size[rank]; std::vector local_row_offset(local_nrow + 1); for(int i = index_offset[rank], k = 0; k < local_nrow + 1; ++i, ++k) { local_row_offset[k] = global_row_offset[i]; } free_host(&global_row_offset); // Read sub matrix - col and val int local_nnz = local_row_offset[local_nrow] - local_row_offset[0]; std::vector local_col(local_nnz); std::vector local_val(local_nnz); for(int i = local_row_offset[0], k = 0; k < local_nnz; ++i, ++k) { local_col[k] = global_col[i]; local_val[k] = global_val[i]; } free_host(&global_col); free_host(&global_val); // Shift row_offset entries int shift = local_row_offset[0]; for(int i = 0; i < local_nrow + 1; ++i) { local_row_offset[i] -= shift; } int interior_nnz = 0; int ghost_nnz = 0; int boundary_nnz = 0; int neighbors = 0; std::vector> boundary(num_procs, std::vector()); std::vector neighbor(num_procs, false); std::vector> checked(num_procs, std::map()); for(int i = 0; i < local_nrow; ++i) { for(int j = local_row_offset[i]; j < local_row_offset[i + 1]; ++j) { // Interior point if(local_col[j] >= index_offset[rank] && local_col[j] < index_offset[rank + 1]) { ++interior_nnz; } else { // Boundary point above current process if(local_col[j] < index_offset[rank]) { // Loop over ranks above current process for(int r = rank - 1; r >= 0; --r) { // Check if boundary belongs to rank r if(local_col[j] >= index_offset[r] && local_col[j] < index_offset[r + 1]) { // Add boundary point to rank r if it has not been added yet if(!checked[r][i + index_offset[rank]]) { boundary[r].push_back(i + index_offset[rank]); neighbor[r] = true; ++boundary_nnz; checked[r][i + index_offset[rank]] = true; } ++ghost_nnz; // Rank for current boundary point local_col[j] has been found // Continue with next boundary point break; } } } // boundary point below current process if(local_col[j] >= index_offset[rank + 1]) { // Loop over ranks above current process for(int r = rank + 1; r < num_procs; ++r) { // Check if boundary belongs to rank r if(local_col[j] >= index_offset[r] && local_col[j] < index_offset[r + 1]) { // Add boundary point to rank r if it has not been added yet if(!checked[r][i + index_offset[rank]]) { boundary[r].push_back(i + index_offset[rank]); neighbor[r] = true; ++boundary_nnz; checked[r][i + index_offset[rank]] = true; } ++ghost_nnz; // Rank for current boundary point local_col[j] has been found // Continue with next boundary point break; } } } } } } for(int i = 0; i < num_procs; ++i) { if(neighbor[i] == true) { ++neighbors; } } std::vector mpi_req(neighbors * 2); int n = 0; // Array to hold boundary size for each interface std::vector boundary_size(neighbors); // MPI receive boundary sizes for(int i = 0; i < num_procs; ++i) { // If neighbor receive from rank i is expected... if(neighbor[i] == true) { // Receive size of boundary from rank i to current rank MPI_Irecv(&(boundary_size[n]), 1, MPI_INT, i, 0, *comm, &mpi_req[n]); ++n; } } // MPI send boundary sizes for(int i = 0; i < num_procs; ++i) { // Send required if boundary for rank i available if(boundary[i].size() > 0) { int size = boundary[i].size(); // Send size of boundary from current rank to rank i MPI_Isend(&size, 1, MPI_INT, i, 0, *comm, &mpi_req[n]); ++n; } } // Wait to finish communication MPI_Waitall(n - 1, &(mpi_req[0]), MPI_STATUSES_IGNORE); n = 0; // Array to hold boundary offset for each interface int k = 0; std::vector recv_offset(neighbors + 1); std::vector send_offset(neighbors + 1); recv_offset[0] = 0; send_offset[0] = 0; for(int i = 0; i < neighbors; ++i) { recv_offset[i + 1] = recv_offset[i] + boundary_size[i]; } for(int i = 0; i < num_procs; ++i) { if(neighbor[i] == true) { send_offset[k + 1] = send_offset[k] + boundary[i].size(); ++k; } } // Array to hold boundary for each interface std::vector> local_boundary(neighbors); for(int i = 0; i < neighbors; ++i) { local_boundary[i].resize(boundary_size[i]); } // MPI receive boundary for(int i = 0; i < num_procs; ++i) { // If neighbor receive from rank i is expected... if(neighbor[i] == true) { // Receive boundary from rank i to current rank MPI_Irecv( local_boundary[n].data(), boundary_size[n], MPI_INT, i, 0, *comm, &mpi_req[n]); ++n; } } // MPI send boundary for(int i = 0; i < num_procs; ++i) { // Send required if boundary for rank i is available if(boundary[i].size() > 0) { // Send boundary from current rank to rank i MPI_Isend(&(boundary[i][0]), boundary[i].size(), MPI_INT, i, 0, *comm, &mpi_req[n]); ++n; } } // Wait to finish communication MPI_Waitall(n - 1, &(mpi_req[0]), MPI_STATUSES_IGNORE); // Total boundary size int nnz_boundary = 0; for(int i = 0; i < neighbors; ++i) { nnz_boundary += boundary_size[i]; } // Create local boundary index array k = 0; std::vector bnd(boundary_nnz); for(int i = 0; i < num_procs; ++i) { for(unsigned int j = 0; j < boundary[i].size(); ++j) { bnd[k] = boundary[i][j] - index_offset[rank]; ++k; } } // Create boundary index array std::vector boundary_index(nnz_boundary); k = 0; for(int i = 0; i < neighbors; ++i) { for(int j = 0; j < boundary_size[i]; ++j) { boundary_index[k] = local_boundary[i][j]; ++k; } } // Create map with boundary index relations std::map boundary_map; for(int i = 0; i < nnz_boundary; ++i) { boundary_map[boundary_index[i]] = i; } // Build up ghost and interior matrix int* ghost_row = new int[ghost_nnz]; int* ghost_col = new int[ghost_nnz]; ValueType* ghost_val = new ValueType[ghost_nnz]; memset(ghost_row, 0, sizeof(int) * ghost_nnz); memset(ghost_col, 0, sizeof(int) * ghost_nnz); memset(ghost_val, 0, sizeof(ValueType) * ghost_nnz); int* row_offset = new int[local_nrow + 1]; int* col = new int[interior_nnz]; ValueType* val = new ValueType[interior_nnz]; memset(row_offset, 0, sizeof(int) * (local_nrow + 1)); memset(col, 0, sizeof(int) * interior_nnz); memset(val, 0, sizeof(ValueType) * interior_nnz); row_offset[0] = 0; k = 0; int l = 0; for(int i = 0; i < local_nrow; ++i) { for(int j = local_row_offset[i]; j < local_row_offset[i + 1]; ++j) { // Boundary point -- create ghost part if(local_col[j] < index_offset[rank] || local_col[j] >= index_offset[rank + 1]) { ghost_row[k] = i; ghost_col[k] = boundary_map[local_col[j]]; ghost_val[k] = local_val[j]; ++k; } else { // Interior point -- create interior part int c = local_col[j] - index_offset[rank]; col[l] = c; val[l] = local_val[j]; ++l; } } row_offset[i + 1] = l; } std::vector recv(neighbors); std::vector sender(neighbors); int nbc = 0; for(int i = 0; i < num_procs; ++i) { if(neighbor[i] == true) { recv[nbc] = i; sender[nbc] = i; ++nbc; } } pm->SetMPICommunicator(comm); pm->SetGlobalNrow(global_nrow); pm->SetGlobalNcol(global_nrow); pm->SetLocalNrow(local_size[rank]); pm->SetLocalNcol(local_size[rank]); pm->SetBoundaryIndex(boundary_nnz, bnd.data()); pm->SetReceivers(neighbors, recv.data(), recv_offset.data()); pm->SetSenders(neighbors, sender.data(), send_offset.data()); gmat->SetParallelManager(*pm); gmat->SetLocalDataPtrCSR(&row_offset, &col, &val, "mat", interior_nnz); gmat->SetGhostDataPtrCOO(&ghost_row, &ghost_col, &ghost_val, "ghost", ghost_nnz); } rocALUTION-rocm-5.7.1/clients/include/random.cpp000066400000000000000000000036461445302240700213630ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "random.hpp" // Random number generator // Note: We do not use random_device to initialize the RNG, because we want // repeatability in case of test failure. TODO: Add seed as an optional CLI // argument, and print the seed on output, to ensure repeatability. rocalution_rng_t rocalution_rng(69069); rocalution_rng_t rocalution_seed(rocalution_rng); void rocalution_rng_set(rocalution_rng_t a) { rocalution_rng = a; } void rocalution_seed_set(rocalution_rng_t a) { rocalution_seed = a; } rocalution_rng_t& rocalution_rng_get() { return rocalution_rng; } rocalution_rng_t& rocalution_seed_get() { return rocalution_seed; } rocALUTION-rocm-5.7.1/clients/include/random.hpp000066400000000000000000000077361445302240700213740ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_RANDOM_HPP #define TESTING_RANDOM_HPP #include #include #include #include /* ==================================================================================== */ // Random number generator using rocalution_rng_t = std::mt19937; void rocalution_rng_set(rocalution_rng_t a); void rocalution_seed_set(rocalution_rng_t a); rocalution_rng_t& rocalution_rng_get(); rocalution_rng_t& rocalution_seed_get(); // Reset the seed (mainly to ensure repeatability of failures in a given suite) inline void rocalution_seedrand() { rocalution_rng_set(rocalution_seed_get()); } /* ==================================================================================== */ /* generate random number :*/ /*! \brief generate a random number in range [a,b] */ template inline T random_generator_exact(int a = 1, int b = 10) { return std::uniform_int_distribution(a, b)(rocalution_rng_get()); } template <> inline std::complex random_generator_exact>(int a, int b) { return std::complex(random_generator_exact(a, b), random_generator_exact(a, b)); } template <> inline std::complex random_generator_exact>(int a, int b) { return std::complex(random_generator_exact(a, b), random_generator_exact(a, b)); } template ::value, bool> = true> inline T random_generator(T a = static_cast(1), T b = static_cast(10)) { return random_generator_exact(a, b); } template ::value, bool> = true> inline T random_generator(T a = static_cast(0), T b = static_cast(1)) { return std::uniform_real_distribution(a, b)(rocalution_rng_get()); } template <> inline std::complex random_generator>(std::complex a, std::complex b) { float theta = random_generator(0.0f, 2.0f * acos(-1.0f)); float r = random_generator(std::abs(a), std::abs(b)); return std::complex(r * cos(theta), r * sin(theta)); } template <> inline std::complex random_generator>(std::complex a, std::complex b) { double theta = random_generator(0.0, 2.0 * acos(-1.0)); double r = random_generator(std::abs(a), std::abs(b)); return std::complex(r * cos(theta), r * sin(theta)); } #endif // TESTING_RANDOM_HPP rocALUTION-rocm-5.7.1/clients/include/testing_backend.hpp000066400000000000000000000065011445302240700232250ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_BACKEND_HPP #define TESTING_BACKEND_HPP #include "utility.hpp" #include #include using namespace rocalution; void testing_backend_init_order(void) { bool use_acc = false; bool omp_aff = false; int dev = 0; int nthreads = 4; int threshold = 20000; // Try to stop rocalution without initialization stop_rocalution(); // Set OpenMP threads ASSERT_DEATH(set_omp_threads_rocalution(nthreads), ".*Assertion.*"); // Set OpenMP threshold size ASSERT_DEATH(set_omp_threshold_rocalution(threshold), ".*Assertion.*"); // Initialize rocalution platform set_device_rocalution(device); init_rocalution(); // Set OpenMP thread affinity after init_rocalution should terminate ASSERT_DEATH(set_omp_affinity_rocalution(omp_aff), ".*Assertion.*"); // Select a device after init_rocalution should terminate ASSERT_DEATH(set_device_rocalution(dev), ".*Assertion.*"); // Enable/disable accelerator after init_rocalution should terminate ASSERT_DEATH(disable_accelerator_rocalution(use_acc), ".*Assertion.*"); // Stop rocalution platform stop_rocalution(); } void testing_backend(Arguments argus) { int rank = argus.rank; int dev_per_node = argus.dev_per_node; int dev = argus.dev; int nthreads = argus.omp_nthreads; bool affinity = argus.omp_affinity; int threshold = argus.omp_threshold; bool use_acc = argus.use_acc; // Select a device set_device_rocalution(dev); // Enable/disable accelerator disable_accelerator_rocalution(use_acc); // Set OpenMP thread affinity set_omp_affinity_rocalution(affinity); // Initialize rocalution platform init_rocalution(rank, dev_per_node); // Set OpenMP threads set_omp_threads_rocalution(nthreads); // Set OpenMP threshold size set_omp_threshold_rocalution(threshold); // Stop rocalution platform stop_rocalution(); } #endif // TESTING_BACKEND_HPP rocALUTION-rocm-5.7.1/clients/include/testing_bicgstab.hpp000066400000000000000000000115631445302240700234200ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_BICGSTAB_HPP #define TESTING_BICGSTAB_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-2f); } static bool check_residual(double res) { return (res < 1e-5); } template bool testing_bicgstab(Arguments argus) { int ndim = argus.size; std::string precond = argus.precond; unsigned int format = argus.format; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver BiCGStab, LocalVector, T> ls; // Preconditioner Preconditioner, LocalVector, T>* p; if(precond == "None") p = NULL; else if(precond == "Chebyshev") { // Chebyshev preconditioner // Determine min and max eigenvalues T lambda_min; T lambda_max; A.Gershgorin(lambda_min, lambda_max); AIChebyshev, LocalVector, T>* cheb = new AIChebyshev, LocalVector, T>; cheb->Set(3, lambda_max / 7.0, lambda_max); p = cheb; } else if(precond == "FSAI") p = new FSAI, LocalVector, T>; else if(precond == "SPAI") p = new SPAI, LocalVector, T>; else if(precond == "TNS") p = new TNS, LocalVector, T>; else if(precond == "Jacobi") p = new Jacobi, LocalVector, T>; else if(precond == "GS") p = new GS, LocalVector, T>; else if(precond == "SGS") p = new SGS, LocalVector, T>; else if(precond == "ILU") p = new ILU, LocalVector, T>; else if(precond == "ILUT") p = new ILUT, LocalVector, T>; else if(precond == "IC") p = new IC, LocalVector, T>; else if(precond == "MCGS") p = new MultiColoredGS, LocalVector, T>; else if(precond == "MCSGS") p = new MultiColoredSGS, LocalVector, T>; else if(precond == "MCILU") p = new MultiColoredILU, LocalVector, T>; else return false; ls.Verbose(0); ls.SetOperator(A); // Set preconditioner if(p != NULL) { ls.SetPreconditioner(*p); } ls.Init(1e-8, 0.0, 1e+8, 10000); ls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); if(p != NULL) { delete p; } // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_BICGSTAB_HPP rocALUTION-rocm-5.7.1/clients/include/testing_bicgstabl.hpp000066400000000000000000000116641445302240700235760ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_BICGSTABL_HPP #define TESTING_BICGSTABL_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-1f); } static bool check_residual(double res) { return (res < 1e-5); } template bool testing_bicgstabl(Arguments argus) { int ndim = argus.size; std::string precond = argus.precond; unsigned int format = argus.format; int l = argus.index; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -3.0, 4.0); // Solver BiCGStabl, LocalVector, T> ls; // Preconditioner Preconditioner, LocalVector, T>* p; if(precond == "None") p = NULL; else if(precond == "Chebyshev") { // Chebyshev preconditioner // Determine min and max eigenvalues T lambda_min; T lambda_max; A.Gershgorin(lambda_min, lambda_max); AIChebyshev, LocalVector, T>* cheb = new AIChebyshev, LocalVector, T>; cheb->Set(3, lambda_max / 7.0, lambda_max); p = cheb; } else if(precond == "FSAI") p = new FSAI, LocalVector, T>; else if(precond == "SPAI") p = new SPAI, LocalVector, T>; else if(precond == "TNS") p = new TNS, LocalVector, T>; else if(precond == "Jacobi") p = new Jacobi, LocalVector, T>; else if(precond == "GS") p = new GS, LocalVector, T>; else if(precond == "SGS") p = new SGS, LocalVector, T>; else if(precond == "ILU") p = new ILU, LocalVector, T>; else if(precond == "ILUT") p = new ILUT, LocalVector, T>; else if(precond == "IC") p = new IC, LocalVector, T>; else if(precond == "MCGS") p = new MultiColoredGS, LocalVector, T>; else if(precond == "MCSGS") p = new MultiColoredSGS, LocalVector, T>; else if(precond == "MCILU") p = new MultiColoredILU, LocalVector, T>; else return false; ls.Verbose(0); ls.SetOperator(A); // Set preconditioner if(p != NULL) { ls.SetPreconditioner(*p); } ls.Init(1e-8, 0.0, 1e+8, 10000); ls.SetOrder(l); ls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); if(p != NULL) { delete p; } // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_BICGSTABL_HPP rocALUTION-rocm-5.7.1/clients/include/testing_cg.hpp000066400000000000000000000115251445302240700222310ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_CG_HPP #define TESTING_CG_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-3f); } static bool check_residual(double res) { return (res < 1e-6); } template bool testing_cg(Arguments argus) { int ndim = argus.size; std::string precond = argus.precond; unsigned int format = argus.format; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver CG, LocalVector, T> ls; // Preconditioner Preconditioner, LocalVector, T>* p; if(precond == "None") p = NULL; else if(precond == "Chebyshev") { // Chebyshev preconditioner // Determine min and max eigenvalues T lambda_min; T lambda_max; A.Gershgorin(lambda_min, lambda_max); AIChebyshev, LocalVector, T>* cheb = new AIChebyshev, LocalVector, T>; cheb->Set(3, lambda_max / 7.0, lambda_max); p = cheb; } else if(precond == "FSAI") p = new FSAI, LocalVector, T>; else if(precond == "SPAI") p = new SPAI, LocalVector, T>; else if(precond == "TNS") p = new TNS, LocalVector, T>; else if(precond == "Jacobi") p = new Jacobi, LocalVector, T>; else if(precond == "GS") p = new GS, LocalVector, T>; else if(precond == "SGS") p = new SGS, LocalVector, T>; else if(precond == "ILU") p = new ILU, LocalVector, T>; else if(precond == "ILUT") p = new ILUT, LocalVector, T>; else if(precond == "IC") p = new IC, LocalVector, T>; else if(precond == "MCGS") p = new MultiColoredGS, LocalVector, T>; else if(precond == "MCSGS") p = new MultiColoredSGS, LocalVector, T>; else if(precond == "MCILU") p = new MultiColoredILU, LocalVector, T>; else return false; ls.Verbose(0); ls.SetOperator(A); // Set preconditioner if(p != NULL) { ls.SetPreconditioner(*p); } ls.Init(1e-8, 0.0, 1e+8, 10000); ls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); if(p != NULL) { delete p; } // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_CG_HPP rocALUTION-rocm-5.7.1/clients/include/testing_cr.hpp000066400000000000000000000115311445302240700222410ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_CR_HPP #define TESTING_CR_HPP #include "utility.hpp" #include using namespace rocalution; /* static bool check_residual(float res) { return (res < 1e-3f); } */ static bool check_residual(double res) { return (res < 1e-6); } template bool testing_cr(Arguments argus) { int ndim = argus.size; std::string precond = argus.precond; unsigned int format = argus.format; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver CR, LocalVector, T> ls; // Preconditioner Preconditioner, LocalVector, T>* p; if(precond == "None") p = NULL; else if(precond == "Chebyshev") { // Chebyshev preconditioner // Determine min and max eigenvalues T lambda_min; T lambda_max; A.Gershgorin(lambda_min, lambda_max); AIChebyshev, LocalVector, T>* cheb = new AIChebyshev, LocalVector, T>; cheb->Set(3, lambda_max / 7.0, lambda_max); p = cheb; } else if(precond == "FSAI") p = new FSAI, LocalVector, T>; else if(precond == "SPAI") p = new SPAI, LocalVector, T>; else if(precond == "TNS") p = new TNS, LocalVector, T>; else if(precond == "Jacobi") p = new Jacobi, LocalVector, T>; else if(precond == "GS") p = new GS, LocalVector, T>; else if(precond == "SGS") p = new SGS, LocalVector, T>; else if(precond == "ILU") p = new ILU, LocalVector, T>; else if(precond == "ILUT") p = new ILUT, LocalVector, T>; else if(precond == "IC") p = new IC, LocalVector, T>; else if(precond == "MCGS") p = new MultiColoredGS, LocalVector, T>; else if(precond == "MCSGS") p = new MultiColoredSGS, LocalVector, T>; else if(precond == "MCILU") p = new MultiColoredILU, LocalVector, T>; else return false; ls.Verbose(0); ls.SetOperator(A); // Set preconditioner if(p != NULL) { ls.SetPreconditioner(*p); } ls.Init(1e-8, 0.0, 1e+8, 10000); ls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); if(p != NULL) { delete p; } // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_CR_HPP rocALUTION-rocm-5.7.1/clients/include/testing_fcg.hpp000066400000000000000000000115321445302240700223750ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_FCG_HPP #define TESTING_FCG_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-3f); } static bool check_residual(double res) { return (res < 1e-6); } template bool testing_fcg(Arguments argus) { int ndim = argus.size; std::string precond = argus.precond; unsigned int format = argus.format; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver FCG, LocalVector, T> ls; // Preconditioner Preconditioner, LocalVector, T>* p; if(precond == "None") p = NULL; else if(precond == "Chebyshev") { // Chebyshev preconditioner // Determine min and max eigenvalues T lambda_min; T lambda_max; A.Gershgorin(lambda_min, lambda_max); AIChebyshev, LocalVector, T>* cheb = new AIChebyshev, LocalVector, T>; cheb->Set(3, lambda_max / 7.0, lambda_max); p = cheb; } else if(precond == "FSAI") p = new FSAI, LocalVector, T>; else if(precond == "SPAI") p = new SPAI, LocalVector, T>; else if(precond == "TNS") p = new TNS, LocalVector, T>; else if(precond == "Jacobi") p = new Jacobi, LocalVector, T>; else if(precond == "GS") p = new GS, LocalVector, T>; else if(precond == "SGS") p = new SGS, LocalVector, T>; else if(precond == "ILU") p = new ILU, LocalVector, T>; else if(precond == "ILUT") p = new ILUT, LocalVector, T>; else if(precond == "IC") p = new IC, LocalVector, T>; else if(precond == "MCGS") p = new MultiColoredGS, LocalVector, T>; else if(precond == "MCSGS") p = new MultiColoredSGS, LocalVector, T>; else if(precond == "MCILU") p = new MultiColoredILU, LocalVector, T>; else return false; ls.Verbose(0); ls.SetOperator(A); // Set preconditioner if(p != NULL) { ls.SetPreconditioner(*p); } ls.Init(1e-8, 0.0, 1e+8, 10000); ls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); if(p != NULL) { delete p; } // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_FCG_HPP rocALUTION-rocm-5.7.1/clients/include/testing_fgmres.hpp000066400000000000000000000114341445302240700231220ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_FGMRES_HPP #define TESTING_FGMRES_HPP #include "utility.hpp" #include using namespace rocalution; template bool testing_fgmres(Arguments argus) { int ndim = argus.size; int basis = argus.index; std::string precond = argus.precond; unsigned int format = argus.format; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver FGMRES, LocalVector, T> ls; // Preconditioner Preconditioner, LocalVector, T>* p; if(precond == "None") p = NULL; else if(precond == "Chebyshev") { // Chebyshev preconditioner // Determine min and max eigenvalues T lambda_min; T lambda_max; A.Gershgorin(lambda_min, lambda_max); AIChebyshev, LocalVector, T>* cheb = new AIChebyshev, LocalVector, T>; cheb->Set(3, lambda_max / 7.0, lambda_max); p = cheb; } else if(precond == "FSAI") p = new FSAI, LocalVector, T>; else if(precond == "SPAI") p = new SPAI, LocalVector, T>; else if(precond == "TNS") p = new TNS, LocalVector, T>; else if(precond == "Jacobi") p = new Jacobi, LocalVector, T>; else if(precond == "GS") p = new GS, LocalVector, T>; else if(precond == "SGS") p = new SGS, LocalVector, T>; else if(precond == "ILU") p = new ILU, LocalVector, T>; else if(precond == "ILUT") p = new ILUT, LocalVector, T>; else if(precond == "IC") p = new IC, LocalVector, T>; else if(precond == "MCGS") p = new MultiColoredGS, LocalVector, T>; else if(precond == "MCSGS") p = new MultiColoredSGS, LocalVector, T>; else if(precond == "MCILU") p = new MultiColoredILU, LocalVector, T>; else return false; ls.Verbose(0); ls.SetOperator(A); // Set preconditioner if(p != NULL) { ls.SetPreconditioner(*p); } ls.Init(1e-6, 0.0, 1e+8, 10000); ls.SetBasisSize(basis); ls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = (nrm2 < 1e3); // Clean up ls.Clear(); if(p != NULL) { delete p; } // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_FGMRES_HPP rocALUTION-rocm-5.7.1/clients/include/testing_global_matrix.hpp000066400000000000000000000430611445302240700244640ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_GLOBAL_MATRIX_HPP #define TESTING_GLOBAL_MATRIX_HPP #include "utility.hpp" #include #include using namespace rocalution; template void testing_global_matrix_bad_args(void) { int safe_size = 100; // Initialize rocALUTION set_device_rocalution(device); init_rocalution(); GlobalMatrix mat; GlobalVector vec; int* idata = nullptr; T* data = nullptr; allocate_host(safe_size, &idata); allocate_host(safe_size, &data); // SetDataPtrCSR { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH(mat.SetDataPtrCSR( nullptr, &idata, &data, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_row_offset != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCSR( &idata, nullptr, &data, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_col != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCSR( &idata, &idata, nullptr, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_val != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCSR( &idata, &idata, &data, nullptr, &idata, &data, "", safe_size, safe_size), ".*Assertion.*ghost_row_offset != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCSR( &idata, &idata, &data, &idata, nullptr, &data, "", safe_size, safe_size), ".*Assertion.*ghost_col != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCSR( &idata, &idata, &data, &idata, &idata, nullptr, "", safe_size, safe_size), ".*Assertion.*ghost_val != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCSR( &null_int, &idata, &data, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_row_offset != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCSR( &idata, &null_int, &data, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_col != (NULL|__null)*"); ASSERT_DEATH( mat.SetDataPtrCSR( &idata, &idata, &null_data, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_val != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCSR( &idata, &idata, &data, &null_int, &idata, &data, "", safe_size, safe_size), ".*Assertion.*ghost_row_offset != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCSR( &idata, &idata, &data, &idata, &null_int, &data, "", safe_size, safe_size), ".*Assertion.*ghost_col != (NULL|__null)*"); ASSERT_DEATH( mat.SetDataPtrCSR( &idata, &idata, &data, &idata, &idata, &null_data, "", safe_size, safe_size), ".*Assertion.*ghost_val != (NULL|__null)*"); } // SetDataPtrCOO { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH(mat.SetDataPtrCOO( nullptr, &idata, &data, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_row != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCOO( &idata, nullptr, &data, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_col != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCOO( &idata, &idata, nullptr, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_val != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCOO( &idata, &idata, &data, nullptr, &idata, &data, "", safe_size, safe_size), ".*Assertion.*ghost_row != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCOO( &idata, &idata, &data, &idata, nullptr, &data, "", safe_size, safe_size), ".*Assertion.*ghost_col != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCOO( &idata, &idata, &data, &idata, &idata, nullptr, "", safe_size, safe_size), ".*Assertion.*ghost_val != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCOO( &null_int, &idata, &data, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_row != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCOO( &idata, &null_int, &data, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_col != (NULL|__null)*"); ASSERT_DEATH( mat.SetDataPtrCOO( &idata, &idata, &null_data, &idata, &idata, &data, "", safe_size, safe_size), ".*Assertion.*local_val != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCOO( &idata, &idata, &data, &null_int, &idata, &data, "", safe_size, safe_size), ".*Assertion.*ghost_row != (NULL|__null)*"); ASSERT_DEATH(mat.SetDataPtrCOO( &idata, &idata, &data, &idata, &null_int, &data, "", safe_size, safe_size), ".*Assertion.*ghost_col != (NULL|__null)*"); ASSERT_DEATH( mat.SetDataPtrCOO( &idata, &idata, &data, &idata, &idata, &null_data, "", safe_size, safe_size), ".*Assertion.*ghost_val != (NULL|__null)*"); } // SetLocalDataPtrCSR { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH(mat.SetLocalDataPtrCSR(nullptr, &idata, &data, "", safe_size), ".*Assertion.*row_offset != (NULL|__null)*"); ASSERT_DEATH(mat.SetLocalDataPtrCSR(&idata, nullptr, &data, "", safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat.SetLocalDataPtrCSR(&idata, &idata, nullptr, "", safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH(mat.SetLocalDataPtrCSR(&null_int, &idata, &data, "", safe_size), ".*Assertion.*row_offset != (NULL|__null)*"); ASSERT_DEATH(mat.SetLocalDataPtrCSR(&idata, &null_int, &data, "", safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat.SetLocalDataPtrCSR(&idata, &idata, &null_data, "", safe_size), ".*Assertion.*val != (NULL|__null)*"); } // SetGhostDataPtrCSR { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH(mat.SetGhostDataPtrCSR(nullptr, &idata, &data, "", safe_size), ".*Assertion.*row_offset != (NULL|__null)*"); ASSERT_DEATH(mat.SetGhostDataPtrCSR(&idata, nullptr, &data, "", safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat.SetGhostDataPtrCSR(&idata, &idata, nullptr, "", safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH(mat.SetGhostDataPtrCSR(&null_int, &idata, &data, "", safe_size), ".*Assertion.*row_offset != (NULL|__null)*"); ASSERT_DEATH(mat.SetGhostDataPtrCSR(&idata, &null_int, &data, "", safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat.SetGhostDataPtrCSR(&idata, &idata, &null_data, "", safe_size), ".*Assertion.*val != (NULL|__null)*"); } // SetLocalDataPtrCOO { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH(mat.SetLocalDataPtrCOO(nullptr, &idata, &data, "", safe_size), ".*Assertion.*row != (NULL|__null)*"); ASSERT_DEATH(mat.SetLocalDataPtrCOO(&idata, nullptr, &data, "", safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat.SetLocalDataPtrCOO(&idata, &idata, nullptr, "", safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH(mat.SetLocalDataPtrCOO(&null_int, &idata, &data, "", safe_size), ".*Assertion.*row != (NULL|__null)*"); ASSERT_DEATH(mat.SetLocalDataPtrCOO(&idata, &null_int, &data, "", safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat.SetLocalDataPtrCOO(&idata, &idata, &null_data, "", safe_size), ".*Assertion.*val != (NULL|__null)*"); } // SetGhostDataPtrCOO { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH(mat.SetGhostDataPtrCOO(nullptr, &idata, &data, "", safe_size), ".*Assertion.*row != (NULL|__null)*"); ASSERT_DEATH(mat.SetGhostDataPtrCOO(&idata, nullptr, &data, "", safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat.SetGhostDataPtrCOO(&idata, &idata, nullptr, "", safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH(mat.SetGhostDataPtrCOO(&null_int, &idata, &data, "", safe_size), ".*Assertion.*row != (NULL|__null)*"); ASSERT_DEATH(mat.SetGhostDataPtrCOO(&idata, &null_int, &data, "", safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat.SetGhostDataPtrCOO(&idata, &idata, &null_data, "", safe_size), ".*Assertion.*val != (NULL|__null)*"); } // LeaveDataPtrCSR { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH( mat.LeaveDataPtrCSR(&idata, &null_int, &null_data, &null_int, &null_int, &null_data), ".*Assertion.*local_row_offset == (NULL|__null)*"); ASSERT_DEATH( mat.LeaveDataPtrCSR(&null_int, &idata, &null_data, &null_int, &null_int, &null_data), ".*Assertion.*local_col == (NULL|__null)*"); ASSERT_DEATH( mat.LeaveDataPtrCSR(&null_int, &null_int, &data, &null_int, &null_int, &null_data), ".*Assertion.*local_val == (NULL|__null)*"); ASSERT_DEATH( mat.LeaveDataPtrCSR(&null_int, &null_int, &null_data, &idata, &null_int, &null_data), ".*Assertion.*ghost_row_offset == (NULL|__null)*"); ASSERT_DEATH( mat.LeaveDataPtrCSR(&null_int, &null_int, &null_data, &null_int, &idata, &null_data), ".*Assertion.*ghost_col == (NULL|__null)*"); ASSERT_DEATH( mat.LeaveDataPtrCSR(&null_int, &null_int, &null_data, &null_int, &null_int, &data), ".*Assertion.*ghost_val == (NULL|__null)*"); } // LeaveDataPtrCOO { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH( mat.LeaveDataPtrCOO(&idata, &null_int, &null_data, &null_int, &null_int, &null_data), ".*Assertion.*local_row == (NULL|__null)*"); ASSERT_DEATH( mat.LeaveDataPtrCOO(&null_int, &idata, &null_data, &null_int, &null_int, &null_data), ".*Assertion.*local_col == (NULL|__null)*"); ASSERT_DEATH( mat.LeaveDataPtrCOO(&null_int, &null_int, &data, &null_int, &null_int, &null_data), ".*Assertion.*local_val == (NULL|__null)*"); ASSERT_DEATH( mat.LeaveDataPtrCOO(&null_int, &null_int, &null_data, &idata, &null_int, &null_data), ".*Assertion.*ghost_row == (NULL|__null)*"); ASSERT_DEATH( mat.LeaveDataPtrCOO(&null_int, &null_int, &null_data, &null_int, &idata, &null_data), ".*Assertion.*ghost_col == (NULL|__null)*"); ASSERT_DEATH( mat.LeaveDataPtrCOO(&null_int, &null_int, &null_data, &null_int, &null_int, &data), ".*Assertion.*ghost_val == (NULL|__null)*"); } // LeaveLocalDataPtrCSR { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH(mat.LeaveLocalDataPtrCSR(&idata, &null_int, &null_data), ".*Assertion.*row_offset == (NULL|__null)*"); ASSERT_DEATH(mat.LeaveLocalDataPtrCSR(&null_int, &idata, &null_data), ".*Assertion.*col == (NULL|__null)*"); ASSERT_DEATH(mat.LeaveLocalDataPtrCSR(&null_int, &null_int, &data), ".*Assertion.*val == (NULL|__null)*"); } // LeaveGhostDataPtrCSR { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH(mat.LeaveGhostDataPtrCSR(&idata, &null_int, &null_data), ".*Assertion.*row_offset == (NULL|__null)*"); ASSERT_DEATH(mat.LeaveGhostDataPtrCSR(&null_int, &idata, &null_data), ".*Assertion.*col == (NULL|__null)*"); ASSERT_DEATH(mat.LeaveGhostDataPtrCSR(&null_int, &null_int, &data), ".*Assertion.*val == (NULL|__null)*"); } // LeaveLocalDataPtrCOO { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH(mat.LeaveLocalDataPtrCOO(&idata, &null_int, &null_data), ".*Assertion.*row == (NULL|__null)*"); ASSERT_DEATH(mat.LeaveLocalDataPtrCOO(&null_int, &idata, &null_data), ".*Assertion.*col == (NULL|__null)*"); ASSERT_DEATH(mat.LeaveLocalDataPtrCOO(&null_int, &null_int, &data), ".*Assertion.*val == (NULL|__null)*"); } // LeaveGhostDataPtrCOO { int* null_int = nullptr; T* null_data = nullptr; ASSERT_DEATH(mat.LeaveGhostDataPtrCOO(&idata, &null_int, &null_data), ".*Assertion.*row == (NULL|__null)*"); ASSERT_DEATH(mat.LeaveGhostDataPtrCOO(&null_int, &idata, &null_data), ".*Assertion.*col == (NULL|__null)*"); ASSERT_DEATH(mat.LeaveGhostDataPtrCOO(&null_int, &null_int, &data), ".*Assertion.*val == (NULL|__null)*"); } // Apply { GlobalVector* null_vec = nullptr; ASSERT_DEATH(mat.Apply(vec, null_vec), ".*Assertion.*out != (NULL|__null)*"); } // ApplyAdd { GlobalVector* null_vec = nullptr; ASSERT_DEATH(mat.ApplyAdd(vec, 1.0, null_vec), ".*Assertion.*out != (NULL|__null)*"); } // ExtractInverseDiagonal { GlobalVector* null_vec = nullptr; ASSERT_DEATH(mat.ExtractInverseDiagonal(null_vec), ".*Assertion.*vec_inv_diag != (NULL|__null)*"); } // InitialPairwiseAggregation { int val; int* null_int = nullptr; LocalVector lvint; LocalVector* null_vec = nullptr; ASSERT_DEATH(mat.InitialPairwiseAggregation(0.1, val, null_vec, val, &null_int, val, 0), ".*Assertion.*G != (NULL|__null)*"); ASSERT_DEATH(mat.InitialPairwiseAggregation(0.1, val, &lvint, val, &idata, val, 0), ".*Assertion.*rG == (NULL|__null)*"); } // FurtherPairwiseAggregation { int val; int* null_int = nullptr; LocalVector lvint; LocalVector* null_vec = nullptr; ASSERT_DEATH(mat.FurtherPairwiseAggregation(0.1, val, null_vec, val, &idata, val, 0), ".*Assertion.*G != (NULL|__null)*"); ASSERT_DEATH(mat.FurtherPairwiseAggregation(0.1, val, &lvint, val, &null_int, val, 0), ".*Assertion.*rG != (NULL|__null)*"); } // CoarsenOperator { GlobalMatrix Ac; ParallelManager pm; LocalVector lvint; GlobalMatrix* null_mat = nullptr; ParallelManager* null_pm = nullptr; int* null_int = nullptr; ASSERT_DEATH(mat.CoarsenOperator( null_mat, &pm, safe_size, safe_size, lvint, safe_size, idata, safe_size), ".*Assertion.*Ac != (NULL|__null)*"); ASSERT_DEATH(mat.CoarsenOperator( &Ac, null_pm, safe_size, safe_size, lvint, safe_size, idata, safe_size), ".*Assertion.*pm != (NULL|__null)*"); ASSERT_DEATH(mat.CoarsenOperator( &Ac, &pm, safe_size, safe_size, lvint, safe_size, null_int, safe_size), ".*Assertion.*rG != (NULL|__null)*"); } free_host(&idata); free_host(&data); // Stop rocALUTION stop_rocalution(); } #endif // TESTING_GLOBAL_MATRIX_HPP rocALUTION-rocm-5.7.1/clients/include/testing_global_vector.hpp000066400000000000000000000043731445302240700244650ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_GLOBAL_VECTOR_HPP #define TESTING_GLOBAL_VECTOR_HPP #include "utility.hpp" #include #include using namespace rocalution; template void testing_global_vector_bad_args(void) { int safe_size = 100; // Initialize rocALUTION set_device_rocalution(device); init_rocalution(); GlobalVector vec; // SetDataPtr { T* null_data = nullptr; ASSERT_DEATH(vec.SetDataPtr(nullptr, "", safe_size), ".*Assertion.*ptr != (NULL|__null)*"); ASSERT_DEATH(vec.SetDataPtr(&null_data, "", safe_size), ".*Assertion.*ptr != (NULL|__null)*"); } // LeaveDataPtr { T* data = nullptr; allocate_host(safe_size, &data); ASSERT_DEATH(vec.LeaveDataPtr(&data), ".*Assertion.*ptr == (NULL|__null)*"); free_host(&data); } // Stop rocALUTION stop_rocalution(); } #endif // TESTING_GLOBAL_VECTOR_HPP rocALUTION-rocm-5.7.1/clients/include/testing_gmres.hpp000066400000000000000000000120761445302240700227570ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_GMRES_HPP #define TESTING_GMRES_HPP #include "utility.hpp" #include using namespace rocalution; template bool testing_gmres(Arguments argus, bool expectConvergence = true) { int ndim = argus.size; int basis = argus.index; std::string matrix = argus.matrix; std::string precond = argus.precond; unsigned int format = argus.format; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = 0; if(matrix == "laplacian") nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); else if(matrix == "permuted_identity") nrow = gen_permuted_identity(ndim, &csr_ptr, &csr_col, &csr_val); else return false; int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver GMRES, LocalVector, T> ls; // Preconditioner Preconditioner, LocalVector, T>* p; if(precond == "None") p = NULL; else if(precond == "Chebyshev") { // Chebyshev preconditioner // Determine min and max eigenvalues T lambda_min; T lambda_max; A.Gershgorin(lambda_min, lambda_max); AIChebyshev, LocalVector, T>* cheb = new AIChebyshev, LocalVector, T>; cheb->Set(3, lambda_max / 7.0, lambda_max); p = cheb; } else if(precond == "FSAI") p = new FSAI, LocalVector, T>; else if(precond == "SPAI") p = new SPAI, LocalVector, T>; else if(precond == "TNS") p = new TNS, LocalVector, T>; else if(precond == "Jacobi") p = new Jacobi, LocalVector, T>; else if(precond == "GS") p = new GS, LocalVector, T>; else if(precond == "SGS") p = new SGS, LocalVector, T>; else if(precond == "ILU") p = new ILU, LocalVector, T>; else if(precond == "ILUT") p = new ILUT, LocalVector, T>; else if(precond == "IC") p = new IC, LocalVector, T>; else if(precond == "MCGS") p = new MultiColoredGS, LocalVector, T>; else if(precond == "MCSGS") p = new MultiColoredSGS, LocalVector, T>; else if(precond == "MCILU") p = new MultiColoredILU, LocalVector, T>; else return false; ls.Verbose(0); ls.SetOperator(A); // Set preconditioner if(p != NULL) { ls.SetPreconditioner(*p); } ls.Init(1e-6, 0.0, 1e+8, 10000); ls.SetBasisSize(basis); ls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = expectConvergence ? (nrm2 < 1e3) : true; // Clean up ls.Clear(); if(p != NULL) { delete p; } // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_GMRES_HPP rocALUTION-rocm-5.7.1/clients/include/testing_idr.hpp000066400000000000000000000116741445302240700224230ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_IDR_HPP #define TESTING_IDR_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-1f); } static bool check_residual(double res) { return (res < 1e-5); } template bool testing_idr(Arguments argus) { int ndim = argus.size; std::string precond = argus.precond; unsigned int format = argus.format; int l = argus.index; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver IDR, LocalVector, T> ls; // Preconditioner Preconditioner, LocalVector, T>* p; if(precond == "None") p = NULL; else if(precond == "Chebyshev") { // Chebyshev preconditioner // Determine min and max eigenvalues T lambda_min; T lambda_max; A.Gershgorin(lambda_min, lambda_max); AIChebyshev, LocalVector, T>* cheb = new AIChebyshev, LocalVector, T>; cheb->Set(3, lambda_max / 7.0, lambda_max); p = cheb; } else if(precond == "FSAI") p = new FSAI, LocalVector, T>; else if(precond == "SPAI") p = new SPAI, LocalVector, T>; else if(precond == "TNS") p = new TNS, LocalVector, T>; else if(precond == "Jacobi") p = new Jacobi, LocalVector, T>; else if(precond == "GS") p = new GS, LocalVector, T>; else if(precond == "SGS") p = new SGS, LocalVector, T>; else if(precond == "ILU") p = new ILU, LocalVector, T>; else if(precond == "ILUT") p = new ILUT, LocalVector, T>; else if(precond == "IC") p = new IC, LocalVector, T>; else if(precond == "MCGS") p = new MultiColoredGS, LocalVector, T>; else if(precond == "MCSGS") p = new MultiColoredSGS, LocalVector, T>; else if(precond == "MCILU") p = new MultiColoredILU, LocalVector, T>; else return false; ls.Verbose(0); ls.SetOperator(A); // Set preconditioner if(p != NULL) { ls.SetPreconditioner(*p); } ls.Init(1e-8, 0.0, 1e+8, 10000); ls.SetShadowSpace(l); ls.SetRandomSeed(12345ULL); ls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); if(p != NULL) { delete p; } // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_IDR_HPP rocALUTION-rocm-5.7.1/clients/include/testing_inversion.hpp000066400000000000000000000066161445302240700236610ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_INVERSION_HPP #define TESTING_INVERSION_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-3f); } static bool check_residual(double res) { return (res < 1e-6); } template bool testing_inversion(Arguments argus) { int ndim = argus.size; unsigned int format = argus.format; std::string matrix_type = argus.matrix_type; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = 0; int ncol = 0; if(matrix_type == "Laplacian2D") { nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); ncol = nrow; } else if(matrix_type == "PermutedIdentity") { nrow = gen_permuted_identity(ndim, &csr_ptr, &csr_col, &csr_val); ncol = nrow; } else { return false; } int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver Inversion, LocalVector, T> dls; dls.Verbose(0); dls.SetOperator(A); dls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); dls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up dls.Clear(); // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_INVERSION_HPP rocALUTION-rocm-5.7.1/clients/include/testing_local_matrix.hpp000066400000000000000000000513111445302240700243130ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_LOCAL_MATRIX_HPP #define TESTING_LOCAL_MATRIX_HPP #include "utility.hpp" #include #include using namespace rocalution; template void testing_local_matrix_bad_args(void) { int safe_size = 100; // Initialize rocALUTION set_device_rocalution(device); init_rocalution(); LocalMatrix mat1; LocalMatrix mat2; LocalVector vec1; LocalVector int1; // null pointers int* null_int = nullptr; T* null_data = nullptr; // Valid pointers int* vint = nullptr; T* vdata = nullptr; allocate_host(safe_size, &vint); allocate_host(safe_size, &vdata); // ExtractSubMatrix, ExtractSubMatrices, Extract(Inverse)Diagonal, ExtractL/U { LocalMatrix* mat_null = nullptr; LocalMatrix** mat_null2 = nullptr; LocalMatrix*** pmat = new LocalMatrix**[1]; pmat[0] = new LocalMatrix*[1]; pmat[0][0] = new LocalMatrix; LocalVector* null_vec = nullptr; ASSERT_DEATH(mat1.ExtractSubMatrix(0, 0, safe_size, safe_size, mat_null), ".*Assertion.*mat != (NULL|__null)*"); ASSERT_DEATH(mat1.ExtractSubMatrices(safe_size, safe_size, null_int, vint, pmat), ".*Assertion.*row_offset != (NULL|__null)*"); ASSERT_DEATH(mat1.ExtractSubMatrices(safe_size, safe_size, vint, null_int, pmat), ".*Assertion.*col_offset != (NULL|__null)*"); ASSERT_DEATH(mat1.ExtractSubMatrices(safe_size, safe_size, vint, vint, nullptr), ".*Assertion.*mat != (NULL|__null)*"); ASSERT_DEATH(mat1.ExtractSubMatrices(safe_size, safe_size, vint, vint, &mat_null2), ".*Assertion.*mat != (NULL|__null)*"); ASSERT_DEATH(mat1.ExtractDiagonal(null_vec), ".*Assertion.*vec_diag != (NULL|__null)*"); ASSERT_DEATH(mat1.ExtractInverseDiagonal(null_vec), ".*Assertion.*vec_inv_diag != (NULL|__null)*"); ASSERT_DEATH(mat1.ExtractL(mat_null, true), ".*Assertion.*L != (NULL|__null)*"); ASSERT_DEATH(mat1.ExtractU(mat_null, true), ".*Assertion.*U != (NULL|__null)*"); delete pmat[0][0]; delete[] pmat[0]; delete[] pmat; } // CMK, RCMK, ConnectivityOrder, MultiColoring, MaximalIndependentSet, ZeroBlockPermutation { int val; LocalVector* null_vec = nullptr; ASSERT_DEATH(mat1.CMK(null_vec), ".*Assertion.*permutation != (NULL|__null)*"); ASSERT_DEATH(mat1.RCMK(null_vec), ".*Assertion.*permutation != (NULL|__null)*"); ASSERT_DEATH(mat1.ConnectivityOrder(null_vec), ".*Assertion.*permutation != (NULL|__null)*"); ASSERT_DEATH(mat1.MultiColoring(val, &vint, &int1), ".*Assertion.*size_colors == (NULL|__null)*"); ASSERT_DEATH(mat1.MultiColoring(val, &null_int, null_vec), ".*Assertion.*permutation != (NULL|__null)*"); ASSERT_DEATH(mat1.MaximalIndependentSet(val, null_vec), ".*Assertion.*permutation != (NULL|__null)*"); ASSERT_DEATH(mat1.ZeroBlockPermutation(val, null_vec), ".*Assertion.*permutation != (NULL|__null)*"); } // LSolve, USolve, LLSolve, LUSolve, QRSolve { LocalVector* null_vec = nullptr; ASSERT_DEATH(mat1.LSolve(vec1, null_vec), ".*Assertion.*out != (NULL|__null)*"); ASSERT_DEATH(mat1.USolve(vec1, null_vec), ".*Assertion.*out != (NULL|__null)*"); ASSERT_DEATH(mat1.LLSolve(vec1, null_vec), ".*Assertion.*out != (NULL|__null)*"); ASSERT_DEATH(mat1.LLSolve(vec1, vec1, null_vec), ".*Assertion.*out != (NULL|__null)*"); ASSERT_DEATH(mat1.LUSolve(vec1, null_vec), ".*Assertion.*out != (NULL|__null)*"); ASSERT_DEATH(mat1.QRSolve(vec1, null_vec), ".*Assertion.*out != (NULL|__null)*"); } // ICFactorize, Householder { T val; LocalVector* null_vec = nullptr; ASSERT_DEATH(mat1.ICFactorize(null_vec), ".*Assertion.*inv_diag != (NULL|__null)*"); ASSERT_DEATH(mat1.Householder(0, val, null_vec), ".*Assertion.*vec != (NULL|__null)*"); } // CopyFrom functions { ASSERT_DEATH(mat1.UpdateValuesCSR(null_data), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyFromCSR(null_int, vint, vdata), ".*Assertion.*row_offsets != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyFromCSR(vint, null_int, vdata), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyFromCSR(vint, vint, null_data), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyToCSR(null_int, vint, vdata), ".*Assertion.*row_offsets != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyToCSR(vint, null_int, vdata), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyToCSR(vint, vint, null_data), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyFromCOO(null_int, vint, vdata), ".*Assertion.*row != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyFromCOO(vint, null_int, vdata), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyFromCOO(vint, vint, null_data), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyToCOO(null_int, vint, vdata), ".*Assertion.*row != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyToCOO(vint, null_int, vdata), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat1.CopyToCOO(vint, vint, null_data), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH( mat1.CopyFromHostCSR(null_int, vint, vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*row_offset != (NULL|__null)*"); ASSERT_DEATH( mat1.CopyFromHostCSR(vint, null_int, vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH( mat1.CopyFromHostCSR(vint, vint, null_data, "", safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); } // CreateFromMat { LocalMatrix* null_mat = nullptr; ASSERT_DEATH(mat1.CreateFromMap(int1, safe_size, safe_size, null_mat), ".*Assertion.*pro != (NULL|__null)*"); } // Apply(Add) { LocalVector* null_vec = nullptr; ASSERT_DEATH(mat1.Apply(vec1, null_vec), ".*Assertion.*out != (NULL|__null)*"); ASSERT_DEATH(mat1.ApplyAdd(vec1, 1.0, null_vec), ".*Assertion.*out != (NULL|__null)*"); } // Row/Column manipulation { LocalVector* null_vec = nullptr; ASSERT_DEATH(mat1.ExtractColumnVector(0, null_vec), ".*Assertion.*vec != (NULL|__null)*"); ASSERT_DEATH(mat1.ExtractRowVector(0, null_vec), ".*Assertion.*vec != (NULL|__null)*"); } // AMG { int val; LocalVector* null_vec = nullptr; LocalMatrix* null_mat = nullptr; ASSERT_DEATH(mat1.AMGConnect(0.1, null_vec), ".*Assertion.*connections != (NULL|__null)*"); ASSERT_DEATH(mat1.AMGAggregate(int1, null_vec), ".*Assertion.*aggregates != (NULL|__null)*"); ASSERT_DEATH(mat1.AMGSmoothedAggregation(0.1, int1, int1, null_mat, &mat2), ".*Assertion.*prolong != (NULL|__null)*"); ASSERT_DEATH(mat1.AMGSmoothedAggregation(0.1, int1, int1, &mat2, null_mat), ".*Assertion.*restrict != (NULL|__null)*"); ASSERT_DEATH(mat1.AMGAggregation(int1, null_mat, &mat2), ".*Assertion.*prolong != (NULL|__null)*"); ASSERT_DEATH(mat1.AMGAggregation(int1, &mat2, null_mat), ".*Assertion.*restrict != (NULL|__null)*"); ASSERT_DEATH(mat1.RugeStueben(0.1, null_mat, &mat2), ".*Assertion.*prolong != (NULL|__null)*"); ASSERT_DEATH(mat1.RugeStueben(0.1, &mat2, null_mat), ".*Assertion.*restrict != (NULL|__null)*"); ASSERT_DEATH(mat1.InitialPairwiseAggregation(0.1, val, null_vec, val, &null_int, val, 0), ".*Assertion.*G != (NULL|__null)*"); ASSERT_DEATH(mat1.InitialPairwiseAggregation(0.1, val, &int1, val, &vint, val, 0), ".*Assertion.*rG == (NULL|__null)*"); ASSERT_DEATH( mat1.InitialPairwiseAggregation(mat2, 0.1, val, null_vec, val, &null_int, val, 0), ".*Assertion.*G != (NULL|__null)*"); ASSERT_DEATH(mat1.InitialPairwiseAggregation(mat2, 0.1, val, &int1, val, &vint, val, 0), ".*Assertion.*rG == (NULL|__null)*"); ASSERT_DEATH(mat1.FurtherPairwiseAggregation(0.1, val, null_vec, val, &vint, val, 0), ".*Assertion.*G != (NULL|__null)*"); ASSERT_DEATH(mat1.FurtherPairwiseAggregation(0.1, val, &int1, val, &null_int, val, 0), ".*Assertion.*rG != (NULL|__null)*"); ASSERT_DEATH(mat1.FurtherPairwiseAggregation(mat2, 0.1, val, null_vec, val, &vint, val, 0), ".*Assertion.*G != (NULL|__null)*"); ASSERT_DEATH(mat1.FurtherPairwiseAggregation(mat2, 0.1, val, &int1, val, &null_int, val, 0), ".*Assertion.*rG != (NULL|__null)*"); ASSERT_DEATH(mat1.CoarsenOperator( null_mat, nullptr, safe_size, safe_size, int1, safe_size, vint, safe_size), ".*Assertion.*Ac != (NULL|__null)*"); ASSERT_DEATH( mat1.CoarsenOperator( &mat2, nullptr, safe_size, safe_size, int1, safe_size, null_int, safe_size), ".*Assertion.*rG != (NULL|__null)*"); } // SetDataPtr { ASSERT_DEATH( mat1.SetDataPtrCOO(&null_int, &vint, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*row != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrCOO(&vint, &null_int, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrCOO(&vint, &vint, &null_data, "", safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrCOO(nullptr, &vint, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*row != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrCOO(&vint, nullptr, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat1.SetDataPtrCOO(&vint, &vint, nullptr, "", safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrCSR(&null_int, &vint, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*row_offset != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrCSR(&vint, &null_int, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrCSR(&vint, &vint, &null_data, "", safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrCSR(nullptr, &vint, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*row_offset != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrCSR(&vint, nullptr, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH(mat1.SetDataPtrCSR(&vint, &vint, nullptr, "", safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrMCSR(&null_int, &vint, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*row_offset != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrMCSR(&vint, &null_int, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrMCSR(&vint, &vint, &null_data, "", safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrMCSR(nullptr, &vint, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*row_offset != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrMCSR(&vint, nullptr, &vdata, "", safe_size, safe_size, safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrMCSR(&vint, &vint, nullptr, "", safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrELL(&null_int, &vdata, "", safe_size, safe_size, safe_size, safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrELL(&vint, &null_data, "", safe_size, safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrELL(nullptr, &vdata, "", safe_size, safe_size, safe_size, safe_size), ".*Assertion.*col != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrELL(&vint, nullptr, "", safe_size, safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrDIA(&null_int, &vdata, "", safe_size, safe_size, safe_size, safe_size), ".*Assertion.*offset != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrDIA(&vint, &null_data, "", safe_size, safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrDIA(nullptr, &vdata, "", safe_size, safe_size, safe_size, safe_size), ".*Assertion.*offset != (NULL|__null)*"); ASSERT_DEATH( mat1.SetDataPtrDIA(&vint, nullptr, "", safe_size, safe_size, safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH(mat1.SetDataPtrDENSE(&null_data, "", safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); ASSERT_DEATH(mat1.SetDataPtrDENSE(nullptr, "", safe_size, safe_size), ".*Assertion.*val != (NULL|__null)*"); } // LeaveDataPtr { int val; ASSERT_DEATH(mat1.LeaveDataPtrCOO(&vint, &null_int, &null_data), ".*Assertion.*row == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrCOO(&null_int, &vint, &null_data), ".*Assertion.*col == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrCOO(&null_int, &null_int, &vdata), ".*Assertion.*val == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrCSR(&vint, &null_int, &null_data), ".*Assertion.*row_offset == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrCSR(&null_int, &vint, &null_data), ".*Assertion.*col == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrCSR(&null_int, &null_int, &vdata), ".*Assertion.*val == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrMCSR(&vint, &null_int, &null_data), ".*Assertion.*row_offset == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrMCSR(&null_int, &vint, &null_data), ".*Assertion.*col == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrMCSR(&null_int, &null_int, &vdata), ".*Assertion.*val == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrELL(&null_int, &vdata, val), ".*Assertion.*val == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrELL(&vint, &null_data, val), ".*Assertion.*col == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrDIA(&null_int, &vdata, val), ".*Assertion.*val == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrDIA(&vint, &null_data, val), ".*Assertion.*offset == (NULL|__null)*"); ASSERT_DEATH(mat1.LeaveDataPtrDENSE(&vdata), ".*Assertion.*val == (NULL|__null)*"); } free_host(&vint); free_host(&vdata); // Stop rocALUTION stop_rocalution(); } template bool testing_local_matrix_conversions(Arguments argus) { int size = argus.size; int blockdim = argus.blockdim; std::string matrix_type = argus.matrix_type; // Initialize rocALUTION set_device_rocalution(device); init_rocalution(); // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = 0; int ncol = 0; if(matrix_type == "Laplacian2D") { nrow = gen_2d_laplacian(size, &csr_ptr, &csr_col, &csr_val); ncol = nrow; } else if(matrix_type == "PermutedIdentity") { nrow = gen_permuted_identity(size, &csr_ptr, &csr_col, &csr_val); ncol = nrow; } else if(matrix_type == "Random") { nrow = gen_random(100 * size, 50 * size, 6, &csr_ptr, &csr_col, &csr_val); ncol = 50 * size; } else { return false; } int nnz = csr_ptr[nrow]; LocalMatrix A; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, ncol); assert(csr_ptr == NULL); assert(csr_col == NULL); assert(csr_val == NULL); bool success = true; // Check host conversions A.ConvertToCOO(); success &= A.Check(); A.ConvertToDIA(); success &= A.Check(); A.ConvertToELL(); success &= A.Check(); A.ConvertToHYB(); success &= A.Check(); A.ConvertToDENSE(); success &= A.Check(); A.ConvertToMCSR(); success &= A.Check(); A.ConvertToBCSR(blockdim); success &= A.Check(); A.ConvertToCSR(); success &= A.Check(); // Check accelerator conversions A.MoveToAccelerator(); A.ConvertToCOO(); success &= A.Check(); A.ConvertToDIA(); success &= A.Check(); A.ConvertToELL(); success &= A.Check(); A.ConvertToHYB(); success &= A.Check(); A.ConvertToDENSE(); success &= A.Check(); A.ConvertToMCSR(); success &= A.Check(); A.ConvertToBCSR(blockdim); success &= A.Check(); A.ConvertToCSR(); success &= A.Check(); // Stop rocALUTION platform stop_rocalution(); return success; } template bool testing_local_matrix_allocations(Arguments argus) { int size = argus.size; int blockdim = argus.blockdim; int m = size; int n = size; int mb = (m + blockdim - 1) / blockdim; int nb = (n + blockdim - 1) / blockdim; int nnz = 0.05 * m * n; if(nnz == 0) { nnz = m * n; } int nnzb = 0.01 * mb * nb; if(nnzb == 0) { nnzb = mb * nb; } // Initialize rocALUTION set_device_rocalution(device); init_rocalution(); int ndiag = 5; int ell_max_row = 6; int ell_nnz = ell_max_row * m; int coo_nnz = (nnz - ell_nnz) < 0 ? 0 : nnz - ell_nnz; // Testing allocating matrix types LocalMatrix A; A.AllocateCSR("A", nnz, m, n); LocalMatrix B; B.AllocateBCSR("B", nnzb, mb, nb, blockdim); LocalMatrix C; C.AllocateCOO("C", nnz, m, n); LocalMatrix D; D.AllocateDIA("D", nnz, m, n, ndiag); LocalMatrix F; F.AllocateELL("F", ell_nnz, m, n, ell_max_row); LocalMatrix G; G.AllocateHYB("G", ell_nnz, coo_nnz, ell_max_row, m, n); // Stop rocALUTION platform stop_rocalution(); return true; } #endif // TESTING_LOCAL_MATRIX_HPP rocALUTION-rocm-5.7.1/clients/include/testing_local_stencil.hpp000066400000000000000000000041251445302240700244510ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_LOCAL_STENCIL_HPP #define TESTING_LOCAL_STENCIL_HPP #include "utility.hpp" #include #include using namespace rocalution; template void testing_local_stencil_bad_args(void) { // Initialize rocALUTION set_device_rocalution(device); init_rocalution(); LocalStencil stn(Laplace2D); LocalVector vec; // Apply { LocalVector* null_vec = nullptr; ASSERT_DEATH(stn.Apply(vec, null_vec), ".*Assertion.*out != (NULL|__null)*"); } // ApplyAdd { LocalVector* null_vec = nullptr; ASSERT_DEATH(stn.ApplyAdd(vec, 1.0, null_vec), ".*Assertion.*out != (NULL|__null)*"); } // Stop rocALUTION stop_rocalution(); } #endif // TESTING_LOCAL_STENCIL_HPP rocALUTION-rocm-5.7.1/clients/include/testing_local_vector.hpp000066400000000000000000000104001445302240700243030ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_LOCAL_VECTOR_HPP #define TESTING_LOCAL_VECTOR_HPP #include "utility.hpp" #include #include using namespace rocalution; template void testing_local_vector_bad_args(void) { int safe_size = 100; // Initialize rocALUTION set_device_rocalution(device); init_rocalution(); // LocalVector object LocalVector vec; // SetDataPtr { T* null_ptr = nullptr; ASSERT_DEATH(vec.SetDataPtr(nullptr, "", safe_size), ".*Assertion.*ptr != (NULL|__null)*"); ASSERT_DEATH(vec.SetDataPtr(&null_ptr, "", safe_size), ".*Assertion.*ptr != (NULL|__null)*"); } // LeaveDataPtr { T* vdata = nullptr; allocate_host(safe_size, &vdata); ASSERT_DEATH(vec.LeaveDataPtr(&vdata), ".*Assertion.*ptr == (NULL|__null)*"); free_host(&vdata); } // CopyFromData { T* null_ptr = nullptr; ASSERT_DEATH(vec.CopyFromData(null_ptr), ".*Assertion.*data != (NULL|__null)*"); } // CopyToData { T* null_ptr = nullptr; ASSERT_DEATH(vec.CopyToData(null_ptr), ".*Assertion.*data != (NULL|__null)*"); } // SetIndexArray { int* null_int = nullptr; ASSERT_DEATH(vec.SetIndexArray(safe_size, null_int), ".*Assertion.*index != (NULL|__null)*"); } // SetIndexValues { T* null_T = nullptr; ASSERT_DEATH(vec.SetIndexValues(null_T), ".*Assertion.*values != (NULL|__null)*"); } // GetContinuousValues { T* null_T = nullptr; ASSERT_DEATH(vec.GetContinuousValues(0, 0, null_T), ".*Assertion.*values != (NULL|__null)*"); } // ExtractCoarseMapping { int* null_int = nullptr; int* vint = nullptr; allocate_host(safe_size, &vint); ASSERT_DEATH(vec.ExtractCoarseMapping(0, 0, null_int, 0, vint, vint), ".*Assertion.*index != (NULL|__null)*"); ASSERT_DEATH(vec.ExtractCoarseMapping(0, 0, vint, 0, null_int, vint), ".*Assertion.*size != (NULL|__null)*"); ASSERT_DEATH(vec.ExtractCoarseMapping(0, 0, vint, 0, vint, null_int), ".*Assertion.*map != (NULL|__null)*"); free_host(&vint); } // ExtractCoarseBoundary { int* null_int = nullptr; int* vint = nullptr; allocate_host(safe_size, &vint); ASSERT_DEATH(vec.ExtractCoarseBoundary(0, 0, null_int, 0, vint, vint), ".*Assertion.*index != (NULL|__null)*"); ASSERT_DEATH(vec.ExtractCoarseBoundary(0, 0, vint, 0, null_int, vint), ".*Assertion.*size != (NULL|__null)*"); ASSERT_DEATH(vec.ExtractCoarseBoundary(0, 0, vint, 0, vint, null_int), ".*Assertion.*boundary != (NULL|__null)*"); free_host(&vint); } // Stop rocALUTION stop_rocalution(); } #endif // TESTING_LOCAL_VECTOR_HPP rocALUTION-rocm-5.7.1/clients/include/testing_lu.hpp000066400000000000000000000065741445302240700222700ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_LU_HPP #define TESTING_LU_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-3f); } static bool check_residual(double res) { return (res < 1e-6); } template bool testing_lu(Arguments argus) { int ndim = argus.size; unsigned int format = argus.format; std::string matrix_type = argus.matrix_type; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = 0; int ncol = 0; if(matrix_type == "Laplacian2D") { nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); ncol = nrow; } else if(matrix_type == "PermutedIdentity") { nrow = gen_permuted_identity(ndim, &csr_ptr, &csr_col, &csr_val); ncol = nrow; } else { return false; } int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver LU, LocalVector, T> dls; dls.Verbose(0); dls.SetOperator(A); dls.Build(); dls.Print(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); dls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up dls.Clear(); // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_QR_HPP rocALUTION-rocm-5.7.1/clients/include/testing_pairwise_amg.hpp000066400000000000000000000133701445302240700243070ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_PAIRWISE_AMG_HPP #define TESTING_PAIRWISE_AMG_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-2f); } static bool check_residual(double res) { return (res < 1e-5); } template bool testing_pairwise_amg(Arguments argus) { int ndim = argus.size; int pre_iter = argus.pre_smooth; int post_iter = argus.post_smooth; std::string smoother = argus.smoother; unsigned int format = argus.format; unsigned int ordering = argus.ordering; bool rebuildnumeric = argus.rebuildnumeric; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector b2; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); int nnz = csr_ptr[nrow]; T* csr_val2 = NULL; if(rebuildnumeric) { csr_val2 = new T[nnz]; for(int i = 0; i < nnz; i++) { csr_val2[i] = csr_val[i]; } } A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); assert(csr_ptr == NULL); assert(csr_col == NULL); assert(csr_val == NULL); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); b2.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); b2.Allocate("b2", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver CG, LocalVector, T> ls; // AMG PairwiseAMG, LocalVector, T> p; // Setup AMG p.SetOrdering(ordering); p.SetCoarsestLevel(300); p.SetCycle(Kcycle); p.SetOperator(A); p.SetManualSmoothers(true); p.SetManualSolver(true); p.BuildHierarchy(); // Get number of hierarchy levels int levels = p.GetNumLevels(); // Coarse grid solver CG, LocalVector, T> cgs; cgs.Verbose(0); // Smoother for each level IterativeLinearSolver, LocalVector, T>** sm = new IterativeLinearSolver, LocalVector, T>*[levels - 1]; Preconditioner, LocalVector, T>** smooth = new Preconditioner, LocalVector, T>*[levels - 1]; for(int i = 0; i < levels - 1; ++i) { FixedPoint, LocalVector, T>* fp = new FixedPoint, LocalVector, T>; sm[i] = fp; if(smoother == "Jacobi") { smooth[i] = new Jacobi, LocalVector, T>; fp->SetRelaxation(0.67); } else if(smoother == "MCGS") { smooth[i] = new MultiColoredGS, LocalVector, T>; fp->SetRelaxation(1.3); } else if(smoother == "MCILU") smooth[i] = new MultiColoredILU, LocalVector, T>; else return false; sm[i]->SetPreconditioner(*(smooth[i])); sm[i]->Verbose(0); } p.SetSmoother(sm); p.SetSolver(cgs); p.SetSmootherPreIter(pre_iter); p.SetSmootherPostIter(post_iter); p.SetOperatorFormat(format); p.InitMaxIter(1); p.Verbose(0); ls.Verbose(0); ls.SetOperator(A); ls.SetPreconditioner(p); ls.Init(1e-8, 0.0, 1e+8, 10000); ls.Build(); if(rebuildnumeric) { A.UpdateValuesCSR(csr_val2); delete[] csr_val2; // b2 = A * 1 A.Apply(e, &b2); ls.ReBuildNumeric(); } // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(rebuildnumeric ? b2 : b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); // TODO // Stop rocALUTION platform stop_rocalution(); for(int i = 0; i < levels - 1; ++i) { delete smooth[i]; delete sm[i]; } delete[] smooth; delete[] sm; return success; } #endif // TESTING_PAIRWISE_AMG_HPP rocALUTION-rocm-5.7.1/clients/include/testing_parallel_manager.hpp000066400000000000000000000055401445302240700251260ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_PARALLEL_MANAGER_HPP #define TESTING_PARALLEL_MANAGER_HPP #include "utility.hpp" #include #include using namespace rocalution; template void testing_parallel_manager_bad_args(void) { int safe_size = 100; // Initialize rocALUTION set_device_rocalution(device); init_rocalution(); ParallelManager pm; int* idata = nullptr; allocate_host(safe_size, &idata); // SetMPICommunicator { void* null_ptr = nullptr; ASSERT_DEATH(pm.SetMPICommunicator(null_ptr), ".*Assertion.*comm != (NULL|__null)*"); } // SetBoundaryIndex { int* null_int = nullptr; ASSERT_DEATH(pm.SetBoundaryIndex(safe_size, null_int), ".*Assertion.*index != (NULL|__null)*"); } // SetReceivers { int* null_int = nullptr; ASSERT_DEATH(pm.SetReceivers(safe_size, null_int, idata), ".*Assertion.*recvs != (NULL|__null)*"); ASSERT_DEATH(pm.SetReceivers(safe_size, idata, null_int), ".*Assertion.*recv_offset != (NULL|__null)*"); } // SetSenders { int* null_int = nullptr; ASSERT_DEATH(pm.SetSenders(safe_size, null_int, idata), ".*Assertion.*sends != (NULL|__null)*"); ASSERT_DEATH(pm.SetSenders(safe_size, idata, null_int), ".*Assertion.*send_offset != (NULL|__null)*"); } free_host(&idata); // Stop rocALUTION stop_rocalution(); } #endif // TESTING_PARALLEL_MANAGER_HPP rocALUTION-rocm-5.7.1/clients/include/testing_qmrcgstab.hpp000066400000000000000000000115701445302240700236230ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_QMRCGSTAB_HPP #define TESTING_QMRCGSTAB_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-3f); } static bool check_residual(double res) { return (res < 1e-6); } template bool testing_qmrcgstab(Arguments argus) { int ndim = argus.size; std::string precond = argus.precond; unsigned int format = argus.format; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver QMRCGStab, LocalVector, T> ls; // Preconditioner Preconditioner, LocalVector, T>* p; if(precond == "None") p = NULL; else if(precond == "Chebyshev") { // Chebyshev preconditioner // Determine min and max eigenvalues T lambda_min; T lambda_max; A.Gershgorin(lambda_min, lambda_max); AIChebyshev, LocalVector, T>* cheb = new AIChebyshev, LocalVector, T>; cheb->Set(3, lambda_max / 7.0, lambda_max); p = cheb; } else if(precond == "FSAI") p = new FSAI, LocalVector, T>; else if(precond == "SPAI") p = new SPAI, LocalVector, T>; else if(precond == "TNS") p = new TNS, LocalVector, T>; else if(precond == "Jacobi") p = new Jacobi, LocalVector, T>; else if(precond == "GS") p = new GS, LocalVector, T>; else if(precond == "SGS") p = new SGS, LocalVector, T>; else if(precond == "ILU") p = new ILU, LocalVector, T>; else if(precond == "ILUT") p = new ILUT, LocalVector, T>; else if(precond == "IC") p = new IC, LocalVector, T>; else if(precond == "MCGS") p = new MultiColoredGS, LocalVector, T>; else if(precond == "MCSGS") p = new MultiColoredSGS, LocalVector, T>; else if(precond == "MCILU") p = new MultiColoredILU, LocalVector, T>; else return false; ls.Verbose(0); ls.SetOperator(A); // Set preconditioner if(p != NULL) { ls.SetPreconditioner(*p); } ls.Init(1e-8, 0.0, 1e+8, 10000); ls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); if(p != NULL) { delete p; } // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_QMRCGSTAB_HPP rocALUTION-rocm-5.7.1/clients/include/testing_qr.hpp000066400000000000000000000065531445302240700222670ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_QR_HPP #define TESTING_QR_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-3f); } static bool check_residual(double res) { return (res < 1e-6); } template bool testing_qr(Arguments argus) { int ndim = argus.size; unsigned int format = argus.format; std::string matrix_type = argus.matrix_type; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = 0; int ncol = 0; if(matrix_type == "Laplacian2D") { nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); ncol = nrow; } else if(matrix_type == "PermutedIdentity") { nrow = gen_permuted_identity(ndim, &csr_ptr, &csr_col, &csr_val); ncol = nrow; } else { return false; } int nnz = csr_ptr[nrow]; A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver QR, LocalVector, T> dls; dls.Verbose(0); dls.SetOperator(A); dls.Build(); // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); dls.Solve(b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up dls.Clear(); // Stop rocALUTION platform stop_rocalution(); return success; } #endif // TESTING_QR_HPP rocALUTION-rocm-5.7.1/clients/include/testing_ruge_stueben_amg.hpp000066400000000000000000000134241445302240700251530ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_RUGE_STUEBEN_AMG_HPP #define TESTING_RUGE_STUEBEN_AMG_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-2f); } static bool check_residual(double res) { return (res < 1e-5); } template bool testing_ruge_stueben_amg(Arguments argus) { int ndim = argus.size; int pre_iter = argus.pre_smooth; int post_iter = argus.post_smooth; std::string smoother = argus.smoother; unsigned int format = argus.format; int cycle = argus.cycle; bool scaling = argus.ordering; bool rebuildnumeric = argus.rebuildnumeric; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector b2; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); int nnz = csr_ptr[nrow]; T* csr_val2 = NULL; if(rebuildnumeric) { csr_val2 = new T[nnz]; for(int i = 0; i < nnz; i++) { csr_val2[i] = csr_val[i]; } } A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); assert(csr_ptr == NULL); assert(csr_col == NULL); assert(csr_val == NULL); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); b2.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); b2.Allocate("b2", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver BiCGStab, LocalVector, T> ls; // AMG RugeStuebenAMG, LocalVector, T> p; // Setup AMG p.SetCoarseningStrategy(PMIS); p.SetInterpolationType(ExtPI); p.SetCoarsestLevel(300); p.SetCycle(cycle); p.SetOperator(A); p.SetManualSmoothers(true); p.SetManualSolver(true); p.SetScaling(scaling); p.BuildHierarchy(); // Get number of hierarchy levels int levels = p.GetNumLevels(); // Coarse grid solver BiCGStab, LocalVector, T> cgs; cgs.Verbose(0); // Smoother for each level IterativeLinearSolver, LocalVector, T>** sm = new IterativeLinearSolver, LocalVector, T>*[levels - 1]; Preconditioner, LocalVector, T>** smooth = new Preconditioner, LocalVector, T>*[levels - 1]; for(int i = 0; i < levels - 1; ++i) { FixedPoint, LocalVector, T>* fp = new FixedPoint, LocalVector, T>; sm[i] = fp; if(smoother == "Jacobi") { smooth[i] = new Jacobi, LocalVector, T>; fp->SetRelaxation(0.67); } else if(smoother == "MCGS") { smooth[i] = new MultiColoredGS, LocalVector, T>; fp->SetRelaxation(1.3); } else return false; sm[i]->SetPreconditioner(*(smooth[i])); sm[i]->Verbose(0); } p.SetSmoother(sm); p.SetSolver(cgs); p.SetSmootherPreIter(pre_iter); p.SetSmootherPostIter(post_iter); p.SetOperatorFormat(format); p.InitMaxIter(1); p.Verbose(0); ls.Verbose(0); ls.SetOperator(A); ls.SetPreconditioner(p); ls.Init(1e-8, 0.0, 1e+8, 10000); ls.Build(); if(rebuildnumeric) { A.UpdateValuesCSR(csr_val2); delete[] csr_val2; // b2 = A * 1 A.Apply(e, &b2); ls.ReBuildNumeric(); } // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(rebuildnumeric ? b2 : b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); // TODO // Stop rocALUTION platform stop_rocalution(); for(int i = 0; i < levels - 1; ++i) { delete smooth[i]; delete sm[i]; } delete[] smooth; delete[] sm; return success; } #endif // TESTING_RUGE_STUEBEN_AMG_HPP rocALUTION-rocm-5.7.1/clients/include/testing_saamg.hpp000066400000000000000000000162331445302240700227310ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_SAAMG_HPP #define TESTING_SAAMG_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-2f); } static bool check_residual(double res) { return (res < 1e-5); } template bool testing_saamg(Arguments argus) { int ndim = argus.size; int pre_iter = argus.pre_smooth; int post_iter = argus.post_smooth; std::string smoother = argus.smoother; std::string coarsening_strategy = argus.coarsening_strategy; std::string matrix_type = argus.matrix_type; unsigned int format = argus.format; int cycle = argus.cycle; bool scaling = argus.ordering; bool rebuildnumeric = argus.rebuildnumeric; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector b2; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = 0; if(matrix_type == "Laplacian2D") { nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); } else if(matrix_type == "Laplacian3D") { nrow = gen_3d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); } else { return false; } int nnz = csr_ptr[nrow]; T* csr_val2 = NULL; if(rebuildnumeric) { csr_val2 = new T[nnz]; for(int i = 0; i < nnz; i++) { csr_val2[i] = csr_val[i]; } } A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); assert(csr_ptr == NULL); assert(csr_col == NULL); assert(csr_val == NULL); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); b2.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); b2.Allocate("b2", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver FCG, LocalVector, T> ls; // Start time measurement double tick = rocalution_time(); double tack = rocalution_time(); // AMG SAAMG, LocalVector, T> p; // Setup SAAMG p.SetCoarsestLevel(10); p.SetCycle(cycle); p.SetOperator(A); p.SetManualSmoothers(true); p.SetManualSolver(true); p.SetScaling(scaling); if(coarsening_strategy == "Greedy") { p.SetCoarseningStrategy(CoarseningStrategy::Greedy); } else if(coarsening_strategy == "PMIS") { p.SetCoarseningStrategy(CoarseningStrategy::PMIS); } else { return false; } p.SetCouplingStrength(0.001); p.SetInterpRelax(2.0 / 3.0); p.BuildHierarchy(); // Stop build hierarchy time measurement tack = rocalution_time(); std::cout << "Build Hierarchy took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Start smoother time measurement tick = rocalution_time(); // Get number of hierarchy levels int levels = p.GetNumLevels(); // Coarse grid solver FCG, LocalVector, T> cgs; cgs.Verbose(0); // Smoother for each level IterativeLinearSolver, LocalVector, T>** sm = new IterativeLinearSolver, LocalVector, T>*[levels - 1]; Preconditioner, LocalVector, T>** smooth = new Preconditioner, LocalVector, T>*[levels - 1]; for(int i = 0; i < levels - 1; ++i) { sm[i] = new FixedPoint, LocalVector, T>; if(smoother == "FSAI") smooth[i] = new FSAI, LocalVector, T>; else if(smoother == "SPAI") smooth[i] = new SPAI, LocalVector, T>; else return false; sm[i]->SetPreconditioner(*(smooth[i])); sm[i]->Verbose(0); } p.SetSmoother(sm); p.SetSolver(cgs); p.SetSmootherPreIter(pre_iter); p.SetSmootherPostIter(post_iter); p.SetOperatorFormat(format); p.InitMaxIter(1); p.Verbose(0); ls.Verbose(0); ls.SetOperator(A); ls.SetPreconditioner(p); ls.Init(1e-8, 0.0, 1e+8, 10000); // Stop build smoother time measurement tack = rocalution_time(); std::cout << "Smoother build took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Start build time measurement tick = rocalution_time(); ls.Build(); if(rebuildnumeric) { A.UpdateValuesCSR(csr_val2); delete[] csr_val2; // b2 = A * 1 A.Apply(e, &b2); ls.ReBuildNumeric(); } // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); // Stop building time measurement tack = rocalution_time(); std::cout << "Build took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Start solving time measurement tick = rocalution_time(); ls.Solve(rebuildnumeric ? b2 : b, &x); // Stop solving time measurement tack = rocalution_time(); std::cout << "Solving took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); // TODO // Stop rocALUTION platform stop_rocalution(); for(int i = 0; i < levels - 1; ++i) { delete smooth[i]; delete sm[i]; } delete[] smooth; delete[] sm; if(!success) { std::cout << "nrm2: " << nrm2 << std::endl; } return success; } #endif // TESTING_SAAMG_HPP rocALUTION-rocm-5.7.1/clients/include/testing_uaamg.hpp000066400000000000000000000142341445302240700227320ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_UAAMG_HPP #define TESTING_UAAMG_HPP #include "utility.hpp" #include using namespace rocalution; static bool check_residual(float res) { return (res < 1e-2f); } static bool check_residual(double res) { return (res < 1e-5); } template bool testing_uaamg(Arguments argus) { int ndim = argus.size; int pre_iter = argus.pre_smooth; int post_iter = argus.post_smooth; std::string smoother = argus.smoother; std::string coarsening_strategy = argus.coarsening_strategy; std::string matrix_type = argus.matrix_type; unsigned int format = argus.format; int cycle = argus.cycle; bool scaling = argus.ordering; bool rebuildnumeric = argus.rebuildnumeric; // Initialize rocALUTION platform set_device_rocalution(device); init_rocalution(); // rocALUTION structures LocalMatrix A; LocalVector x; LocalVector b; LocalVector b2; LocalVector e; // Generate A int* csr_ptr = NULL; int* csr_col = NULL; T* csr_val = NULL; int nrow = 0; if(matrix_type == "Laplacian2D") { nrow = gen_2d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); } else if(matrix_type == "Laplacian3D") { nrow = gen_3d_laplacian(ndim, &csr_ptr, &csr_col, &csr_val); } else { return false; } int nnz = csr_ptr[nrow]; T* csr_val2 = NULL; if(rebuildnumeric) { csr_val2 = new T[nnz]; for(int i = 0; i < nnz; i++) { csr_val2[i] = csr_val[i]; } } A.SetDataPtrCSR(&csr_ptr, &csr_col, &csr_val, "A", nnz, nrow, nrow); assert(csr_ptr == NULL); assert(csr_col == NULL); assert(csr_val == NULL); // Move data to accelerator A.MoveToAccelerator(); x.MoveToAccelerator(); b.MoveToAccelerator(); b2.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate x, b and e x.Allocate("x", A.GetN()); b.Allocate("b", A.GetM()); b2.Allocate("b2", A.GetM()); e.Allocate("e", A.GetN()); // b = A * 1 e.Ones(); A.Apply(e, &b); // Random initial guess x.SetRandomUniform(12345ULL, -4.0, 6.0); // Solver FCG, LocalVector, T> ls; // AMG UAAMG, LocalVector, T> p; // Setup SAAMG p.SetCoarsestLevel(200); p.SetCycle(cycle); p.SetOperator(A); p.SetManualSmoothers(true); p.SetManualSolver(true); p.SetScaling(scaling); if(coarsening_strategy == "Greedy") { p.SetCoarseningStrategy(CoarseningStrategy::Greedy); } else if(coarsening_strategy == "PMIS") { p.SetCoarseningStrategy(CoarseningStrategy::PMIS); } else { return false; } p.SetCouplingStrength(0.005); p.SetOverInterp(1.2); p.BuildHierarchy(); // Get number of hierarchy levels int levels = p.GetNumLevels(); // Coarse grid solver FCG, LocalVector, T> cgs; cgs.Verbose(0); // Smoother for each level IterativeLinearSolver, LocalVector, T>** sm = new IterativeLinearSolver, LocalVector, T>*[levels - 1]; Preconditioner, LocalVector, T>** smooth = new Preconditioner, LocalVector, T>*[levels - 1]; for(int i = 0; i < levels - 1; ++i) { sm[i] = new FixedPoint, LocalVector, T>; if(smoother == "FSAI") smooth[i] = new FSAI, LocalVector, T>; else if(smoother == "ILU") smooth[i] = new ILU, LocalVector, T>; else return false; sm[i]->SetPreconditioner(*(smooth[i])); sm[i]->Verbose(0); } p.SetSmoother(sm); p.SetSolver(cgs); p.SetSmootherPreIter(pre_iter); p.SetSmootherPostIter(post_iter); p.SetOperatorFormat(format); p.InitMaxIter(1); p.Verbose(0); ls.Verbose(0); ls.SetOperator(A); ls.SetPreconditioner(p); ls.Init(1e-8, 0.0, 1e+8, 10000); ls.Build(); if(rebuildnumeric) { A.UpdateValuesCSR(csr_val2); delete[] csr_val2; // b2 = A * 1 A.Apply(e, &b2); ls.ReBuildNumeric(); } // Matrix format A.ConvertTo(format, format == BCSR ? 3 : 1); ls.Solve(rebuildnumeric ? b2 : b, &x); // Verify solution x.ScaleAdd(-1.0, e); T nrm2 = x.Norm(); bool success = check_residual(nrm2); // Clean up ls.Clear(); // TODO // Stop rocALUTION platform stop_rocalution(); for(int i = 0; i < levels - 1; ++i) { delete smooth[i]; delete sm[i]; } delete[] smooth; delete[] sm; return success; } #endif // TESTING_UAAMG_HPP rocALUTION-rocm-5.7.1/clients/include/utility.hpp000066400000000000000000000240571445302240700216120ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef TESTING_UTILITY_HPP #define TESTING_UTILITY_HPP #include #include #include "random.hpp" template static constexpr std::size_t countof(T (&)[N]) { return N; } #define rocalution_bench_errmsg std::cerr << "// rocalution_bench_error msg: " extern int device; /* ============================================================================================ */ /*! \brief Generate 2D laplacian on unit square in CSR format */ template int gen_2d_laplacian(int ndim, int** rowptr, int** col, T** val) { if(ndim == 0) { return 0; } int n = ndim * ndim; int nnz_mat = n * 5 - ndim * 4; *rowptr = new int[n + 1]; *col = new int[nnz_mat]; *val = new T[nnz_mat]; int nnz = 0; // Fill local arrays for(int i = 0; i < ndim; ++i) { for(int j = 0; j < ndim; ++j) { int idx = i * ndim + j; (*rowptr)[idx] = nnz; // if no upper boundary element, connect with upper neighbor if(i != 0) { (*col)[nnz] = idx - ndim; (*val)[nnz] = static_cast(-1); ++nnz; } // if no left boundary element, connect with left neighbor if(j != 0) { (*col)[nnz] = idx - 1; (*val)[nnz] = static_cast(-1); ++nnz; } // element itself (*col)[nnz] = idx; (*val)[nnz] = static_cast(4); ++nnz; // if no right boundary element, connect with right neighbor if(j != ndim - 1) { (*col)[nnz] = idx + 1; (*val)[nnz] = static_cast(-1); ++nnz; } // if no lower boundary element, connect with lower neighbor if(i != ndim - 1) { (*col)[nnz] = idx + ndim; (*val)[nnz] = static_cast(-1); ++nnz; } } } (*rowptr)[n] = nnz; return n; } /* ============================================================================================ */ /*! \brief Generate 3D laplacian on unit square in CSR format */ template int gen_3d_laplacian(int ndim, int** row_ptr, int** col_ind, T** val) { // Do nothing if(ndim == 0) { return 0; } int n = ndim * ndim * ndim; // Approximate 27pt stencil int nnz_mat = 27 * n; *row_ptr = new int[n + 1]; *col_ind = new int[nnz_mat]; *val = new T[nnz_mat]; int nnz = 0; (*row_ptr)[0] = 0; // Fill local arrays #ifdef _OPENMP #pragma omp parallel for schedule(dynamic, 1024) #endif for(int32_t iz = 0; iz < ndim; ++iz) { for(int32_t iy = 0; iy < ndim; ++iy) { for(int32_t ix = 0; ix < ndim; ++ix) { int row = iz * ndim * ndim + iy * ndim + ix; for(int32_t sz = -1; sz <= 1; ++sz) { if(iz + sz > -1 && iz + sz < ndim) { for(int32_t sy = -1; sy <= 1; ++sy) { if(iy + sy > -1 && iy + sy < ndim) { for(int32_t sx = -1; sx <= 1; ++sx) { if(ix + sx > -1 && ix + sx < ndim) { int col = row + sz * ndim * ndim + sy * ndim + sx; (*col_ind)[nnz - 0] = col + 0; (*val)[nnz - 0] = (col == row) ? 26.0 : -1.0; ++nnz; } } } } } } (*row_ptr)[row + 1] = nnz; } } } // Adjust nnz by index base nnz -= 0; return n; } /* ============================================================================================ */ /*! \brief Generate full rank identity matrix where the row order has been permuted */ template int gen_permuted_identity(int ndim, int** rowptr, int** col, T** val) { if(ndim == 0) { return 0; } int n = ndim * ndim; int nnz_mat = n; *rowptr = new int[n + 1]; *col = new int[nnz_mat]; *val = new T[nnz_mat]; for(int i = 0; i < n + 1; i++) { (*rowptr)[i] = i; } srand(12345ULL); int r = (int)(static_cast(rand()) / RAND_MAX * (n - 0)); for(int i = 0; i < n; i++) { int index = r + i; if(r + i >= n) { index = r + i - n; } (*col)[i] = index; (*val)[i] = static_cast(1); } return n; } /* ============================================================================================ */ /*! \brief Generate random sparse matrix */ template int gen_random(int m, int n, int max_nnz_per_row, int** rowptr, int** col, T** val) { if(m == 0 || n == 0) { return 0; } int nnz = 0; int* nnz_per_row = new int[m]; for(int i = 0; i < m; i++) { nnz_per_row[i] = random_generator_exact(0, max_nnz_per_row); nnz += nnz_per_row[i]; } *rowptr = new int[m + 1]; *col = new int[nnz]; *val = new T[nnz]; (*rowptr)[0] = 0; for(int i = 1; i < m + 1; i++) { (*rowptr)[i] = (*rowptr)[i - 1] + nnz_per_row[i - 1]; } for(int i = 0; i < m; i++) { int row_start = (*rowptr)[i]; int row_end = (*rowptr)[i + 1]; for(int j = row_start; j < row_end; j++) { (*col)[j] = random_generator(0, n); (*val)[j] = random_generator(); } } auto compare = [](const void* a, const void* b) { int ai = *((int*)a); int bi = *((int*)b); if(ai == bi) { return 0; } else if(ai < bi) { return -1; } else { return 1; } }; qsort(*col, nnz, sizeof(int), compare); delete[] nnz_per_row; return m; } /* ============================================================================================ */ /*! \brief Class used to parse command arguments in both client & gtest */ // has to compile with option "-std=c++11", and this rocsparse library uses c++11 everywhere // c++11 allows intilization of member of a struct class Arguments { public: // MPI variables int rank = 0; int dev_per_node = 1; // OpenMP variables int omp_nthreads = 8; int omp_affinity = true; int omp_threshold = 50000; // Accelerator variables int dev = 0; int use_acc = true; // Structure variables int size = 100; int index = 50; int chunk_size = 20; int blockdim = 4; // Computation variables double alpha = 1.0; double beta = 0.0; double gamma = 0.0; // Solver variables std::string solver = ""; std::string precond = ""; std::string smoother = ""; std::string matrix = ""; std::string coarsening_strategy = ""; std::string matrix_type = ""; int pre_smooth = 2; int post_smooth = 2; int ordering = 1; int cycle = 0; int rebuildnumeric = 0; unsigned int format; Arguments& operator=(const Arguments& rhs) { this->rank = rhs.rank; this->dev_per_node = rhs.dev_per_node; this->omp_nthreads = rhs.omp_nthreads; this->omp_affinity = rhs.omp_affinity; this->omp_threshold = rhs.omp_threshold; this->dev = rhs.dev; this->use_acc = rhs.use_acc; this->size = rhs.size; this->index = rhs.index; this->chunk_size = rhs.chunk_size; this->blockdim = rhs.blockdim; this->alpha = rhs.alpha; this->beta = rhs.beta; this->gamma = rhs.gamma; this->solver = rhs.solver; this->precond = rhs.precond; this->smoother = rhs.smoother; this->matrix = rhs.matrix; this->matrix_type = rhs.matrix_type; this->pre_smooth = rhs.pre_smooth; this->post_smooth = rhs.post_smooth; this->ordering = rhs.ordering; this->cycle = rhs.cycle; this->rebuildnumeric = rhs.rebuildnumeric; this->coarsening_strategy = rhs.coarsening_strategy; this->format = rhs.format; return *this; } }; #endif // TESTING_UTILITY_HPP rocALUTION-rocm-5.7.1/clients/samples/000077500000000000000000000000001445302240700174075ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/clients/samples/CMakeLists.txt000066400000000000000000000071271445302240700221560ustar00rootroot00000000000000# ######################################################################## # Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ######################################################################## # Function to add rocalution examples function(add_rocalution_example EXAMPLE_SOURCE) get_filename_component(EXAMPLE_TARGET ${EXAMPLE_SOURCE} NAME_WE) add_executable(${EXAMPLE_TARGET} ${EXAMPLE_SOURCE} ${ROCALUTION_CLIENTS_COMMON}) # Include common client headers target_include_directories(${EXAMPLE_TARGET} PRIVATE $) # Link rocALUTION library target_link_libraries(${EXAMPLE_TARGET} PRIVATE roc::rocalution) if (BUILD_CODE_COVERAGE) target_link_libraries(${EXAMPLE_TARGET} PRIVATE -lgcov) endif() # Examples output directory if(NOT TARGET rocalution) set_target_properties(${EXAMPLE_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging") else() set_target_properties(${EXAMPLE_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/clients/staging") endif() endfunction() # Examples add_rocalution_example(amg.cpp) add_rocalution_example(sa-amg.cpp) add_rocalution_example(ua-amg.cpp) add_rocalution_example(as-precond.cpp) add_rocalution_example(async.cpp) add_rocalution_example(benchmark.cpp) add_rocalution_example(bicgstab.cpp) add_rocalution_example(block-precond.cpp) add_rocalution_example(cg-amg.cpp) add_rocalution_example(cg-rsamg.cpp) add_rocalution_example(cg-saamg.cpp) add_rocalution_example(cg.cpp) add_rocalution_example(cmk.cpp) add_rocalution_example(complex.cpp) add_rocalution_example(direct.cpp) add_rocalution_example(fcg.cpp) add_rocalution_example(fixed-point.cpp) add_rocalution_example(gmres.cpp) add_rocalution_example(fgmres.cpp) add_rocalution_example(idr.cpp) add_rocalution_example(key.cpp) add_rocalution_example(me-preconditioner.cpp) add_rocalution_example(mixed-precision.cpp) add_rocalution_example(power-method.cpp) add_rocalution_example(simple-spmv.cpp) add_rocalution_example(sp-precond.cpp) add_rocalution_example(stencil.cpp) add_rocalution_example(tns.cpp) add_rocalution_example(var-precond.cpp) # MPI examples if(SUPPORT_MPI) add_rocalution_example(benchmark_mpi.cpp) add_rocalution_example(bicgstab_mpi.cpp) add_rocalution_example(cg-amg_mpi.cpp) add_rocalution_example(cg_mpi.cpp) add_rocalution_example(fcg_mpi.cpp) add_rocalution_example(fgmres_mpi.cpp) add_rocalution_example(global-io_mpi.cpp) add_rocalution_example(idr_mpi.cpp) add_rocalution_example(qmrcgstab_mpi.cpp) endif() rocALUTION-rocm-5.7.1/clients/samples/amg.cpp000066400000000000000000000134441445302240700206650ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Time measurement double tick, tack, start, end; // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Start time measurement tick = rocalution_time(); start = rocalution_time(); // Linear Solver SAAMG, LocalVector, double> ls; // Set solver operator ls.SetOperator(mat); // Set coupling strength ls.SetCouplingStrength(0.001); // Set maximal number of unknowns on coarsest level ls.SetCoarsestLevel(300); // Set relaxation parameter for smoothed interpolation aggregation ls.SetInterpRelax(2. / 3.); // Set manual smoothers ls.SetManualSmoothers(true); // Set manual course grid solver ls.SetManualSolver(true); // Set grid transfer scaling ls.SetScaling(true); // Build AMG hierarchy ls.BuildHierarchy(); // Obtain number of AMG levels int levels = ls.GetNumLevels(); // Coarse Grid Solver CG, LocalVector, double> cgs; cgs.Verbose(0); // Smoother for each level IterativeLinearSolver, LocalVector, double>** sm = new IterativeLinearSolver, LocalVector, double>*[levels - 1]; MultiColoredGS, LocalVector, double>** gs = new MultiColoredGS, LocalVector, double>*[levels - 1]; // Coarse grid solver with preconditioner // MultiColoredILU, LocalVector, double > p; // cgs->SetPreconditioner(p); // Initialize smoother for each level for(int i = 0; i < levels - 1; ++i) { // Smooth with MultiColoredGS using Fixed-Point iteration scheme FixedPoint, LocalVector, double>* fp; fp = new FixedPoint, LocalVector, double>; fp->SetRelaxation(1.3); sm[i] = fp; gs[i] = new MultiColoredGS, LocalVector, double>; sm[i]->SetPreconditioner(*gs[i]); sm[i]->Verbose(0); } // Pass smoother and coarse grid solver to AMG ls.SetSmoother(sm); ls.SetSolver(cgs); // Set number of pre and post smoothing steps ls.SetSmootherPreIter(1); ls.SetSmootherPostIter(2); // Initialize solver tolerances ls.Init(1e-10, 1e-8, 1e+8, 10000); // Verbosity output ls.Verbose(2); // Build solver ls.Build(); // Move solver to the accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); ls.MoveToAccelerator(); // Print matrix info mat.Info(); // Stop building time measurement tack = rocalution_time(); std::cout << "Building took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Start solving time measurement tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop solving time measurement tack = rocalution_time(); std::cout << "Solving took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Clear the solver ls.Clear(); // Free all allocated data for(int i = 0; i < levels - 1; ++i) { delete gs[i]; delete sm[i]; } delete[] gs; delete[] sm; // End time measurement end = rocalution_time(); std::cout << "Total runtime: " << (end - start) / 1e6 << " sec" << std::endl; // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/as-precond.cpp000066400000000000000000000101621445302240700221460ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Linear Solver GMRES, LocalVector, double> ls; // Preconditioner AS, LocalVector, double> p; // Additive Schwarz // RAS, LocalVector, double > p; // Restricted Additive Schwarz // Second level preconditioners Solver, LocalVector, double>** p2; int n = 2; p2 = new Solver, LocalVector, double>*[n]; for(int i = 0; i < n; ++i) { MultiColoredILU, LocalVector, double>* mc; mc = new MultiColoredILU, LocalVector, double>; p2[i] = mc; } double tick, tack; // Initialize preconditioner p.Set(n, 4, p2); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Verbosity output // ls.Verbose(2); // Build solver ls.Build(); // Move solver to the accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); ls.MoveToAccelerator(); // Print matrix info mat.Info(); // Start solving time measurement tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop solving time measurement tack = rocalution_time(); std::cout << "Solver took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Clear the solver ls.Clear(); // Free all allocated data for(int i = 0; i < n; ++i) { delete p2[i]; p2[i] = NULL; } delete[] p2; p2 = NULL; // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/async.cpp000066400000000000000000000120551445302240700212330ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector y; LocalMatrix mat; double tick, tack; double tickg, tackg; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Allocate vectors x.Allocate("x", mat.GetN()); y.Allocate("y", mat.GetM()); // Initialize x with 1 x.Ones(); // No Async tickg = rocalution_time(); // Initialize y with 0 y.Zeros(); // Print object info mat.Info(); x.Info(); y.Info(); // CPU tick = rocalution_time(); // y += mat * x for(int i = 0; i < 100; ++i) { mat.ApplyAdd(x, 1.0, &y); } tack = rocalution_time(); std::cout << "CPU execution took: " << (tack - tick) / 1e6 << " sec" << std::endl; std::cout << "Dot product = " << x.Dot(y) << std::endl; tick = rocalution_time(); // Memory transfer mat.MoveToAccelerator(); x.MoveToAccelerator(); y.MoveToAccelerator(); // Print object info mat.Info(); x.Info(); y.Info(); tack = rocalution_time(); std::cout << "Sync transfer took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Initialize y with 0 y.Zeros(); // Accelerator tick = rocalution_time(); // y += mat * x for(int i = 0; i < 100; ++i) { mat.ApplyAdd(x, 1.0, &y); } tack = rocalution_time(); std::cout << "Accelerator execution took: " << (tack - tick) / 1e6 << " sec" << std::endl; std::cout << "Dot product = " << x.Dot(y) << std::endl; tackg = rocalution_time(); std::cout << "Total execution + transfers (no async) took: " << (tackg - tickg) / 1e6 << " sec" << std::endl; // Move data to host mat.MoveToHost(); x.MoveToHost(); y.MoveToHost(); // Initialize y with 0 y.Zeros(); // Async tickg = rocalution_time(); tick = rocalution_time(); // Memory transfer mat.MoveToAcceleratorAsync(); x.MoveToAcceleratorAsync(); // Print oject info mat.Info(); x.Info(); y.Info(); tack = rocalution_time(); std::cout << "Async transfer took: " << (tack - tick) / 1e6 << " sec" << std::endl; // CPU tick = rocalution_time(); // y += mat * x for(int i = 0; i < 100; ++i) { mat.ApplyAdd(x, 1.0, &y); } tack = rocalution_time(); std::cout << "CPU execution took: " << (tack - tick) / 1e6 << " sec" << std::endl; std::cout << "Dot product = " << x.Dot(y) << std::endl; // Synchronize objects mat.Sync(); x.Sync(); // Move y to host y.MoveToAccelerator(); // Print object info mat.Info(); x.Info(); y.Info(); // Initialize y with 0 y.Zeros(); // Accelerator tick = rocalution_time(); // y += mat * x for(int i = 0; i < 100; ++i) { mat.ApplyAdd(x, 1.0, &y); } tack = rocalution_time(); std::cout << "Accelerator execution took: " << (tack - tick) / 1e6 << " sec" << std::endl; std::cout << "Dot product = " << x.Dot(y) << std::endl; tackg = rocalution_time(); std::cout << "Total execution + transfers (async) took: " << (tackg - tickg) / 1e6 << " sec" << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/benchmark.cpp000066400000000000000000000370151445302240700220530ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector vec1; LocalVector vec2; LocalVector vec3; LocalMatrix mat; // Time measurement double tick, tack; // Number of tests const int max_tests = 200; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Allocate vectors vec1.Allocate("x", mat.GetN()); vec2.Allocate("y", mat.GetM()); vec3.Allocate("z", mat.GetM()); int size = mat.GetM(); int nnz = mat.GetNnz(); // Initialize objects vec1.Ones(); vec2.Zeros(); vec3.Ones(); mat.Apply(vec1, &vec2); // Move objects to accelerator mat.MoveToAccelerator(); vec1.MoveToAccelerator(); vec2.MoveToAccelerator(); vec3.MoveToAccelerator(); // Print object info mat.Info(); vec1.Info(); vec2.Info(); vec3.Info(); std::cout << "----------------------------------------------------" << std::endl; std::cout << "Number of tests = " << max_tests << std::endl; std::cout << "----------------------------------------------------" << std::endl; std::cout << "Stand alone micro benchmarks" << std::endl; // Dot product // Size = 2*size // Flop = 2 per element vec3.Dot(vec2); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { vec3.Dot(vec2); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "Dot execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double(sizeof(double) * (size + size)) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * size)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; // Reduce // Size = size // Flop = 1 per element vec3.Reduce(); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { vec3.Reduce(); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "Reduce execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double(sizeof(double) * (size)) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((size - 1)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; // Norm // Size = size // Flop = 2 per element vec3.Norm(); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { vec3.Norm(); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "Norm execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double(sizeof(double) * (size)) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * size)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; // Vector Update 1 // Size = 3xsize // Flop = 2 per element vec3.ScaleAdd(double(5.5), vec2); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { vec3.ScaleAdd(double(5.5), vec2); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "Vector update (scaleadd) execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double(sizeof(double) * (size + size + size)) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * size)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; // Vector Update 2 // Size = 3*size // Flop = 2 per element vec3.AddScale(vec2, double(5.5)); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { vec3.AddScale(vec2, double(5.5)); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "Vector update (addscale) execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double(sizeof(double) * (size + size + size)) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * size)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; mat.ConvertToCSR(); nnz = mat.GetNnz(); mat.Info(); // Matrix-Vector Multiplication // Size = int(size+nnz) [row_offset + col] + valuetype(2*size+nnz) [in + out + nnz] // Flop = 2 per entry (nnz) mat.Apply(vec1, &vec2); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { mat.Apply(vec1, &vec2); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "CSR SpMV execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double((sizeof(double) * (size + size + nnz) + sizeof(int) * (size + nnz))) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * nnz)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; mat.ConvertToMCSR(); nnz = mat.GetNnz(); mat.Info(); // Matrix-Vector Multiplication // Size = int(size+(nnz-size)) [row_offset + col] + valuetype(2*size+nnz) [in + out + nnz] // Flop = 2 per entry (nnz) mat.Apply(vec1, &vec2); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { mat.Apply(vec1, &vec2); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "MCSR SpMV execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double( (sizeof(double) * (size + size + nnz - size) + sizeof(int) * (size + nnz))) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * nnz)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; mat.ConvertToELL(); nnz = mat.GetNnz(); mat.Info(); // Matrix-Vector Multiplication // Size = int(nnz) [col] + valuetype(2*size+nnz) [in + out + nnz] // Flop = 2 per entry (nnz) mat.Apply(vec1, &vec2); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { mat.Apply(vec1, &vec2); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "ELL SpMV execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double((sizeof(double) * (size + size + nnz) + sizeof(int) * (nnz))) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * nnz)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; mat.ConvertToCOO(); nnz = mat.GetNnz(); mat.Info(); // Matrix-Vector Multiplication // Size = int(2*nnz) + valuetype(2*size+nnz) // Flop = 2 per entry (nnz) mat.Apply(vec1, &vec2); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { mat.Apply(vec1, &vec2); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "COO SpMV execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double((sizeof(double) * (size + size + nnz) + sizeof(int) * (2 * nnz))) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * nnz)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; mat.ConvertToHYB(); nnz = mat.GetNnz(); mat.Info(); // Matrix-Vector Multiplication // Size = int(nnz) [col] + valuetype(2*size+nnz) [in + out + nnz] // Flop = 2 per entry (nnz) mat.Apply(vec1, &vec2); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { mat.Apply(vec1, &vec2); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "HYB SpMV execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " // like O(ELL) << max_tests * double((sizeof(double) * (size + size + nnz) + sizeof(int) * (nnz))) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * nnz)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; mat.ConvertToDIA(); nnz = mat.GetNnz(); mat.Info(); // Matrix-Vector Multiplication // Size = int(size+nnz) + valuetype(2*size+nnz) // Flop = 2 per entry (nnz) mat.Apply(vec1, &vec2); _rocalution_sync(); tick = rocalution_time(); for(int i = 0; i < max_tests; ++i) { mat.Apply(vec1, &vec2); _rocalution_sync(); } _rocalution_sync(); tack = rocalution_time(); std::cout << "DIA SpMV execution: " << (tack - tick) / max_tests / 1e3 << " msec" << "; " // assuming ndiag << size << max_tests * double((sizeof(double) * (nnz))) / (tack - tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * nnz)) / (tack - tick) / 1e3 << " GFlop/sec" << std::endl; mat.ConvertToCSR(); std::cout << "----------------------------------------------------" << std::endl; std::cout << "Combined micro benchmarks" << std::endl; double dot_tick = 0, dot_tack = 0; double norm_tick = 0, norm_tack = 0; double updatev1_tick = 0, updatev1_tack = 0; double updatev2_tick = 0, updatev2_tack = 0; double spmv_tick = 0, spmv_tack = 0; for(int i = 0; i < max_tests; ++i) { vec1.Ones(); vec2.Zeros(); vec3.Ones(); mat.Apply(vec1, &vec2); // Dot product // Size = 2*size // Flop = 2 per element vec3.Dot(vec2); _rocalution_sync(); dot_tick += rocalution_time(); vec3.Dot(vec2); _rocalution_sync(); dot_tack += rocalution_time(); vec1.Ones(); vec2.Zeros(); vec3.Ones(); mat.Apply(vec1, &vec2); // Norm // Size = size // Flop = 2 per element vec3.Norm(); _rocalution_sync(); norm_tick += rocalution_time(); vec3.Norm(); _rocalution_sync(); norm_tack += rocalution_time(); vec1.Ones(); vec2.Zeros(); vec3.Ones(); mat.Apply(vec1, &vec2); // Vector Update 1 // Size = 3xsize // Flop = 2 per element vec3.ScaleAdd(double(5.5), vec2); _rocalution_sync(); updatev1_tick += rocalution_time(); vec3.ScaleAdd(double(5.5), vec2); _rocalution_sync(); updatev1_tack += rocalution_time(); vec1.Ones(); vec2.Zeros(); vec3.Ones(); mat.Apply(vec1, &vec2); // Vector Update 2 // Size = 3*size // Flop = 2 per element vec3.AddScale(vec2, double(5.5)); _rocalution_sync(); updatev2_tick += rocalution_time(); vec3.AddScale(vec2, double(5.5)); _rocalution_sync(); updatev2_tack += rocalution_time(); vec1.Ones(); vec2.Zeros(); vec3.Ones(); mat.Apply(vec1, &vec2); // Matrix-Vector Multiplication // Size = int(size+nnz) + valuetype(2*size+nnz) // Flop = 2 per entry (nnz) mat.Apply(vec1, &vec2); _rocalution_sync(); spmv_tick += rocalution_time(); mat.Apply(vec1, &vec2); _rocalution_sync(); spmv_tack += rocalution_time(); } std::cout << "Dot execution: " << (dot_tack - dot_tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double(sizeof(double) * (size + size)) / (dot_tack - dot_tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * size)) / (dot_tack - dot_tick) / 1e3 << " GFlop/sec" << std::endl; std::cout << "Norm execution: " << (norm_tack - norm_tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double(sizeof(double) * (size)) / (norm_tack - norm_tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * size)) / (norm_tack - norm_tick) / 1e3 << " GFlop/sec" << std::endl; std::cout << "Vector update (scaleadd) execution: " << (updatev1_tack - updatev1_tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double(sizeof(double) * (size + size + size)) / (updatev1_tack - updatev1_tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * size)) / (updatev1_tack - updatev1_tick) / 1e3 << " GFlop/sec" << std::endl; std::cout << "Vector update (addscale) execution: " << (updatev2_tack - updatev2_tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double(sizeof(double) * (size + size + size)) / (updatev2_tack - updatev2_tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * size)) / (updatev2_tack - updatev2_tick) / 1e3 << " GFlop/sec" << std::endl; std::cout << "SpMV execution: " << (spmv_tack - spmv_tick) / max_tests / 1e3 << " msec" << "; " << max_tests * double((sizeof(double) * (size + size + nnz) + sizeof(int) * (size + nnz))) / (spmv_tack - spmv_tick) / 1e3 << " Gbyte/sec; " << max_tests * double((2 * nnz) / (spmv_tack - spmv_tick)) / 1e3 << " GFlop/sec" << std::endl; stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/benchmark_mpi.cpp000066400000000000000000000434571445302240700227270ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "common.hpp" #include #include #include #define ValueType double using namespace rocalution; int main(int argc, char* argv[]) { // Initialize MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank; int num_procs; MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &num_procs); // Check command line parameters if(num_procs < 2) { std::cerr << "Expecting at least 2 MPI processes" << std::endl; return -1; } if(argc < 2) { std::cerr << argv[0] << " " << std::endl; return -1; } // Disable OpenMP thread affinity set_omp_affinity_rocalution(false); // Initialize platform with rank and # of accelerator devices in the node init_rocalution(rank, 2); // Disable OpenMP set_omp_threads_rocalution(1); // Print platform info_rocalution(); // Load undistributed matrix LocalMatrix lmat; lmat.ReadFileMTX(argv[1]); // Global structures ParallelManager manager; GlobalMatrix mat; // Distribute matrix - lmat will be destroyed distribute_matrix(&comm, &lmat, &mat, &manager); // rocALUTION vectors GlobalVector v1(manager); GlobalVector v2(manager); // Move structures to accelerator, if available mat.MoveToAccelerator(); v1.MoveToAccelerator(); v2.MoveToAccelerator(); // Allocate memory v1.Allocate("v1", mat.GetN()); v2.Allocate("v2", mat.GetM()); size_t size = mat.GetM(); size_t nnz; // Initialize objects v1.Ones(); v2.Zeros(); mat.Apply(v1, &v2); // Print object info mat.Info(); v1.Info(); v2.Info(); // Number of tests int tests = 200; double time; if(rank == 0) { std::cout << "--------------------------------------- BENCHMARKS " "--------------------------------------" << std::endl; } // Dot product // Size = 2*size // Flop = 2 per element v1.Dot(v2); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { v1.Dot(v2); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "Dot execution: " << time / 1e3 / tests << " msec" << "; " << tests * double(sizeof(ValueType) * (2 * size)) / time / 1e3 << " GByte/sec; " << tests * double(2 * size) / time / 1e3 << " GFlop/sec" << std::endl; } // L2 Norm // Size = size // Flop = 2 per element v1.Norm(); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { v1.Norm(); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "Norm2 execution: " << time / 1e3 / tests << " msec" << "; " << tests * double(sizeof(ValueType) * (size)) / time / 1e3 << " GByte/sec; " << tests * double(2 * size) / time / 1e3 << " GFlop/sec" << std::endl; } // Reduction // Size = size // Flop = 1 per element v1.Reduce(); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { v1.Reduce(); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "Reduce execution: " << time / 1e3 / tests << " msec" << "; " << tests * double(sizeof(ValueType) * (size)) / time / 1e3 << " GByte/sec; " << tests * double(size) / time / 1e3 << " GFlop/sec" << std::endl; } if(rank == 0) { std::cout << "----------------------------------------------------" "-------------------------------------" << std::endl; } // Vector Update 1 // Size = 3*size // Flop = 2 per element v1.ScaleAdd((ValueType)3.1, v2); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { v1.ScaleAdd((ValueType)3.1, v2); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "Vector update (ScaleAdd) execution: " << time / 1e3 / tests << " msec" << "; " << tests * double(sizeof(ValueType) * (3 * size)) / time / 1e3 << " GByte/sec; " << tests * double(2 * size) / time / 1e3 << " GFlop/sec" << std::endl; } // Vector Update 2 // Size = 3*size // Flop = 2 per element v1.AddScale(v2, (ValueType)3.1); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { v1.AddScale(v2, (ValueType)3.1); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "Vector update (AddScale) execution: " << time / 1e3 / tests << " msec" << "; " << tests * double(sizeof(ValueType) * (3 * size)) / time / 1e3 << " GByte/sec; " << tests * double(2 * size) / time / 1e3 << " GFlop/sec" << std::endl; } if(rank == 0) { std::cout << "----------------------------------------------------" "-------------------------------------" << std::endl; } // Matrix vector multiplication CSR // Size = int(size+1+nnz) [row_offset + col] + ValueType(2*size+nnz) [in + out + nnz] // Flop = 2 per entry (nnz) mat.ConvertToCSR(); nnz = mat.GetNnz(); mat.Info(); mat.Apply(v1, &v2); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { mat.Apply(v1, &v2); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "CSR SpMV execution: " << time / 1e3 / tests << " msec" << "; " << tests * double((sizeof(ValueType) * (2 * size + nnz) + sizeof(int) * (size + 1 + nnz))) / time / 1e3 << " GByte/sec; " << tests * double(2 * nnz) / time / 1e3 << " GFlop/sec" << std::endl; } if(rank == 0) { std::cout << "----------------------------------------------------" "-------------------------------------" << std::endl; } // Matrix vector multiplication MCSR // Size = int(size+(nnz-size)) [row_offset + col] + valuetype(2*size+nnz) [in + out + nnz] // Flop = 2 per entry (nnz) mat.ConvertToMCSR(); nnz = mat.GetNnz(); mat.Info(); mat.Apply(v1, &v2); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { mat.Apply(v1, &v2); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "MCSR SpMV execution: " << time / 1e3 / tests << " msec" << "; " << tests * double((sizeof(ValueType) * (2 * size + nnz - size) + sizeof(int) * (size + 1 + nnz))) / time / 1e3 << " GByte/sec; " << tests * double(2 * nnz) / time / 1e3 << " GFlop/sec" << std::endl; } if(rank == 0) { std::cout << "----------------------------------------------------" "-------------------------------------" << std::endl; } // Matrix vector multiplication ELL // Size = int(nnz) [col] + ValueType(2*size+nnz) [in + out + nnz] // Flop = 2 per entry (nnz) mat.ConvertToELL(); nnz = mat.GetNnz(); mat.Info(); mat.Apply(v1, &v2); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { mat.Apply(v1, &v2); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "ELL SpMV execution: " << time / 1e3 / tests << " msec" << "; " << tests * double((sizeof(ValueType) * (2 * size + nnz) + sizeof(int) * (nnz))) / time / 1e3 << " GByte/sec; " << tests * double(2 * nnz) / time / 1e3 << " GFlop/sec" << std::endl; } if(rank == 0) { std::cout << "----------------------------------------------------" "-------------------------------------" << std::endl; } // Matrix vector multiplication COO // Size = int(2*nnz) [col+row] + ValueType(2*size+nnz) [in + out + nnz] // Flop = 2 per entry (nnz) mat.ConvertToCOO(); nnz = mat.GetNnz(); mat.Info(); mat.Apply(v1, &v2); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { mat.Apply(v1, &v2); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "COO SpMV execution: " << time / 1e3 / tests << " msec" << "; " << tests * double((sizeof(ValueType) * (2 * size + nnz) + sizeof(int) * (2 * nnz))) / time / 1e3 << " GByte/sec; " << tests * double(2 * nnz) / time / 1e3 << " GFlop/sec" << std::endl; } if(rank == 0) { std::cout << "----------------------------------------------------" "-------------------------------------" << std::endl; } // Matrix vector multiplication HYB // Size = int(nnz) [col] + valuetype(2*size+nnz) [in + out + nnz] // Flop = 2 per entry (nnz) mat.ConvertToHYB(); nnz = mat.GetNnz(); mat.Info(); mat.Apply(v1, &v2); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { mat.Apply(v1, &v2); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "HYB SpMV execution: " << time / 1e3 / tests << " msec" << "; " << tests * double((sizeof(ValueType) * (2 * size + nnz) + sizeof(int) * (nnz))) / time / 1e3 << " GByte/sec; " << tests * double(2 * nnz) / time / 1e3 << " GFlop/sec" << std::endl; } if(rank == 0) { std::cout << "----------------------------------------------------" "-------------------------------------" << std::endl; } // Matrix vector multiplication DIA // Size = int(size+nnz) + valuetype(2*size+nnz) // Flop = 2 per entry (nnz) mat.ConvertToDIA(); nnz = mat.GetNnz(); mat.Info(); mat.Apply(v1, &v2); _rocalution_sync(); time = rocalution_time(); for(int i = 0; i < tests; ++i) { mat.Apply(v1, &v2); _rocalution_sync(); } _rocalution_sync(); time = rocalution_time() - time; if(rank == 0) { std::cout << "DIA SpMV execution: " << time / 1e3 / tests << " msec" << "; " << tests * double((sizeof(ValueType) * (nnz))) / time / 1e3 << " GByte/sec; " << tests * double(2 * nnz) / time / 1e3 << " GFlop/sec" << std::endl; } if(rank == 0) { std::cout << "----------------------------------------------------" "-------------------------------------" << std::endl; } mat.ConvertToCSR(); if(rank == 0) { std::cout << "----------------------------------------------------" << std::endl; std::cout << "Combined micro benchmarks" << std::endl; } double dot_tick = 0, dot_tack = 0; double norm_tick = 0, norm_tack = 0; double red_tick = 0, red_tack = 0; double updatev1_tick = 0, updatev1_tack = 0; double updatev2_tick = 0, updatev2_tack = 0; double spmv_tick = 0, spmv_tack = 0; for(int i = 0; i < tests; ++i) { v1.Ones(); v2.Zeros(); mat.Apply(v1, &v2); // Dot product // Size = 2*size // Flop = 2 per element v1.Dot(v2); dot_tick += rocalution_time(); v1.Dot(v2); dot_tack += rocalution_time(); v1.Ones(); v2.Zeros(); mat.Apply(v1, &v2); // Norm // Size = size // Flop = 2 per element v1.Norm(); norm_tick += rocalution_time(); v1.Norm(); norm_tack += rocalution_time(); v1.Ones(); v2.Zeros(); mat.Apply(v1, &v2); // Reduce // Size = size // Flop = 1 per element v1.Reduce(); red_tick += rocalution_time(); v1.Reduce(); red_tack += rocalution_time(); v1.Ones(); v2.Zeros(); mat.Apply(v1, &v2); // Vector Update 1 // Size = 3xsize // Flop = 2 per element v1.ScaleAdd(double(5.5), v2); updatev1_tick += rocalution_time(); v1.ScaleAdd(double(5.5), v2); updatev1_tack += rocalution_time(); v1.Ones(); v2.Zeros(); mat.Apply(v1, &v2); // Vector Update 2 // Size = 3*size // Flop = 2 per element v1.AddScale(v2, double(5.5)); updatev2_tick += rocalution_time(); v1.AddScale(v2, double(5.5)); updatev2_tack += rocalution_time(); v1.Ones(); v2.Zeros(); mat.Apply(v1, &v2); // Matrix-Vector Multiplication // Size = int(size+nnz) + valuetype(2*size+nnz) // Flop = 2 per entry (nnz) mat.Apply(v1, &v2); spmv_tick += rocalution_time(); mat.Apply(v1, &v2); spmv_tack += rocalution_time(); } if(rank == 0) { std::cout << "Dot execution: " << (dot_tack - dot_tick) / tests / 1e3 << " msec" << "; " << tests * double(sizeof(double) * (size + size)) / (dot_tack - dot_tick) / 1e3 << " Gbyte/sec; " << tests * double(2 * size) / (dot_tack - dot_tick) / 1e3 << " GFlop/sec" << std::endl; std::cout << "Norm execution: " << (norm_tack - norm_tick) / tests / 1e3 << " msec" << "; " << tests * double(sizeof(double) * (size)) / (norm_tack - norm_tick) / 1e3 << " Gbyte/sec; " << tests * double(2 * size) / (norm_tack - norm_tick) / 1e3 << " GFlop/sec" << std::endl; std::cout << "Reduce execution: " << (red_tack - red_tick) / tests / 1e3 << " msec" << "; " << tests * double(sizeof(double) * (size)) / (red_tack - red_tick) / 1e3 << " Gbyte/sec; " << tests * double(size) / (red_tack - red_tick) / 1e3 << " GFlop/sec" << std::endl; std::cout << "Vector update (scaleadd) execution: " << (updatev1_tack - updatev1_tick) / tests / 1e3 << " msec" << "; " << tests * double(sizeof(double) * (size + size + size)) / (updatev1_tack - updatev1_tick) / 1e3 << " Gbyte/sec; " << tests * double(2 * size) / (updatev1_tack - updatev1_tick) / 1e3 << " GFlop/sec" << std::endl; std::cout << "Vector update (addscale) execution: " << (updatev2_tack - updatev2_tick) / tests / 1e3 << " msec" << "; " << tests * double(sizeof(double) * (size + size + size)) / (updatev2_tack - updatev2_tick) / 1e3 << " Gbyte/sec; " << tests * double(2 * size) / (updatev2_tack - updatev2_tick) / 1e3 << " GFlop/sec" << std::endl; std::cout << "SpMV execution: " << (spmv_tack - spmv_tick) / tests / 1e3 << " msec" << "; " << tests * double( (sizeof(double) * (size + size + nnz) + sizeof(int) * (size + nnz))) / (spmv_tack - spmv_tick) / 1e3 << " Gbyte/sec; " << tests * double((2 * nnz) / (spmv_tack - spmv_tick)) / 1e3 << " GFlop/sec" << std::endl; } stop_rocalution(); MPI_Finalize(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/bicgstab.cpp000066400000000000000000000065351445302240700217020ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver BiCGStab, LocalVector, double> ls; // Preconditioner MultiColoredGS, LocalVector, double> p; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Build solver ls.Build(); // Verbosity output ls.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/bicgstab_mpi.cpp000066400000000000000000000103151445302240700225360ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "common.hpp" #include #include #include #define ValueType double using namespace rocalution; int main(int argc, char* argv[]) { // Initialize MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank; int num_procs; MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &num_procs); // Check command line parameters if(num_procs < 2) { std::cerr << "Expecting at least 2 MPI processes" << std::endl; return -1; } if(argc < 2) { std::cerr << argv[0] << " " << std::endl; return -1; } // Disable OpenMP thread affinity set_omp_affinity_rocalution(false); // Initialize platform with rank and # of accelerator devices in the node init_rocalution(rank, 2); // Disable OpenMP set_omp_threads_rocalution(1); // Print platform info_rocalution(); // Load undistributed matrix LocalMatrix lmat; lmat.ReadFileMTX(argv[1]); // Global structures ParallelManager manager; GlobalMatrix mat; // Distribute matrix - lmat will be destroyed distribute_matrix(&comm, &lmat, &mat, &manager); // rocALUTION vectors GlobalVector rhs(manager); GlobalVector x(manager); GlobalVector e(manager); // Move structures to accelerator, if available mat.MoveToAccelerator(); rhs.MoveToAccelerator(); x.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate memory rhs.Allocate("rhs", mat.GetM()); x.Allocate("x", mat.GetN()); e.Allocate("sol", mat.GetN()); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Linear solver BiCGStab, GlobalVector, double> ls; // Block jacobi global preconditioner BlockJacobi, GlobalVector, double> bj; // Local preconditioner MultiColoredGS, LocalVector, double> p; // Set local preconditioner bj.Set(p); // Set solver preconditioner ls.SetPreconditioner(bj); // Set solver operator ls.SetOperator(mat); // Build solver ls.Build(); // Verbosity output ls.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double time = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement time = rocalution_time() - time; if(rank == 0) { std::cout << "Solving: " << time / 1e6 << " sec" << std::endl; } // Compute error L2 norm e.ScaleAdd(-1.0, x); double nrm2 = e.Norm(); if(rank == 0) { std::cout << "||e - x||_2 = " << nrm2 << std::endl; } // Clear solver ls.Clear(); // Stop rocALUTION platform stop_rocalution(); MPI_Finalize(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/block-precond.cpp000066400000000000000000000105411445302240700226360ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator // mat.MoveToAccelerator(); // x.MoveToAccelerator(); // rhs.MoveToAccelerator(); // e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver GMRES, LocalVector, double> ls; // Preconditioner BlockPreconditioner, LocalVector, double> p; Solver, LocalVector, double>** p2; // Setup blocks int n = 2; int* size; size = new int[n]; p2 = new Solver, LocalVector, double>*[n]; for(int i = 0; i < n; ++i) { size[i] = mat.GetM() / n; MultiColoredILU, LocalVector, double>* mc; mc = new MultiColoredILU, LocalVector, double>; p2[i] = mc; // AMG, LocalVector, double > *amg; // amg = new AMG, LocalVector, double >; // amg->InitMaxIter(2); // amg->Verbose(0); // p2[i] = amg; } double tick, tack; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set blocks and diagonal solver p.Set(n, size, p2); p.SetDiagonalSolver(); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Verbosity output // ls.Verbose(2); // Build solver ls.Build(); // Print matrix info mat.Info(); // Start time measurement tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Clear all allocated data for(int i = 0; i < n; ++i) { delete p2[i]; p2[i] = NULL; } delete[] size; delete[] p2; p2 = NULL; // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/cg-amg.cpp000066400000000000000000000073561445302240700212610ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Start time measurement double tick = rocalution_time(); // Linear Solver CG, LocalVector, double> ls; // AMG Preconditioner SAAMG, LocalVector, double> p; // Disable verbosity output of AMG preconditioner p.Verbose(0); // Set solver preconditioner ls.SetPreconditioner(p); // Set solver operator ls.SetOperator(mat); // Build solver ls.Build(); // Compute 2 coarsest levels on the host p.SetHostLevels(2); // Stop time measurement double tack = rocalution_time(); std::cout << "Building took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Print matrix info mat.Info(); // Initialize solver tolerances ls.Init(1e-8, 1e-8, 1e+8, 10000); // Set verbosity output ls.Verbose(1); // Start time measurement tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/cg-amg_mpi.cpp000066400000000000000000000100501445302240700221070ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "common.hpp" #include #include #include #define ValueType double using namespace rocalution; int main(int argc, char* argv[]) { // Initialize MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank; int num_procs; MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &num_procs); if(argc < 2) { std::cerr << argv[0] << " " << std::endl; return -1; } // Disable OpenMP thread affinity set_omp_affinity_rocalution(false); // Initialize platform with rank and # of accelerator devices in the node init_rocalution(rank, 2); // Disable OpenMP set_omp_threads_rocalution(1); // Print platform info_rocalution(); // Load undistributed matrix LocalMatrix lmat; lmat.ReadFileMTX(argv[1]); // Global structures ParallelManager manager; GlobalMatrix mat; // Distribute matrix - lmat will be destroyed distribute_matrix(&comm, &lmat, &mat, &manager); // rocALUTION vectors GlobalVector rhs(manager); GlobalVector x(manager); GlobalVector e(manager); // Allocate memory rhs.Allocate("rhs", mat.GetM()); x.Allocate("x", mat.GetN()); e.Allocate("sol", mat.GetN()); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Linear solver CG, GlobalVector, double> ls; // Preconditioner PairwiseAMG, GlobalVector, double> p; // Disable AMG preconditioner verbosity output p.Verbose(0); // Set solver preconditioner ls.SetPreconditioner(p); // Set solver operator ls.SetOperator(mat); // Build solver ls.Build(); // Move structures to accelerator, if available mat.MoveToAccelerator(); rhs.MoveToAccelerator(); x.MoveToAccelerator(); e.MoveToAccelerator(); ls.MoveToAccelerator(); // Set verbosity output ls.Verbose(2); // Set host levels (requires solver built) p.SetHostLevels(2); // Print matrix info mat.Info(); // Start time measurement double time = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement time = rocalution_time() - time; if(rank == 0) { std::cout << "Solving: " << time / 1e6 << " sec" << std::endl; } // Compute error L2 norm e.ScaleAdd(-1.0, x); double nrm2 = e.Norm(); if(rank == 0) { std::cout << "||e - x||_2 = " << nrm2 << std::endl; } // Clear solver ls.Clear(); // Stop rocALUTION platform stop_rocalution(); MPI_Finalize(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/cg-rsamg.cpp000066400000000000000000000077211445302240700216220ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Linear Solver CG, LocalVector, double> ls; // AMG Preconditioner RugeStuebenAMG, LocalVector, double> p; // Disable verbosity output of AMG preconditioner p.Verbose(0); p.SetCoarseningStrategy(CoarseningStrategy::PMIS); p.SetInterpolationType(InterpolationType::ExtPI); // Limit operator complexity p.SetInterpolationTruncation(0.0f); p.SetInterpolationFF1Limit(false); // Set solver preconditioner ls.SetPreconditioner(p); // Set solver operator ls.SetOperator(mat); // Start time measurement double tick = rocalution_time(); // Build solver ls.Build(); // Compute 2 coarsest levels on the host p.SetHostLevels(2); // Stop time measurement double tack = rocalution_time(); std::cout << "Building took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Print matrix info mat.Info(); // Initialize solver tolerances ls.Init(1e-8, 1e-8, 1e+8, 10000); // Set verbosity output ls.Verbose(1); // Start time measurement tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/cg-saamg.cpp000066400000000000000000000101761445302240700215770ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Start time measurement double tick, tack, start, end; start = rocalution_time(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Start time measurement tick = rocalution_time(); // Linear Solver CG, LocalVector, double> ls; // AMG Preconditioner SAAMG, LocalVector, double> p; p.SetCoarseningStrategy(CoarseningStrategy::PMIS); p.SetLumpingStrategy(LumpingStrategy::AddWeakConnections); p.SetCoarsestLevel(200); p.SetCouplingStrength(0.001); // Disable verbosity output of AMG preconditioner p.Verbose(0); // Set solver preconditioner ls.SetPreconditioner(p); // Set solver operator ls.SetOperator(mat); // Build solver ls.Build(); // Compute 2 coarsest levels on the host p.SetHostLevels(2); // Stop time measurement tack = rocalution_time(); std::cout << "Building took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Print matrix info mat.Info(); // Initialize solver tolerances ls.Init(1e-8, 1e-8, 1e+8, 10000); // Set verbosity output ls.Verbose(2); // Start time measurement tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop time measurement end = rocalution_time(); std::cout << "Total runtime: " << (end - start) / 1e6 << " sec" << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/cg.cpp000066400000000000000000000065171445302240700205150ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver CG, LocalVector, double> ls; // Preconditioner Jacobi, LocalVector, double> p; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Build solver ls.Build(); // Verbosity output ls.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/cg_mpi.cpp000066400000000000000000000067431445302240700213630ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "common.hpp" #include #include #include #define ValueType double using namespace rocalution; int main(int argc, char* argv[]) { // Initialize MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank; int num_procs; MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &num_procs); if(argc < 2) { std::cerr << argv[0] << " " << std::endl; return -1; } // Disable OpenMP thread affinity set_omp_affinity_rocalution(false); // Initialize platform with rank and # of accelerator devices in the node init_rocalution(rank, 2); // Disable OpenMP set_omp_threads_rocalution(1); // Print platform info_rocalution(); // Load undistributed matrix LocalMatrix lmat; lmat.ReadFileMTX(argv[1]); // Global structures ParallelManager manager; GlobalMatrix mat; // Distribute matrix - lmat will be destroyed distribute_matrix(&comm, &lmat, &mat, &manager); // rocALUTION vectors GlobalVector rhs(manager); GlobalVector x(manager); GlobalVector e(manager); // Move structures to accelerator, if available mat.MoveToAccelerator(); rhs.MoveToAccelerator(); x.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate memory rhs.Allocate("rhs", mat.GetM()); x.Allocate("x", mat.GetN()); e.Allocate("sol", mat.GetN()); e.Ones(); mat.Apply(e, &rhs); x.Zeros(); CG, GlobalVector, double> ls; Jacobi, GlobalVector, double> p; ls.SetPreconditioner(p); ls.SetOperator(mat); ls.Build(); ls.Verbose(1); mat.Info(); double time = rocalution_time(); ls.Solve(rhs, &x); time = rocalution_time() - time; if(rank == 0) { std::cout << "Solving: " << time / 1e6 << " sec" << std::endl; } e.ScaleAdd(-1.0, x); double nrm2 = e.Norm(); if(rank == 0) { std::cout << "||e - x||_2 = " << nrm2 << std::endl; } ls.Clear(); stop_rocalution(); MPI_Finalize(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/cmk.cpp000066400000000000000000000070411445302240700206670ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Compute (R)CMK ordering LocalVector cmk; // mat.CMK(&cmk); mat.RCMK(&cmk); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); cmk.MoveToAccelerator(); e.MoveToAccelerator(); // Apply (R)CMK ordering mat.Permute(cmk); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver CG, LocalVector, double> ls; // Preconditioner ILU, LocalVector, double> p; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Build solver ls.Build(); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Revert CMK ordering on solution vector x.PermuteBackward(cmk); // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/complex.cpp000066400000000000000000000072171445302240700215710ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector> x; LocalVector> rhs; LocalVector> e; LocalMatrix> mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Initialize e with some values for(int i = 0; i < mat.GetN(); ++i) e[i] = std::complex(1.0, -1.0); e.MoveToAccelerator(); // Linear Solver IDR>, LocalVector>, std::complex> ls; // Preconditioner Jacobi>, LocalVector>, std::complex> p; // Initialize rhs such that A 1 = rhs mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Build solver ls.Build(); // Verbosity output ls.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); std::complex error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/direct.cpp000066400000000000000000000057311445302240700213730ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " " << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator // mat.MoveToAccelerator(); // x.MoveToAccelerator(); // rhs.MoveToAccelerator(); // e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Direct solver Inversion, LocalVector, double> ds; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Set solver operator ds.SetOperator(mat); // Build solver ds.Build(); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ds.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ds.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/fcg.cpp000066400000000000000000000065071445302240700206620ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver FCG, LocalVector, double> ls; // Preconditioner IC, LocalVector, double> p; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Build solver ls.Build(); // Verbosity output ls.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/fcg_mpi.cpp000066400000000000000000000073511445302240700215250ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "common.hpp" #include #include #include #define ValueType double using namespace rocalution; int main(int argc, char* argv[]) { // Initialize MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank; int num_procs; MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &num_procs); // Check command line parameters if(num_procs < 2) { std::cerr << "Expecting at least 2 MPI processes" << std::endl; return -1; } if(argc < 2) { std::cerr << argv[0] << " " << std::endl; return -1; } // Disable OpenMP thread affinity set_omp_affinity_rocalution(false); // Initialize platform with rank and # of accelerator devices in the node init_rocalution(rank, 2); // Disable OpenMP set_omp_threads_rocalution(1); // Print platform info_rocalution(); // Load undistributed matrix LocalMatrix lmat; lmat.ReadFileMTX(argv[1]); // Global structures ParallelManager manager; GlobalMatrix mat; // Distribute matrix - lmat will be destroyed distribute_matrix(&comm, &lmat, &mat, &manager); // rocALUTION vectors GlobalVector rhs(manager); GlobalVector x(manager); GlobalVector e(manager); // Move structures to accelerator, if available mat.MoveToAccelerator(); rhs.MoveToAccelerator(); x.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate memory rhs.Allocate("rhs", mat.GetM()); x.Allocate("x", mat.GetN()); e.Allocate("sol", mat.GetN()); e.Ones(); mat.Apply(e, &rhs); x.Zeros(); FCG, GlobalVector, double> ls; BlockJacobi, GlobalVector, double> bj; ILU, LocalVector, double> p; bj.Set(p); ls.SetPreconditioner(bj); ls.SetOperator(mat); ls.Build(); ls.Verbose(1); mat.Info(); double time = rocalution_time(); ls.Solve(rhs, &x); time = rocalution_time() - time; if(rank == 0) { std::cout << "Solving: " << time / 1e6 << " sec" << std::endl; } e.ScaleAdd(-1.0, x); double nrm2 = e.Norm(); if(rank == 0) { std::cout << "||e - x||_2 = " << nrm2 << std::endl; } ls.Clear(); stop_rocalution(); MPI_Finalize(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/fgmres.cpp000066400000000000000000000066221445302240700214040ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver FGMRES, LocalVector, double> ls; // Preconditioner MultiColoredGS, LocalVector, double> p; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Set FGMRES basis size ls.SetBasisSize(15); // Build solver ls.Build(); // Verbosity output ls.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/fgmres_mpi.cpp000066400000000000000000000073511445302240700222510ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "common.hpp" #include #include #include #define ValueType double using namespace rocalution; int main(int argc, char* argv[]) { // Initialize MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank; int num_procs; MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &num_procs); // Check command line parameters if(num_procs < 2) { std::cerr << "Expecting at least 2 MPI processes" << std::endl; return -1; } if(argc < 2) { std::cerr << argv[0] << " " << std::endl; return -1; } // Disable OpenMP thread affinity set_omp_affinity_rocalution(false); // Initialize platform with rank and # of accelerator devices in the node init_rocalution(rank, 2); // Disable OpenMP set_omp_threads_rocalution(1); // Print platform info_rocalution(); // Load undistributed matrix LocalMatrix lmat; lmat.ReadFileMTX(argv[1]); // Global structures ParallelManager manager; GlobalMatrix mat; // Distribute matrix - lmat will be destroyed distribute_matrix(&comm, &lmat, &mat, &manager); // rocALUTION vectors GlobalVector rhs(manager); GlobalVector x(manager); GlobalVector e(manager); // Move structures to accelerator, if available mat.MoveToAccelerator(); rhs.MoveToAccelerator(); x.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate memory rhs.Allocate("rhs", mat.GetM()); x.Allocate("x", mat.GetN()); e.Allocate("sol", mat.GetN()); e.Ones(); mat.Apply(e, &rhs); x.Zeros(); FGMRES, GlobalVector, double> ls; BlockJacobi, GlobalVector, double> bj; SPAI, LocalVector, double> p; bj.Set(p); ls.SetPreconditioner(bj); ls.SetOperator(mat); ls.Build(); ls.Verbose(1); mat.Info(); double time = rocalution_time(); ls.Solve(rhs, &x); time = rocalution_time() - time; if(rank == 0) { std::cout << "Solving: " << time / 1e6 << " sec" << std::endl; } e.ScaleAdd(-1.0, x); double nrm2 = e.Norm(); if(rank == 0) { std::cout << "||e - x||_2 = " << nrm2 << std::endl; } ls.Clear(); stop_rocalution(); MPI_Finalize(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/fixed-point.cpp000066400000000000000000000072621445302240700223500ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); rhs.MoveToAccelerator(); x.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver FixedPoint, LocalVector, double> fp; Jacobi, LocalVector, double> p; // MultiColoredILU, LocalVector, double > p; // ILU, LocalVector, double > p; // MultiColoredGS, LocalVector, double > p; // MultiColoredSGS, LocalVector, double > p; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator fp.SetOperator(mat); // Set solver preconditioner fp.SetPreconditioner(p); // Set relaxation parameter omega fp.SetRelaxation(2. / 3.); // Verbosity output fp.Verbose(1); // Build solver fp.Build(); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs fp.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver fp.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/global-io_mpi.cpp000066400000000000000000000072031445302240700226270ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { if(argc < 2) { std::cerr << argv[0] << " " << std::endl; exit(1); } // Initialize MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank; int num_procs; MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &num_procs); if(num_procs < 2) { std::cerr << "Expecting more than 1 MPI process\n"; MPI_Finalize(); return -1; } // Disable OpenMP thread affinity set_omp_affinity_rocalution(false); // Initialize platform with rank and # of accelerator devices in the node init_rocalution(rank, 2); // Disable OpenMP set_omp_threads_rocalution(1); // Print platform info_rocalution(); // Parallel Manager ParallelManager pm; // Initialize Parallel Manager pm.SetMPICommunicator(&comm); // Read Parallel Manager from file pm.ReadFileASCII(std::string(argv[1])); // Create global structures GlobalMatrix mat(pm); GlobalVector rhs(pm); GlobalVector x(pm); GlobalVector e(pm); // Move structures to accelerator, if available mat.MoveToAccelerator(); rhs.MoveToAccelerator(); x.MoveToAccelerator(); e.MoveToAccelerator(); // Read from file mat.ReadFileMTX(std::string(argv[2])); rhs.Allocate("rhs", mat.GetM()); x.Allocate("x", mat.GetN()); e.Allocate("sol", mat.GetN()); e.Ones(); mat.Apply(e, &rhs); x.Zeros(); CG, GlobalVector, double> ls; BlockJacobi, GlobalVector, double> bj; FSAI, LocalVector, double> p; bj.Set(p); ls.SetPreconditioner(bj); ls.SetOperator(mat); ls.Build(); ls.Verbose(1); mat.Info(); double time = rocalution_time(); ls.Solve(rhs, &x); time = rocalution_time() - time; if(rank == 0) { std::cout << "Solving: " << time / 1e6 << " sec" << std::endl; } e.ScaleAdd(-1.0, x); double nrm2 = e.Norm(); if(rank == 0) { std::cout << "||e - x||_2 = " << nrm2 << std::endl; } ls.Clear(); stop_rocalution(); MPI_Finalize(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/gmres.cpp000066400000000000000000000066201445302240700212340ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver GMRES, LocalVector, double> ls; // Preconditioner MultiColoredGS, LocalVector, double> p; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Set GMRES basis size ls.SetBasisSize(15); // Build solver ls.Build(); // Verbosity output ls.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/idr.cpp000066400000000000000000000067041445302240700207000ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver IDR, LocalVector, double> ls; // Preconditioner Jacobi, LocalVector, double> p; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Set IDR shadow space ls.SetShadowSpace(4); // Set IDR random seed ls.SetRandomSeed(123456ULL); // Build solver ls.Build(); // Verbosity output ls.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/idr_mpi.cpp000066400000000000000000000073511445302240700215440ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "common.hpp" #include #include #include #define ValueType double using namespace rocalution; int main(int argc, char* argv[]) { // Initialize MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank; int num_procs; MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &num_procs); // Check command line parameters if(num_procs < 2) { std::cerr << "Expecting at least 2 MPI processes" << std::endl; return -1; } if(argc < 2) { std::cerr << argv[0] << " " << std::endl; return -1; } // Disable OpenMP thread affinity set_omp_affinity_rocalution(false); // Initialize platform with rank and # of accelerator devices in the node init_rocalution(rank, 2); // Disable OpenMP set_omp_threads_rocalution(1); // Print platform info_rocalution(); // Load undistributed matrix LocalMatrix lmat; lmat.ReadFileMTX(argv[1]); // Global structures ParallelManager manager; GlobalMatrix mat; // Distribute matrix - lmat will be destroyed distribute_matrix(&comm, &lmat, &mat, &manager); // rocALUTION vectors GlobalVector rhs(manager); GlobalVector x(manager); GlobalVector e(manager); // Move structures to accelerator, if available mat.MoveToAccelerator(); rhs.MoveToAccelerator(); x.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate memory rhs.Allocate("rhs", mat.GetM()); x.Allocate("x", mat.GetN()); e.Allocate("sol", mat.GetN()); e.Ones(); mat.Apply(e, &rhs); x.Zeros(); IDR, GlobalVector, double> ls; BlockJacobi, GlobalVector, double> bj; FSAI, LocalVector, double> p; bj.Set(p); ls.SetPreconditioner(bj); ls.SetOperator(mat); ls.Build(); ls.Verbose(1); mat.Info(); double time = rocalution_time(); ls.Solve(rhs, &x); time = rocalution_time() - time; if(rank == 0) { std::cout << "Solving: " << time / 1e6 << " sec" << std::endl; } e.ScaleAdd(-1.0, x); double nrm2 = e.Norm(); if(rank == 0) { std::cout << "||e - x||_2 = " << nrm2 << std::endl; } ls.Clear(); stop_rocalution(); MPI_Finalize(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/key.cpp000066400000000000000000000042121445302240700207020ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " " << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // rocALUTION objects LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Print matrix info mat.Info(); long int row_key; long int col_key; long int val_key; // Compute keys mat.Key(row_key, col_key, val_key); // Print keys std::cout << "Row key = " << row_key << std::endl << "Col key = " << col_key << std::endl << "Val key = " << val_key << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/me-preconditioner.cpp000066400000000000000000000070021445302240700235350ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver CG, LocalVector, double> cg; // Preconditioner (main) MultiElimination, LocalVector, double> p; // Last block-preconditioner MultiColoredILU, LocalVector, double> mcilu_p; mcilu_p.Set(0); p.Set(mcilu_p, 2, 0.4); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator cg.SetOperator(mat); // Set solver preconditioner cg.SetPreconditioner(p); // Build solver cg.Build(); // Verbosity output cg.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs cg.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver cg.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/mixed-precision.cpp000066400000000000000000000067571445302240700232310ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver MixedPrecisionDC, LocalVector, double, LocalMatrix, LocalVector, float> mp; CG, LocalVector, float> cg; MultiColoredILU, LocalVector, float> p; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // setup a lower tol for the inner solver cg.SetPreconditioner(p); cg.Init(1e-5, 1e-2, 1e+20, 100000); // setup the mixed-precision DC mp.SetOperator(mat); mp.Set(cg); // Build solver mp.Build(); // Verbosity output mp.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs mp.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver mp.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/power-method.cpp000066400000000000000000000147311445302240700225330ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); LocalVector b; LocalVector b_old; LocalVector* b_k; LocalVector* b_k1; LocalVector* b_tmp; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Gershgorin spectrum approximation double glambda_min, glambda_max; // Power method spectrum approximation double plambda_min, plambda_max; // Maximum number of iteration for the power method int iter_max = 10000; // Gershgorin approximation of the eigenvalues mat.Gershgorin(glambda_min, glambda_max); std::cout << "Gershgorin : Lambda min = " << glambda_min << "; Lambda max = " << glambda_max << std::endl; // Move objects to accelerator mat.MoveToAccelerator(); b.MoveToAccelerator(); b_old.MoveToAccelerator(); // Allocate vectors b.Allocate("b_k+1", mat.GetM()); b_k1 = &b; b_old.Allocate("b_k", mat.GetM()); b_k = &b_old; // Set b_k to 1 b_k->Ones(); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // compute lambda max for(int i = 0; i <= iter_max; ++i) { mat.Apply(*b_k, b_k1); // std::cout << b_k1->Dot(*b_k) << std::endl; b_k1->Scale(double(1.0) / b_k1->Norm()); b_tmp = b_k1; b_k1 = b_k; b_k = b_tmp; } // get lambda max (Rayleigh quotient) mat.Apply(*b_k, b_k1); plambda_max = b_k1->Dot(*b_k); tack = rocalution_time(); std::cout << "Power method (lambda max) execution:" << (tack - tick) / 1e6 << " sec" << std::endl; mat.AddScalarDiagonal(double(-1.0) * plambda_max); b_k->Ones(); tick = rocalution_time(); // compute lambda min for(int i = 0; i <= iter_max; ++i) { mat.Apply(*b_k, b_k1); // std::cout << b_k1->Dot(*b_k) + plambda_max << std::endl; b_k1->Scale(double(1.0) / b_k1->Norm()); b_tmp = b_k1; b_k1 = b_k; b_k = b_tmp; } // get lambda min (Rayleigh quotient) mat.Apply(*b_k, b_k1); plambda_min = (b_k1->Dot(*b_k) + plambda_max); // back to the original matrix mat.AddScalarDiagonal(plambda_max); tack = rocalution_time(); std::cout << "Power method (lambda min) execution:" << (tack - tick) / 1e6 << " sec" << std::endl; std::cout << "Power method Lambda min = " << plambda_min << "; Lambda max = " << plambda_max << "; iter=2x" << iter_max << std::endl; LocalVector x; LocalVector e; LocalVector rhs; x.CloneBackend(mat); e.CloneBackend(mat); rhs.CloneBackend(mat); x.Allocate("x", mat.GetN()); e.Allocate("e", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); // Chebyshev iteration Chebyshev, LocalVector, double> ls; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(mat); // Set eigenvalues ls.Set(plambda_min, plambda_max); // Build solver ls.Build(); // Start time measurement tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "Chebyshev iteration ||e - x||_2 = " << error << std::endl; // PCG + Chebyshev polynomial CG, LocalVector, double> cg; AIChebyshev, LocalVector, double> p; // damping factor plambda_min = plambda_max / 7; // Set preconditioner p.Set(3, plambda_min, plambda_max); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator cg.SetOperator(mat); // Set solver preconditioner cg.SetPreconditioner(p); // Build solver cg.Build(); // Start time measurement tick = rocalution_time(); // Solve A x = rhs cg.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver cg.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); error = e.Norm(); std::cout << "CG + AIChebyshev ||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/qmrcgstab_mpi.cpp000066400000000000000000000073511445302240700227510ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "common.hpp" #include #include #include #define ValueType double using namespace rocalution; int main(int argc, char* argv[]) { // Initialize MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank; int num_procs; MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &num_procs); // Check command line parameters if(num_procs < 2) { std::cerr << "Expecting at least 2 MPI processes" << std::endl; return -1; } if(argc < 2) { std::cerr << argv[0] << " " << std::endl; return -1; } // Disable OpenMP thread affinity set_omp_affinity_rocalution(false); // Initialize platform with rank and # of accelerator devices in the node init_rocalution(rank, 2); // Disable OpenMP set_omp_threads_rocalution(1); // Print platform info_rocalution(); // Load undistributed matrix LocalMatrix lmat; lmat.ReadFileMTX(argv[1]); // Global structures ParallelManager manager; GlobalMatrix mat; // Distribute matrix - lmat will be destroyed distribute_matrix(&comm, &lmat, &mat, &manager); // rocALUTION vectors GlobalVector rhs(manager); GlobalVector x(manager); GlobalVector e(manager); // Move structures to accelerator, if available mat.MoveToAccelerator(); rhs.MoveToAccelerator(); x.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate memory rhs.Allocate("rhs", mat.GetM()); x.Allocate("x", mat.GetN()); e.Allocate("sol", mat.GetN()); e.Ones(); mat.Apply(e, &rhs); x.Zeros(); QMRCGStab, GlobalVector, double> ls; BlockJacobi, GlobalVector, double> bj; ILUT, LocalVector, double> p; bj.Set(p); ls.SetPreconditioner(bj); ls.SetOperator(mat); ls.Build(); ls.Verbose(1); mat.Info(); double time = rocalution_time(); ls.Solve(rhs, &x); time = rocalution_time() - time; if(rank == 0) { std::cout << "Solving: " << time / 1e6 << " sec" << std::endl; } e.ScaleAdd(-1.0, x); double nrm2 = e.Norm(); if(rank == 0) { std::cout << "||e - x||_2 = " << nrm2 << std::endl; } ls.Clear(); stop_rocalution(); MPI_Finalize(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/sa-amg.cpp000066400000000000000000000153111445302240700212610ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2021 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Time measurement double tick, tack, start, end; // Start time measurement tick = rocalution_time(); start = rocalution_time(); // Linear Solver SAAMG, LocalVector, double> ls; // Set solver operator ls.SetOperator(mat); // Set coupling strength ls.SetCouplingStrength(0.001); // Set maximal number of unknowns on coarsest level ls.SetCoarsestLevel(200); // Set relaxation parameter for smoothed interpolation aggregation ls.SetInterpRelax(2. / 3.); // Set manual smoothers ls.SetManualSmoothers(true); // Set manual course grid solver ls.SetManualSolver(true); // Set grid transfer scaling ls.SetScaling(true); // Set coarsening strategy ls.SetCoarseningStrategy(CoarseningStrategy::Greedy); //ls.SetCoarseningStrategy(CoarseningStrategy::PMIS); // Move solver to the accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); ls.MoveToAccelerator(); // Build AMG hierarchy ls.BuildHierarchy(); // Stop build hierarchy time measurement tack = rocalution_time(); std::cout << "Build Hierarchy took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Start smoother time measurement tick = rocalution_time(); // Obtain number of AMG levels int levels = ls.GetNumLevels(); // Coarse Grid Solver CG, LocalVector, double> cgs; cgs.Verbose(0); // Smoother for each level IterativeLinearSolver, LocalVector, double>** sm = new IterativeLinearSolver, LocalVector, double>*[levels - 1]; Preconditioner, LocalVector, double>** p = new Preconditioner, LocalVector, double>*[levels - 1]; std::string preconditioner = "Jacobi"; // Initialize smoother for each level for(int i = 0; i < levels - 1; ++i) { FixedPoint, LocalVector, double>* fp; fp = new FixedPoint, LocalVector, double>; fp->SetRelaxation(1.3); sm[i] = fp; if(preconditioner == "GS") { p[i] = new GS, LocalVector, double>; } else if(preconditioner == "SGS") { p[i] = new SGS, LocalVector, double>; } else if(preconditioner == "ILU") { p[i] = new ILU, LocalVector, double>; } else if(preconditioner == "IC") { p[i] = new IC, LocalVector, double>; } else { p[i] = new Jacobi, LocalVector, double>; } sm[i]->SetPreconditioner(*p[i]); sm[i]->Verbose(0); } // Pass smoother and coarse grid solver to AMG ls.SetSmoother(sm); ls.SetSolver(cgs); // Set number of pre and post smoothing steps ls.SetSmootherPreIter(1); ls.SetSmootherPostIter(2); // Initialize solver tolerances ls.Init(1e-10, 1e-8, 1e+8, 10000); // Verbosity output ls.Verbose(2); // Build solver ls.Build(); // Move solver to the accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); ls.MoveToAccelerator(); // Print matrix info mat.Info(); // Stop building time measurement tack = rocalution_time(); std::cout << "Build took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Start solving time measurement tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop solving time measurement tack = rocalution_time(); std::cout << "Solving took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Clear the solver ls.Clear(); // Free all allocated data for(int i = 0; i < levels - 1; ++i) { delete p[i]; delete sm[i]; } delete[] p; delete[] sm; // End time measurement end = rocalution_time(); std::cout << "Total runtime: " << (end - start) / 1e6 << " sec" << std::endl; // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/simple-spmv.cpp000066400000000000000000000055501445302240700223740ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Print matrix info mat.Info(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); // Print vector info x.Info(); rhs.Info(); // Set rhs to 1 rhs.Ones(); // x = mat * rhs mat.Apply(rhs, &x); // Print dot product std::cout << "dot=" << x.Dot(rhs) << std::endl; // Convert matrix to ELL format mat.ConvertToELL(); // Print matrix info mat.Info(); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); // Print matrix info mat.Info(); // Set rhs to 1 rhs.Ones(); // x = mat * rhs mat.Apply(rhs, &x); // Print dot product std::cout << "dot=" << x.Dot(rhs) << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/sp-precond.cpp000066400000000000000000000071601445302240700221710ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver BiCGStab, LocalVector, double> ls; // Preconditioner DiagJacobiSaddlePointPrecond, LocalVector, double> p; MultiColoredILU, LocalVector, double> p1; MultiColoredILU, LocalVector, double> p2; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set up preconditioner // p1.Set(1); // p2.Set(1); p.Set(p1, p2); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Build solver ls.Build(); // Verbosity output ls.Verbose(2); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/stencil.cpp000066400000000000000000000053571445302240700215660ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Initialize rocALUTION init_rocalution(); // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalStencil stencil(Laplace2D); // Set up stencil grid stencil.SetGrid(100); // 100x100 // Allocate vectors x.Allocate("x", stencil.GetN()); rhs.Allocate("rhs", stencil.GetM()); e.Allocate("e", stencil.GetN()); // Linear Solver CG, LocalVector, double> ls; // Initialize rhs such that A 1 = rhs e.Ones(); stencil.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(stencil); // Build solver ls.Build(); // Print stencil info stencil.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/tns.cpp000066400000000000000000000065201445302240700207220ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver CG, LocalVector, double> ls; // Preconditioner TNS, LocalVector, double> p; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Build solver ls.Build(); // Verbosity output // ls.Verbose(2); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/ua-amg.cpp000066400000000000000000000137501445302240700212700ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Time measurement double tick, tack, start, end; // Start time measurement tick = rocalution_time(); start = rocalution_time(); // Linear Solver UAAMG, LocalVector, double> ls; // Set solver operator ls.SetOperator(mat); // Set coupling strength ls.SetCouplingStrength(0.001); // Set maximal number of unknowns on coarsest level ls.SetCoarsestLevel(200); // Set manual smoothers ls.SetManualSmoothers(true); // Set manual course grid solver ls.SetManualSolver(true); // Set grid transfer scaling ls.SetScaling(true); // Set coarsening strategy //ls.SetCoarseningStrategy(CoarseningStrategy::Greedy); ls.SetCoarseningStrategy(CoarseningStrategy::PMIS); // Move solver to the accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); ls.MoveToAccelerator(); // Build AMG hierarchy ls.BuildHierarchy(); // Stop build hierarchy time measurement tack = rocalution_time(); std::cout << "Build Hierarchy took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Start smoother time measurement tick = rocalution_time(); // Obtain number of AMG levels int levels = ls.GetNumLevels(); // Coarse Grid Solver CG, LocalVector, double> cgs; cgs.Verbose(0); // Smoother for each level IterativeLinearSolver, LocalVector, double>** sm = new IterativeLinearSolver, LocalVector, double>*[levels - 1]; Jacobi, LocalVector, double>** js = new Jacobi, LocalVector, double>*[levels - 1]; // Initialize smoother for each level for(int i = 0; i < levels - 1; ++i) { FixedPoint, LocalVector, double>* fp; fp = new FixedPoint, LocalVector, double>; fp->SetRelaxation(1.3); sm[i] = fp; js[i] = new Jacobi, LocalVector, double>; sm[i]->SetPreconditioner(*js[i]); sm[i]->Verbose(0); } // Pass smoother and coarse grid solver to AMG ls.SetSmoother(sm); ls.SetSolver(cgs); // Set number of pre and post smoothing steps ls.SetSmootherPreIter(1); ls.SetSmootherPostIter(2); // Initialize solver tolerances ls.Init(1e-10, 1e-8, 1e+8, 10000); // Verbosity output ls.Verbose(2); // Build solver ls.Build(); // Move solver to the accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); ls.MoveToAccelerator(); // Print matrix info mat.Info(); // Stop building time measurement tack = rocalution_time(); std::cout << "Build took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Start solving time measurement tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop solving time measurement tack = rocalution_time(); std::cout << "Solving took: " << (tack - tick) / 1e6 << " sec" << std::endl; // Clear the solver ls.Clear(); // Free all allocated data for(int i = 0; i < levels - 1; ++i) { delete js[i]; delete sm[i]; } delete[] js; delete[] sm; // End time measurement end = rocalution_time(); std::cout << "Total runtime: " << (end - start) / 1e6 << " sec" << std::endl; // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/samples/var-precond.cpp000066400000000000000000000075741445302240700223500ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include #include #include using namespace rocalution; int main(int argc, char* argv[]) { // Check command line parameters if(argc == 1) { std::cerr << argv[0] << " [Num threads]" << std::endl; exit(1); } // Initialize rocALUTION init_rocalution(); // Check command line parameters for number of OMP threads if(argc > 2) { set_omp_threads_rocalution(atoi(argv[2])); } // Print rocALUTION info info_rocalution(); // rocALUTION objects LocalVector x; LocalVector rhs; LocalVector e; LocalMatrix mat; // Read matrix from MTX file mat.ReadFileMTX(std::string(argv[1])); // Move objects to accelerator mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); e.MoveToAccelerator(); // Allocate vectors x.Allocate("x", mat.GetN()); rhs.Allocate("rhs", mat.GetM()); e.Allocate("e", mat.GetN()); // Linear Solver FGMRES, LocalVector, double> ls; // Variable Preconditioner VariablePreconditioner, LocalVector, double> p; Solver, LocalVector, double>** vp; vp = new Solver, LocalVector, double>*[3]; // Preconditioners MultiColoredSGS, LocalVector, double> p1; MultiColoredILU, LocalVector, double> p2; ILU, LocalVector, double> p3; vp[0] = &p1; vp[1] = &p2; vp[2] = &p3; // Initialize rhs such that A 1 = rhs e.Ones(); mat.Apply(e, &rhs); // Initial zero guess x.Zeros(); // Set variable preconditioners p.SetPreconditioner(3, vp); // Set solver operator ls.SetOperator(mat); // Set solver preconditioner ls.SetPreconditioner(p); // Build solver ls.Build(); // Verbosity output ls.Verbose(1); // Print matrix info mat.Info(); // Start time measurement double tick, tack; tick = rocalution_time(); // Solve A x = rhs ls.Solve(rhs, &x); // Stop time measurement tack = rocalution_time(); std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; // Clear solver ls.Clear(); delete[] vp; // Compute error L2 norm e.ScaleAdd(-1.0, x); double error = e.Norm(); std::cout << "||e - x||_2 = " << error << std::endl; // Stop rocALUTION platform stop_rocalution(); return 0; } rocALUTION-rocm-5.7.1/clients/tests/000077500000000000000000000000001445302240700171055ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/clients/tests/CMakeLists.txt000066400000000000000000000075221445302240700216530ustar00rootroot00000000000000# ######################################################################## # Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ######################################################################## # Find google test and its dependencies find_package(GTest REQUIRED) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) # Non MPI tests set(ROCALUTION_TEST_SOURCES rocalution_host_gtest_main.cpp # Direct solvers test_qr.cpp test_lu.cpp test_inversion.cpp # Krylov solvers test_backend.cpp test_bicgstab.cpp test_bicgstabl.cpp test_cg.cpp test_cr.cpp test_fcg.cpp test_fgmres.cpp test_gmres.cpp test_idr.cpp test_qmrcgstab.cpp # AMG test_pairwise_amg.cpp test_ruge_stueben_amg.cpp test_saamg.cpp test_uaamg.cpp ) if(NOT WIN32) # Local structures - skip on Windows, as google test does not support union for death tests list(APPEND ROCALUTION_TEST_SOURCES test_local_matrix.cpp test_local_stencil.cpp test_local_vector.cpp ) endif() # MPI tests if(SUPPORT_MPI) list(APPEND ROCALUTION_TEST_SOURCES test_global_matrix.cpp # test_global_stencil.cpp test_global_vector.cpp test_parallel_manager.cpp ) endif() # Common list(APPEND ROCALUTION_TEST_SOURCES ../include/random.cpp ) add_executable(rocalution-test ${ROCALUTION_TEST_SOURCES} ${ROCALUTION_CLIENTS_COMMON}) # Google test target_compile_definitions(rocalution-test PRIVATE GOOGLE_TEST) target_include_directories(rocalution-test SYSTEM PRIVATE $) target_link_libraries(rocalution-test PRIVATE ${GTEST_BOTH_LIBRARIES} Threads::Threads) # Include common client headers target_include_directories(rocalution-test PRIVATE $) # Link rocALUTION library target_link_libraries(rocalution-test PRIVATE roc::rocalution) if(NOT TARGET rocalution) set_target_properties(rocalution-test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging") else() set_target_properties(rocalution-test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/clients/staging") endif() # Add tests add_test(rocalution-test rocalution-test) rocm_install(TARGETS rocalution-test COMPONENT tests) if (WIN32) # for now adding in all .dll as dependency chain is not cmake based on win32 file( GLOB third_party_dlls LIST_DIRECTORIES OFF CONFIGURE_DEPENDS ${HIP_DIR}/bin/*.dll ${HIP_DIR}/bin/hipinfo.exe ${CMAKE_SOURCE_DIR}/rtest.* $ENV{rocsparse_DIR}/bin/*.dll $ENV{rocrand_DIR}/bin/*.dll $ENV{rocblas_DIR}/bin/*.dll C:/Windows/System32/libomp140*.dll ) foreach( file_i ${third_party_dlls}) add_custom_command( TARGET rocalution-test POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${file_i} ${PROJECT_BINARY_DIR}/staging/ ) endforeach( file_i ) endif() rocALUTION-rocm-5.7.1/clients/tests/rocalution_host_gtest_main.cpp000066400000000000000000000050251445302240700252410ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "utility.hpp" #include #include #include #define VAL(str) #str #define TOSTRING(str) VAL(str) int device; /* ===================================================================== Main function: =================================================================== */ int main(int argc, char** argv) { // Get device id from command line device = 0; for(int i = 1; i < argc; ++i) { if(strcmp(argv[i], "--device") == 0 && argc > i + 1) { device = atoi(argv[i + 1]); } if(strcmp(argv[i], "--version") == 0) { // Print version and exit, if requested std::cout << "rocALUTION version: " << __ROCALUTION_VER_MAJOR << "." << __ROCALUTION_VER_MINOR << "." << __ROCALUTION_VER_PATCH << "-" << TOSTRING(__ROCALUTION_VER_TWEAK) << std::endl; return 0; } } rocalution::set_device_rocalution(device); rocalution::init_rocalution(); rocalution::info_rocalution(); rocalution::stop_rocalution(); ::testing::InitGoogleTest(&argc, argv); ::testing::FLAGS_gtest_death_test_style = "threadsafe"; return RUN_ALL_TESTS(); } rocALUTION-rocm-5.7.1/clients/tests/test_backend.cpp000066400000000000000000000062221445302240700222410ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_backend.hpp" #include "utility.hpp" #include typedef std::tuple backend_tuple; int backend_rank[] = {-1, 0, 13}; int backend_dev_node[] = {-1, 0, 13}; int backend_dev[] = {-1, 0, 13}; int backend_omp_threads[] = {-1, 0, 8}; bool backend_affinity[] = {true, false}; int backend_omp_threshold[] = {-1, 0, 20000}; bool backend_disable_acc[] = {true, false}; class parameterized_backend : public testing::TestWithParam { protected: parameterized_backend() {} virtual ~parameterized_backend() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_backend_arguments(backend_tuple tup) { Arguments arg; arg.rank = std::get<0>(tup); arg.dev_per_node = std::get<1>(tup); arg.dev = std::get<2>(tup); arg.omp_nthreads = std::get<3>(tup); arg.omp_affinity = std::get<4>(tup); arg.omp_threshold = std::get<5>(tup); arg.use_acc = std::get<6>(tup); return arg; } TEST(backend_init_order, backend) { testing_backend_init_order(); } TEST_P(parameterized_backend, backend) { Arguments arg = setup_backend_arguments(GetParam()); testing_backend(arg); } INSTANTIATE_TEST_CASE_P(backend, parameterized_backend, testing::Combine(testing::ValuesIn(backend_rank), testing::ValuesIn(backend_dev_node), testing::ValuesIn(backend_dev), testing::ValuesIn(backend_omp_threads), testing::ValuesIn(backend_affinity), testing::ValuesIn(backend_omp_threshold), testing::ValuesIn(backend_disable_acc))); rocALUTION-rocm-5.7.1/clients/tests/test_bicgstab.cpp000066400000000000000000000052371445302240700224350ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_bicgstab.hpp" #include "utility.hpp" #include typedef std::tuple bicgstab_tuple; int bicgstab_size[] = {7, 63}; std::string bicgstab_precond[] = {"None", "Chebyshev", "TNS", "Jacobi", "ILUT", "MCGS", "MCILU"}; unsigned int bicgstab_format[] = {1, 2, 4, 6}; class parameterized_bicgstab : public testing::TestWithParam { protected: parameterized_bicgstab() {} virtual ~parameterized_bicgstab() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_bicgstab_arguments(bicgstab_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.precond = std::get<1>(tup); arg.format = std::get<2>(tup); return arg; } TEST_P(parameterized_bicgstab, bicgstab_float) { Arguments arg = setup_bicgstab_arguments(GetParam()); ASSERT_EQ(testing_bicgstab(arg), true); } TEST_P(parameterized_bicgstab, bicgstab_double) { Arguments arg = setup_bicgstab_arguments(GetParam()); ASSERT_EQ(testing_bicgstab(arg), true); } INSTANTIATE_TEST_CASE_P(bicgstab, parameterized_bicgstab, testing::Combine(testing::ValuesIn(bicgstab_size), testing::ValuesIn(bicgstab_precond), testing::ValuesIn(bicgstab_format))); rocALUTION-rocm-5.7.1/clients/tests/test_bicgstabl.cpp000066400000000000000000000055511445302240700226100ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_bicgstabl.hpp" #include "utility.hpp" #include typedef std::tuple bicgstabl_tuple; int bicgstabl_size[] = {7, 63}; std::string bicgstabl_precond[] = {"None", "SPAI", "TNS", "Jacobi", "GS", "ILU", "ILUT", "IC", "MCGS", "MCILU"}; unsigned int bicgstabl_format[] = {1, 4, 5, 6, 7}; int bicgstabl_level[] = {1, 2, 4}; class parameterized_bicgstabl : public testing::TestWithParam { protected: parameterized_bicgstabl() {} virtual ~parameterized_bicgstabl() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_bicgstabl_arguments(bicgstabl_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.precond = std::get<1>(tup); arg.format = std::get<2>(tup); arg.index = std::get<3>(tup); return arg; } TEST_P(parameterized_bicgstabl, bicgstabl_float) { Arguments arg = setup_bicgstabl_arguments(GetParam()); ASSERT_EQ(testing_bicgstabl(arg), true); } TEST_P(parameterized_bicgstabl, bicgstabl_double) { Arguments arg = setup_bicgstabl_arguments(GetParam()); ASSERT_EQ(testing_bicgstabl(arg), true); } INSTANTIATE_TEST_CASE_P(bicgstabl, parameterized_bicgstabl, testing::Combine(testing::ValuesIn(bicgstabl_size), testing::ValuesIn(bicgstabl_precond), testing::ValuesIn(bicgstabl_format), testing::ValuesIn(bicgstabl_level))); rocALUTION-rocm-5.7.1/clients/tests/test_cg.cpp000066400000000000000000000050101445302240700212350ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_cg.hpp" #include "utility.hpp" #include typedef std::tuple cg_tuple; int cg_size[] = {7, 63}; std::string cg_precond[] = {"None", "FSAI", "SPAI", "TNS", "Jacobi", "IC", "MCSGS"}; unsigned int cg_format[] = {1, 3, 4, 6}; class parameterized_cg : public testing::TestWithParam { protected: parameterized_cg() {} virtual ~parameterized_cg() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_cg_arguments(cg_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.precond = std::get<1>(tup); arg.format = std::get<2>(tup); return arg; } TEST_P(parameterized_cg, cg_float) { Arguments arg = setup_cg_arguments(GetParam()); ASSERT_EQ(testing_cg(arg), true); } TEST_P(parameterized_cg, cg_double) { Arguments arg = setup_cg_arguments(GetParam()); ASSERT_EQ(testing_cg(arg), true); } INSTANTIATE_TEST_CASE_P(cg, parameterized_cg, testing::Combine(testing::ValuesIn(cg_size), testing::ValuesIn(cg_precond), testing::ValuesIn(cg_format))); rocALUTION-rocm-5.7.1/clients/tests/test_cr.cpp000066400000000000000000000051121445302240700212530ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_cr.hpp" #include "utility.hpp" #include typedef std::tuple cr_tuple; int cr_size[] = {7, 63}; std::string cr_precond[] = {"None", "Chebyshev", "FSAI", "Jacobi", "SGS", "ILU", "IC", "MCSGS"}; unsigned int cr_format[] = {2, 4, 7}; class parameterized_cr : public testing::TestWithParam { protected: parameterized_cr() {} virtual ~parameterized_cr() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_cr_arguments(cr_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.precond = std::get<1>(tup); arg.format = std::get<2>(tup); return arg; } /* TODO there _MIGHT_ be some issue with float accuracy TEST_P(parameterized_cr, cr_float) { Arguments arg = setup_cr_arguments(GetParam()); ASSERT_EQ(testing_cr(arg), true); } */ TEST_P(parameterized_cr, cr_double) { Arguments arg = setup_cr_arguments(GetParam()); ASSERT_EQ(testing_cr(arg), true); } INSTANTIATE_TEST_CASE_P(cr, parameterized_cr, testing::Combine(testing::ValuesIn(cr_size), testing::ValuesIn(cr_precond), testing::ValuesIn(cr_format))); rocALUTION-rocm-5.7.1/clients/tests/test_fcg.cpp000066400000000000000000000050351445302240700214120ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_fcg.hpp" #include "utility.hpp" #include typedef std::tuple fcg_tuple; int fcg_size[] = {7, 63}; std::string fcg_precond[] = {"None", "Chebyshev", "SPAI", "TNS", "ILUT", "MCSGS"}; unsigned int fcg_format[] = {2, 5, 6, 7}; class parameterized_fcg : public testing::TestWithParam { protected: parameterized_fcg() {} virtual ~parameterized_fcg() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_fcg_arguments(fcg_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.precond = std::get<1>(tup); arg.format = std::get<2>(tup); return arg; } TEST_P(parameterized_fcg, fcg_float) { Arguments arg = setup_fcg_arguments(GetParam()); ASSERT_EQ(testing_fcg(arg), true); } TEST_P(parameterized_fcg, fcg_double) { Arguments arg = setup_fcg_arguments(GetParam()); ASSERT_EQ(testing_fcg(arg), true); } INSTANTIATE_TEST_CASE_P(fcg, parameterized_fcg, testing::Combine(testing::ValuesIn(fcg_size), testing::ValuesIn(fcg_precond), testing::ValuesIn(fcg_format))); rocALUTION-rocm-5.7.1/clients/tests/test_fgmres.cpp000066400000000000000000000054041445302240700221360ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_fgmres.hpp" #include "utility.hpp" #include typedef std::tuple fgmres_tuple; int fgmres_size[] = {7, 63}; int fgmres_basis[] = {20, 60}; std::string fgmres_precond[] = {"None", "SPAI", "TNS", "Jacobi", "GS", "ILUT", "MCGS"}; unsigned int fgmres_format[] = {1, 4, 5, 7}; class parameterized_fgmres : public testing::TestWithParam { protected: parameterized_fgmres() {} virtual ~parameterized_fgmres() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_fgmres_arguments(fgmres_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.index = std::get<1>(tup); arg.precond = std::get<2>(tup); arg.format = std::get<3>(tup); return arg; } TEST_P(parameterized_fgmres, fgmres_float) { Arguments arg = setup_fgmres_arguments(GetParam()); ASSERT_EQ(testing_fgmres(arg), true); } TEST_P(parameterized_fgmres, fgmres_double) { Arguments arg = setup_fgmres_arguments(GetParam()); ASSERT_EQ(testing_fgmres(arg), true); } INSTANTIATE_TEST_CASE_P(fgmres, parameterized_fgmres, testing::Combine(testing::ValuesIn(fgmres_size), testing::ValuesIn(fgmres_basis), testing::ValuesIn(fgmres_precond), testing::ValuesIn(fgmres_format))); rocALUTION-rocm-5.7.1/clients/tests/test_global_matrix.cpp000066400000000000000000000062241445302240700235000ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_global_matrix.hpp" #include "utility.hpp" #include /* typedef std::tuple backend_tuple; int backend_rank[] = {-1, 0, 13}; int backend_dev_node[] = {-1, 0, 13}; int backend_dev[] = {-1, 0, 13}; int backend_omp_threads[] = {-1, 0, 8}; bool backend_affinity[] = {true, false}; int backend_omp_threshold[] = {-1, 0, 20000}; bool backend_disable_acc[] = {true, false}; class parameterized_backend : public testing::TestWithParam { protected: parameterized_backend() {} virtual ~parameterized_backend() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_backend_arguments(backend_tuple tup) { Arguments arg; arg.rank = std::get<0>(tup); arg.dev_per_node = std::get<1>(tup); arg.dev = std::get<2>(tup); arg.omp_nthreads = std::get<3>(tup); arg.omp_affinity = std::get<4>(tup); arg.omp_threshold = std::get<5>(tup); arg.use_acc = std::get<6>(tup); return arg; } */ TEST(global_matrix_bad_args, global_matrix) { testing_global_matrix_bad_args(); } /* TEST_P(parameterized_backend, backend) { Arguments arg = setup_backend_arguments(GetParam()); testing_backend(arg); } INSTANTIATE_TEST_CASE_P(backend, parameterized_backend, testing::Combine(testing::ValuesIn(backend_rank), testing::ValuesIn(backend_dev_node), testing::ValuesIn(backend_dev), testing::ValuesIn(backend_omp_threads), testing::ValuesIn(backend_affinity), testing::ValuesIn(backend_omp_threshold), testing::ValuesIn(backend_disable_acc))); */ rocALUTION-rocm-5.7.1/clients/tests/test_global_vector.cpp000066400000000000000000000062241445302240700234760ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_global_vector.hpp" #include "utility.hpp" #include /* typedef std::tuple backend_tuple; int backend_rank[] = {-1, 0, 13}; int backend_dev_node[] = {-1, 0, 13}; int backend_dev[] = {-1, 0, 13}; int backend_omp_threads[] = {-1, 0, 8}; bool backend_affinity[] = {true, false}; int backend_omp_threshold[] = {-1, 0, 20000}; bool backend_disable_acc[] = {true, false}; class parameterized_backend : public testing::TestWithParam { protected: parameterized_backend() {} virtual ~parameterized_backend() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_backend_arguments(backend_tuple tup) { Arguments arg; arg.rank = std::get<0>(tup); arg.dev_per_node = std::get<1>(tup); arg.dev = std::get<2>(tup); arg.omp_nthreads = std::get<3>(tup); arg.omp_affinity = std::get<4>(tup); arg.omp_threshold = std::get<5>(tup); arg.use_acc = std::get<6>(tup); return arg; } */ TEST(global_vector_bad_args, global_vector) { testing_global_vector_bad_args(); } /* TEST_P(parameterized_backend, backend) { Arguments arg = setup_backend_arguments(GetParam()); testing_backend(arg); } INSTANTIATE_TEST_CASE_P(backend, parameterized_backend, testing::Combine(testing::ValuesIn(backend_rank), testing::ValuesIn(backend_dev_node), testing::ValuesIn(backend_dev), testing::ValuesIn(backend_omp_threads), testing::ValuesIn(backend_affinity), testing::ValuesIn(backend_omp_threshold), testing::ValuesIn(backend_disable_acc))); */ rocALUTION-rocm-5.7.1/clients/tests/test_gmres.cpp000066400000000000000000000076671445302240700220050ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_gmres.hpp" #include "utility.hpp" #include typedef std::tuple gmres_tuple; int gmres_size[] = {7, 63}; int gmres_basis[] = {20, 60}; std::string gmres_matrix[] = {"laplacian"}; std::string gmres_bad_precond_matrix[] = {"permuted_identity"}; std::string gmres_precond[] = {"None", "Chebyshev", "GS", "ILU", "ILUT", "MCGS", "MCILU"}; std::string gmres_bad_precond[] = {"MCGS"}; unsigned int gmres_format[] = {1, 2, 5, 6}; class parameterized_gmres : public testing::TestWithParam { protected: parameterized_gmres() {} virtual ~parameterized_gmres() {} virtual void SetUp() {} virtual void TearDown() {} }; class parameterized_gmres_bad_precond : public testing::TestWithParam { protected: parameterized_gmres_bad_precond() {} virtual ~parameterized_gmres_bad_precond() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_gmres_arguments(gmres_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.index = std::get<1>(tup); arg.matrix = std::get<2>(tup); arg.precond = std::get<3>(tup); arg.format = std::get<4>(tup); return arg; } TEST_P(parameterized_gmres, gmres_float) { Arguments arg = setup_gmres_arguments(GetParam()); ASSERT_EQ(testing_gmres(arg), true); } TEST_P(parameterized_gmres, gmres_double) { Arguments arg = setup_gmres_arguments(GetParam()); ASSERT_EQ(testing_gmres(arg), true); } TEST_P(parameterized_gmres_bad_precond, gmres_float) { Arguments arg = setup_gmres_arguments(GetParam()); ASSERT_EQ(testing_gmres(arg, false), true); } INSTANTIATE_TEST_CASE_P(gmres, parameterized_gmres, testing::Combine(testing::ValuesIn(gmres_size), testing::ValuesIn(gmres_basis), testing::ValuesIn(gmres_matrix), testing::ValuesIn(gmres_precond), testing::ValuesIn(gmres_format))); INSTANTIATE_TEST_CASE_P(gmres_bad_precond, parameterized_gmres_bad_precond, testing::Combine(testing::ValuesIn(gmres_size), testing::ValuesIn(gmres_basis), testing::ValuesIn(gmres_bad_precond_matrix), testing::ValuesIn(gmres_bad_precond), testing::ValuesIn(gmres_format))); rocALUTION-rocm-5.7.1/clients/tests/test_idr.cpp000066400000000000000000000052461445302240700214350ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_idr.hpp" #include "utility.hpp" #include typedef std::tuple idr_tuple; int idr_size[] = {7, 63}; std::string idr_precond[] = {"None", "SPAI", "GS", "ILU", "MCILU"}; unsigned int idr_format[] = {1, 4, 5, 6}; int idr_level[] = {1, 2, 4}; class parameterized_idr : public testing::TestWithParam { protected: parameterized_idr() {} virtual ~parameterized_idr() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_idr_arguments(idr_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.precond = std::get<1>(tup); arg.format = std::get<2>(tup); arg.index = std::get<3>(tup); return arg; } TEST_P(parameterized_idr, idr_float) { Arguments arg = setup_idr_arguments(GetParam()); ASSERT_EQ(testing_idr(arg), true); } TEST_P(parameterized_idr, idr_double) { Arguments arg = setup_idr_arguments(GetParam()); ASSERT_EQ(testing_idr(arg), true); } INSTANTIATE_TEST_CASE_P(idr, parameterized_idr, testing::Combine(testing::ValuesIn(idr_size), testing::ValuesIn(idr_precond), testing::ValuesIn(idr_format), testing::ValuesIn(idr_level))); rocALUTION-rocm-5.7.1/clients/tests/test_inversion.cpp000066400000000000000000000052771445302240700226770ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_inversion.hpp" #include "utility.hpp" #include typedef std::tuple inversion_tuple; int inversion_size[] = {7, 16, 21}; unsigned int inversion_format[] = {1, 2, 3, 4, 5, 6, 7}; std::string inversion_matrix_type[] = {"Laplacian2D", "PermutedIdentity"}; class parameterized_inversion : public testing::TestWithParam { protected: parameterized_inversion() {} virtual ~parameterized_inversion() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_inversion_arguments(inversion_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.format = std::get<1>(tup); arg.matrix_type = std::get<2>(tup); return arg; } TEST_P(parameterized_inversion, inversion_float) { Arguments arg = setup_inversion_arguments(GetParam()); ASSERT_EQ(testing_inversion(arg), true); } TEST_P(parameterized_inversion, inversion_double) { Arguments arg = setup_inversion_arguments(GetParam()); ASSERT_EQ(testing_inversion(arg), true); } INSTANTIATE_TEST_CASE_P(inversion, parameterized_inversion, testing::Combine(testing::ValuesIn(inversion_size), testing::ValuesIn(inversion_format), testing::ValuesIn(inversion_matrix_type))); rocALUTION-rocm-5.7.1/clients/tests/test_local_matrix.cpp000066400000000000000000000107711445302240700233340ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_local_matrix.hpp" #include "utility.hpp" #include typedef std::tuple local_matrix_conversions_tuple; typedef std::tuple local_matrix_allocations_tuple; int local_matrix_conversions_size[] = {10, 17, 21}; int local_matrix_conversions_blockdim[] = {4, 7, 11}; std::string local_matrix_type[] = {"Laplacian2D", "PermutedIdentity", "Random"}; int local_matrix_allocations_size[] = {100, 1475, 2524}; int local_matrix_allocations_blockdim[] = {4, 7, 11}; class parameterized_local_matrix_conversions : public testing::TestWithParam { protected: parameterized_local_matrix_conversions() {} virtual ~parameterized_local_matrix_conversions() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_local_matrix_conversions_arguments(local_matrix_conversions_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.blockdim = std::get<1>(tup); arg.matrix_type = std::get<2>(tup); return arg; } class parameterized_local_matrix_allocations : public testing::TestWithParam { protected: parameterized_local_matrix_allocations() {} virtual ~parameterized_local_matrix_allocations() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_local_matrix_allocations_arguments(local_matrix_allocations_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.blockdim = std::get<1>(tup); return arg; } TEST(local_matrix_bad_args, local_matrix) { testing_local_matrix_bad_args(); } TEST_P(parameterized_local_matrix_conversions, local_matrix_conversions_float) { Arguments arg = setup_local_matrix_conversions_arguments(GetParam()); ASSERT_EQ(testing_local_matrix_conversions(arg), true); } TEST_P(parameterized_local_matrix_conversions, local_matrix_conversions_double) { Arguments arg = setup_local_matrix_conversions_arguments(GetParam()); ASSERT_EQ(testing_local_matrix_conversions(arg), true); } INSTANTIATE_TEST_CASE_P(local_matrix_conversions, parameterized_local_matrix_conversions, testing::Combine(testing::ValuesIn(local_matrix_conversions_size), testing::ValuesIn(local_matrix_conversions_blockdim), testing::ValuesIn(local_matrix_type))); TEST_P(parameterized_local_matrix_allocations, local_matrix_allocations_float) { Arguments arg = setup_local_matrix_allocations_arguments(GetParam()); ASSERT_EQ(testing_local_matrix_allocations(arg), true); } TEST_P(parameterized_local_matrix_allocations, local_matrix_allocations_double) { Arguments arg = setup_local_matrix_allocations_arguments(GetParam()); ASSERT_EQ(testing_local_matrix_allocations(arg), true); } INSTANTIATE_TEST_CASE_P(local_matrix_allocations, parameterized_local_matrix_allocations, testing::Combine(testing::ValuesIn(local_matrix_allocations_size), testing::ValuesIn(local_matrix_allocations_blockdim))); rocALUTION-rocm-5.7.1/clients/tests/test_local_stencil.cpp000066400000000000000000000062241445302240700234670ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_local_stencil.hpp" #include "utility.hpp" #include /* typedef std::tuple backend_tuple; int backend_rank[] = {-1, 0, 13}; int backend_dev_node[] = {-1, 0, 13}; int backend_dev[] = {-1, 0, 13}; int backend_omp_threads[] = {-1, 0, 8}; bool backend_affinity[] = {true, false}; int backend_omp_threshold[] = {-1, 0, 20000}; bool backend_disable_acc[] = {true, false}; class parameterized_backend : public testing::TestWithParam { protected: parameterized_backend() {} virtual ~parameterized_backend() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_backend_arguments(backend_tuple tup) { Arguments arg; arg.rank = std::get<0>(tup); arg.dev_per_node = std::get<1>(tup); arg.dev = std::get<2>(tup); arg.omp_nthreads = std::get<3>(tup); arg.omp_affinity = std::get<4>(tup); arg.omp_threshold = std::get<5>(tup); arg.use_acc = std::get<6>(tup); return arg; } */ TEST(local_stencil_bad_args, local_stencil) { testing_local_stencil_bad_args(); } /* TEST_P(parameterized_backend, backend) { Arguments arg = setup_backend_arguments(GetParam()); testing_backend(arg); } INSTANTIATE_TEST_CASE_P(backend, parameterized_backend, testing::Combine(testing::ValuesIn(backend_rank), testing::ValuesIn(backend_dev_node), testing::ValuesIn(backend_dev), testing::ValuesIn(backend_omp_threads), testing::ValuesIn(backend_affinity), testing::ValuesIn(backend_omp_threshold), testing::ValuesIn(backend_disable_acc))); */ rocALUTION-rocm-5.7.1/clients/tests/test_local_vector.cpp000066400000000000000000000062201445302240700233240ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_local_vector.hpp" #include "utility.hpp" #include /* typedef std::tuple backend_tuple; int backend_rank[] = {-1, 0, 13}; int backend_dev_node[] = {-1, 0, 13}; int backend_dev[] = {-1, 0, 13}; int backend_omp_threads[] = {-1, 0, 8}; bool backend_affinity[] = {true, false}; int backend_omp_threshold[] = {-1, 0, 20000}; bool backend_disable_acc[] = {true, false}; class parameterized_backend : public testing::TestWithParam { protected: parameterized_backend() {} virtual ~parameterized_backend() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_backend_arguments(backend_tuple tup) { Arguments arg; arg.rank = std::get<0>(tup); arg.dev_per_node = std::get<1>(tup); arg.dev = std::get<2>(tup); arg.omp_nthreads = std::get<3>(tup); arg.omp_affinity = std::get<4>(tup); arg.omp_threshold = std::get<5>(tup); arg.use_acc = std::get<6>(tup); return arg; } */ TEST(local_vector_bad_args, local_vector) { testing_local_vector_bad_args(); } /* TEST_P(parameterized_backend, backend) { Arguments arg = setup_backend_arguments(GetParam()); testing_backend(arg); } INSTANTIATE_TEST_CASE_P(backend, parameterized_backend, testing::Combine(testing::ValuesIn(backend_rank), testing::ValuesIn(backend_dev_node), testing::ValuesIn(backend_dev), testing::ValuesIn(backend_omp_threads), testing::ValuesIn(backend_affinity), testing::ValuesIn(backend_omp_threshold), testing::ValuesIn(backend_disable_acc))); */ rocALUTION-rocm-5.7.1/clients/tests/test_lu.cpp000066400000000000000000000050031445302240700212660ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_lu.hpp" #include "utility.hpp" #include typedef std::tuple lu_tuple; int lu_size[] = {7, 16, 21}; unsigned int lu_format[] = {1, 2, 3, 4, 5, 6, 7}; std::string lu_matrix_type[] = {"Laplacian2D"}; class parameterized_lu : public testing::TestWithParam { protected: parameterized_lu() {} virtual ~parameterized_lu() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_lu_arguments(lu_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.format = std::get<1>(tup); arg.matrix_type = std::get<2>(tup); return arg; } TEST_P(parameterized_lu, lu_float) { Arguments arg = setup_lu_arguments(GetParam()); ASSERT_EQ(testing_lu(arg), true); } TEST_P(parameterized_lu, lu_double) { Arguments arg = setup_lu_arguments(GetParam()); ASSERT_EQ(testing_lu(arg), true); } INSTANTIATE_TEST_CASE_P(lu, parameterized_lu, testing::Combine(testing::ValuesIn(lu_size), testing::ValuesIn(lu_format), testing::ValuesIn(lu_matrix_type))); rocALUTION-rocm-5.7.1/clients/tests/test_pairwise_amg.cpp000066400000000000000000000065461445302240700233320ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_pairwise_amg.hpp" #include "utility.hpp" #include typedef std::tuple pwamg_tuple; int pwamg_size[] = {63, 134}; std::string pwamg_smoother[] = {"Jacobi"}; //, "MCILU"}; unsigned int pwamg_format[] = {1, 7}; int pwamg_pre_iter[] = {1, 2}; int pwamg_post_iter[] = {1, 2}; int pwamg_ordering[] = {0, 1, 2, 3, 4, 5}; int pwamg_rebuildnumeric[] = {0, 1}; class parameterized_pairwise_amg : public testing::TestWithParam { protected: parameterized_pairwise_amg() {} virtual ~parameterized_pairwise_amg() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_pwamg_arguments(pwamg_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.smoother = std::get<1>(tup); arg.format = std::get<2>(tup); arg.pre_smooth = std::get<3>(tup); arg.post_smooth = std::get<4>(tup); arg.ordering = std::get<5>(tup); arg.rebuildnumeric = std::get<6>(tup); return arg; } TEST_P(parameterized_pairwise_amg, pairwise_amg_float) { Arguments arg = setup_pwamg_arguments(GetParam()); ASSERT_EQ(testing_pairwise_amg(arg), true); } TEST_P(parameterized_pairwise_amg, pairwise_amg_double) { Arguments arg = setup_pwamg_arguments(GetParam()); ASSERT_EQ(testing_pairwise_amg(arg), true); } INSTANTIATE_TEST_CASE_P(pairwise_amg, parameterized_pairwise_amg, testing::Combine(testing::ValuesIn(pwamg_size), testing::ValuesIn(pwamg_smoother), testing::ValuesIn(pwamg_format), testing::ValuesIn(pwamg_pre_iter), testing::ValuesIn(pwamg_post_iter), testing::ValuesIn(pwamg_ordering), testing::ValuesIn(pwamg_rebuildnumeric))); rocALUTION-rocm-5.7.1/clients/tests/test_parallel_manager.cpp000066400000000000000000000062401445302240700241400ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_parallel_manager.hpp" #include "utility.hpp" #include /* typedef std::tuple backend_tuple; int backend_rank[] = {-1, 0, 13}; int backend_dev_node[] = {-1, 0, 13}; int backend_dev[] = {-1, 0, 13}; int backend_omp_threads[] = {-1, 0, 8}; bool backend_affinity[] = {true, false}; int backend_omp_threshold[] = {-1, 0, 20000}; bool backend_disable_acc[] = {true, false}; class parameterized_backend : public testing::TestWithParam { protected: parameterized_backend() {} virtual ~parameterized_backend() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_backend_arguments(backend_tuple tup) { Arguments arg; arg.rank = std::get<0>(tup); arg.dev_per_node = std::get<1>(tup); arg.dev = std::get<2>(tup); arg.omp_nthreads = std::get<3>(tup); arg.omp_affinity = std::get<4>(tup); arg.omp_threshold = std::get<5>(tup); arg.use_acc = std::get<6>(tup); return arg; } */ TEST(parallel_manager_bad_args, parallel_manager) { testing_parallel_manager_bad_args(); } /* TEST_P(parameterized_backend, backend) { Arguments arg = setup_backend_arguments(GetParam()); testing_backend(arg); } INSTANTIATE_TEST_CASE_P(backend, parameterized_backend, testing::Combine(testing::ValuesIn(backend_rank), testing::ValuesIn(backend_dev_node), testing::ValuesIn(backend_dev), testing::ValuesIn(backend_omp_threads), testing::ValuesIn(backend_affinity), testing::ValuesIn(backend_omp_threshold), testing::ValuesIn(backend_disable_acc))); */ rocALUTION-rocm-5.7.1/clients/tests/test_qmrcgstab.cpp000066400000000000000000000052541445302240700226410ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_qmrcgstab.hpp" #include "utility.hpp" #include typedef std::tuple qmrcgstab_tuple; int qmrcgstab_size[] = {7, 63}; std::string qmrcgstab_precond[] = {"None", "Chebyshev", "SPAI", "Jacobi", "GS", "ILU"}; unsigned int qmrcgstab_format[] = {1, 2, 3, 7}; class parameterized_qmrcgstab : public testing::TestWithParam { protected: parameterized_qmrcgstab() {} virtual ~parameterized_qmrcgstab() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_qmrcgstab_arguments(qmrcgstab_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.precond = std::get<1>(tup); arg.format = std::get<2>(tup); return arg; } TEST_P(parameterized_qmrcgstab, qmrcgstab_float) { Arguments arg = setup_qmrcgstab_arguments(GetParam()); ASSERT_EQ(testing_qmrcgstab(arg), true); } TEST_P(parameterized_qmrcgstab, qmrcgstab_double) { Arguments arg = setup_qmrcgstab_arguments(GetParam()); ASSERT_EQ(testing_qmrcgstab(arg), true); } INSTANTIATE_TEST_CASE_P(qmrcgstab, parameterized_qmrcgstab, testing::Combine(testing::ValuesIn(qmrcgstab_size), testing::ValuesIn(qmrcgstab_precond), testing::ValuesIn(qmrcgstab_format))); rocALUTION-rocm-5.7.1/clients/tests/test_qr.cpp000066400000000000000000000050271445302240700212760ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_qr.hpp" #include "utility.hpp" #include typedef std::tuple qr_tuple; int qr_size[] = {7, 16, 21}; unsigned int qr_format[] = {1, 2, 3, 4, 5, 6, 7}; std::string qr_matrix_type[] = {"Laplacian2D", "PermutedIdentity"}; class parameterized_qr : public testing::TestWithParam { protected: parameterized_qr() {} virtual ~parameterized_qr() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_qr_arguments(qr_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.format = std::get<1>(tup); arg.matrix_type = std::get<2>(tup); return arg; } TEST_P(parameterized_qr, qr_float) { Arguments arg = setup_qr_arguments(GetParam()); ASSERT_EQ(testing_qr(arg), true); } TEST_P(parameterized_qr, qr_double) { Arguments arg = setup_qr_arguments(GetParam()); ASSERT_EQ(testing_qr(arg), true); } INSTANTIATE_TEST_CASE_P(qr, parameterized_qr, testing::Combine(testing::ValuesIn(qr_size), testing::ValuesIn(qr_format), testing::ValuesIn(qr_matrix_type))); rocALUTION-rocm-5.7.1/clients/tests/test_ruge_stueben_amg.cpp000066400000000000000000000070421445302240700241660ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_ruge_stueben_amg.hpp" #include "utility.hpp" #include typedef std::tuple rsamg_tuple; int rsamg_size[] = {63, 134}; std::string rsamg_smoother[] = {"Jacobi"}; unsigned int rsamg_format[] = {1, 7}; int rsamg_pre_iter[] = {1, 2}; int rsamg_post_iter[] = {1, 2}; int rsamg_cycle[] = {0, 1}; int rsamg_scaling[] = {0, 1}; int rsamg_rebuildnumeric[] = {0, 1}; class parameterized_ruge_stueben_amg : public testing::TestWithParam { protected: parameterized_ruge_stueben_amg() {} virtual ~parameterized_ruge_stueben_amg() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_rsamg_arguments(rsamg_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.smoother = std::get<1>(tup); arg.format = std::get<2>(tup); arg.pre_smooth = std::get<3>(tup); arg.post_smooth = std::get<4>(tup); arg.cycle = std::get<5>(tup); arg.ordering = std::get<6>(tup); arg.rebuildnumeric = std::get<7>(tup); return arg; } TEST_P(parameterized_ruge_stueben_amg, ruge_stueben_amg_float) { Arguments arg = setup_rsamg_arguments(GetParam()); ASSERT_EQ(testing_ruge_stueben_amg(arg), true); } TEST_P(parameterized_ruge_stueben_amg, ruge_stueben_amg_double) { Arguments arg = setup_rsamg_arguments(GetParam()); ASSERT_EQ(testing_ruge_stueben_amg(arg), true); } INSTANTIATE_TEST_CASE_P(ruge_stueben_amg, parameterized_ruge_stueben_amg, testing::Combine(testing::ValuesIn(rsamg_size), testing::ValuesIn(rsamg_smoother), testing::ValuesIn(rsamg_format), testing::ValuesIn(rsamg_pre_iter), testing::ValuesIn(rsamg_post_iter), testing::ValuesIn(rsamg_cycle), testing::ValuesIn(rsamg_scaling), testing::ValuesIn(rsamg_rebuildnumeric))); rocALUTION-rocm-5.7.1/clients/tests/test_saamg.cpp000066400000000000000000000075711445302240700217520ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2022 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_saamg.hpp" #include "utility.hpp" #include typedef std:: tuple saamg_tuple; int saamg_size[] = {22, 63, 134, 207}; int saamg_pre_iter[] = {2}; int saamg_post_iter[] = {2}; std::string saamg_smoother[] = {"FSAI", "SPAI"}; std::string saamg_coarsening_strat[] = {"Greedy", "PMIS"}; std::string saamg_matrix_type[] = {"Laplacian2D"}; unsigned int saamg_format[] = {1, 6}; int saamg_cycle[] = {2}; int saamg_scaling[] = {1}; int saamg_rebuildnumeric[] = {0, 1}; class parameterized_saamg : public testing::TestWithParam { protected: parameterized_saamg() {} virtual ~parameterized_saamg() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_saamg_arguments(saamg_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.pre_smooth = std::get<1>(tup); arg.post_smooth = std::get<2>(tup); arg.smoother = std::get<3>(tup); arg.coarsening_strategy = std::get<4>(tup); arg.matrix_type = std::get<5>(tup); arg.format = std::get<6>(tup); arg.cycle = std::get<7>(tup); arg.ordering = std::get<8>(tup); arg.rebuildnumeric = std::get<9>(tup); return arg; } TEST_P(parameterized_saamg, saamg_float) { Arguments arg = setup_saamg_arguments(GetParam()); ASSERT_EQ(testing_saamg(arg), true); } TEST_P(parameterized_saamg, saamg_double) { Arguments arg = setup_saamg_arguments(GetParam()); ASSERT_EQ(testing_saamg(arg), true); } INSTANTIATE_TEST_CASE_P(saamg, parameterized_saamg, testing::Combine(testing::ValuesIn(saamg_size), testing::ValuesIn(saamg_pre_iter), testing::ValuesIn(saamg_post_iter), testing::ValuesIn(saamg_smoother), testing::ValuesIn(saamg_coarsening_strat), testing::ValuesIn(saamg_matrix_type), testing::ValuesIn(saamg_format), testing::ValuesIn(saamg_cycle), testing::ValuesIn(saamg_scaling), testing::ValuesIn(saamg_rebuildnumeric))); rocALUTION-rocm-5.7.1/clients/tests/test_uaamg.cpp000066400000000000000000000076141445302240700217520ustar00rootroot00000000000000/* ************************************************************************ * Copyright (C) 2018-2023 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #include "testing_uaamg.hpp" #include "utility.hpp" #include typedef std:: tuple uaamg_tuple; int uaamg_size[] = {22, 63, 134, 157}; int uaamg_pre_iter[] = {2}; int uaamg_post_iter[] = {2}; std::string uaamg_smoother[] = {"FSAI" /*, "ILU"*/}; std::string uaamg_coarsening_strat[] = {"Greedy", "PMIS"}; std::string uaamg_matrix_type[] = {"Laplacian2D", "Laplacian3D"}; unsigned int uaamg_format[] = {1, 6}; int uaamg_cycle[] = {2}; int uaamg_scaling[] = {1}; int uaamg_rebuildnumeric[] = {0, 1}; class parameterized_uaamg : public testing::TestWithParam { protected: parameterized_uaamg() {} virtual ~parameterized_uaamg() {} virtual void SetUp() {} virtual void TearDown() {} }; Arguments setup_uaamg_arguments(uaamg_tuple tup) { Arguments arg; arg.size = std::get<0>(tup); arg.pre_smooth = std::get<1>(tup); arg.post_smooth = std::get<2>(tup); arg.smoother = std::get<3>(tup); arg.coarsening_strategy = std::get<4>(tup); arg.matrix_type = std::get<5>(tup); arg.format = std::get<6>(tup); arg.cycle = std::get<7>(tup); arg.ordering = std::get<8>(tup); arg.rebuildnumeric = std::get<9>(tup); return arg; } TEST_P(parameterized_uaamg, uaamg_float) { Arguments arg = setup_uaamg_arguments(GetParam()); ASSERT_EQ(testing_uaamg(arg), true); } TEST_P(parameterized_uaamg, uaamg_double) { Arguments arg = setup_uaamg_arguments(GetParam()); ASSERT_EQ(testing_uaamg(arg), true); } INSTANTIATE_TEST_CASE_P(uaamg, parameterized_uaamg, testing::Combine(testing::ValuesIn(uaamg_size), testing::ValuesIn(uaamg_pre_iter), testing::ValuesIn(uaamg_post_iter), testing::ValuesIn(uaamg_smoother), testing::ValuesIn(uaamg_coarsening_strat), testing::ValuesIn(uaamg_matrix_type), testing::ValuesIn(uaamg_format), testing::ValuesIn(uaamg_cycle), testing::ValuesIn(uaamg_scaling), testing::ValuesIn(uaamg_rebuildnumeric))); rocALUTION-rocm-5.7.1/cmake/000077500000000000000000000000001445302240700153625ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/cmake/Dependencies.cmake000066400000000000000000000107401445302240700207540ustar00rootroot00000000000000# ######################################################################## # Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ######################################################################## # Dependencies # Find OpenMP package find_package(OpenMP) if (NOT OPENMP_FOUND) message("-- OpenMP not found. Compiling WITHOUT OpenMP support.") else() option(SUPPORT_OMP "Compile WITH OpenMP support." ON) if(NOT TARGET OpenMP::OpenMP_CXX) # cmake fix for cmake <= 3.9 find_package(Threads REQUIRED) add_library(OpenMP::OpenMP_CXX IMPORTED INTERFACE) set_property(TARGET OpenMP::OpenMP_CXX PROPERTY INTERFACE_COMPILE_OPTIONS ${OpenMP_CXX_FLAGS}) set_property(TARGET OpenMP::OpenMP_CXX PROPERTY INTERFACE_LINK_LIBRARIES ${OpenMP_CXX_FLAGS} Threads::Threads) endif() endif() # MPI set(MPI_HOME ${ROCALUTION_MPI_DIR}) find_package(MPI) if (NOT MPI_FOUND) message("-- MPI not found. Compiling WITHOUT MPI support.") if (SUPPORT_MPI) message(FATAL_ERROR "Cannot build with MPI support.") endif() else() option(SUPPORT_MPI "Compile WITH MPI support." OFF) if(NOT TARGET MPI::MPI_CXX) # cmake fix for cmake <= 3.9 add_library(MPI::MPI_CXX IMPORTED INTERFACE) set_property(TARGET MPI::MPI_CXX PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_CXX_COMPILE_OPTIONS}") set_property(TARGET MPI::MPI_CXX PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_CXX_COMPILE_DEFINITIONS}") set_property(TARGET MPI::MPI_CXX PROPERTY INTERFACE_LINK_LIBRARIES "") if(MPI_CXX_LINK_FLAGS) set_property(TARGET MPI::MPI_CXX APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_CXX_LINK_FLAGS}") endif() if(MPI_CXX_LIBRARIES) set_property(TARGET MPI::MPI_CXX APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_CXX_LIBRARIES}") endif() set_property(TARGET MPI::MPI_CXX PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_CXX_INCLUDE_DIRS}") endif() endif() # ROCm cmake package set(PROJECT_EXTERN_DIR ${CMAKE_CURRENT_BINARY_DIR}/extern) find_package(ROCM 0.7.3 QUIET CONFIG PATHS ${CMAKE_PREFIX_PATH}) if(NOT ROCM_FOUND) set(rocm_cmake_tag "master" CACHE STRING "rocm-cmake tag to download") file(DOWNLOAD https://github.com/RadeonOpenCompute/rocm-cmake/archive/${rocm_cmake_tag}.zip ${PROJECT_EXTERN_DIR}/rocm-cmake-${rocm_cmake_tag}.zip STATUS status LOG log) list(GET status 0 status_code) list(GET status 1 status_string) if(NOT status_code EQUAL 0) message(FATAL_ERROR "error: downloading 'https://github.com/RadeonOpenCompute/rocm-cmake/archive/${rocm_cmake_tag}.zip' failed status_code: ${status_code} status_string: ${status_string} log: ${log} ") endif() execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_EXTERN_DIR}/rocm-cmake-${rocm_cmake_tag}.zip WORKING_DIRECTORY ${PROJECT_EXTERN_DIR}) execute_process( COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${PROJECT_EXTERN_DIR}/rocm-cmake . WORKING_DIRECTORY ${PROJECT_EXTERN_DIR}/rocm-cmake-${rocm_cmake_tag} ) execute_process( COMMAND ${CMAKE_COMMAND} --build rocm-cmake-${rocm_cmake_tag} --target install WORKING_DIRECTORY ${PROJECT_EXTERN_DIR}) find_package(ROCM 0.7.3 REQUIRED CONFIG PATHS ${PROJECT_EXTERN_DIR}/rocm-cmake) endif() include(ROCMSetupVersion) include(ROCMCreatePackage) include(ROCMInstallTargets) include(ROCMPackageConfigHelpers) include(ROCMInstallSymlinks) include(ROCMCheckTargetIds OPTIONAL) include(ROCMHeaderWrapper) include(ROCMClients) rocALUTION-rocm-5.7.1/cmake/Packaging.cmake000066400000000000000000000057241445302240700202600ustar00rootroot00000000000000# ######################################################################## # Copyright (C) 2019-2020 Advanced Micro Devices, Inc. All rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ######################################################################## # Client packaging include(CMakeParseArguments) function(rocm_create_package_clients) set(options) set(oneValueArgs LIB_NAME DESCRIPTION SECTION MAINTAINER VERSION) set(multiValueArgs DEPENDS) cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) string(CONCAT PACKAGE_NAME ${PARSE_LIB_NAME} "-clients-" ${PARSE_VERSION} "-Linux.deb") string(CONCAT DEB_CONTROL_FILE_CONTENT "Package: " ${PARSE_LIB_NAME} "-clients" "\nVersion: " ${PARSE_VERSION} "\nSection: " ${PARSE_SECTION} "\nPriority: optional" "\nArchitecture: amd64" "\nMaintainer: " ${PARSE_MAINTAINER} "\nDescription: " ${PARSE_DESCRIPTION} "\nDepends: " ${PARSE_LIB_NAME} "(>=" ${PARSE_VERSION} ")\n\n") if(EXISTS "${PROJECT_BINARY_DIR}/package") file(REMOVE_RECURSE "${PROJECT_BINARY_DIR}/package") endif() file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/package/${ROCM_PATH}/${PARSE_LIB_NAME}/bin") file(WRITE "${PROJECT_BINARY_DIR}/package/DEBIAN/control" ${DEB_CONTROL_FILE_CONTENT}) add_custom_target(package_clients COMMAND ${CMAKE_COMMAND} -E remove -f "${PROJECT_BINARY_DIR}/package/${ROCM_PATH}/${PARSE_LIB_NAME}/bin/*" COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_BINARY_DIR}/staging/*" "${PROJECT_BINARY_DIR}/package/${ROCM_PATH}/${PARSE_LIB_NAME}/bin" COMMAND dpkg -b "${PROJECT_BINARY_DIR}/package/" ${PACKAGE_NAME}) endfunction(rocm_create_package_clients) rocALUTION-rocm-5.7.1/cmake/Verbose.cmake000066400000000000000000000104311445302240700177700ustar00rootroot00000000000000# ######################################################################## # Copyright (C) 2021 Advanced Micro Devices, Inc. All rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ######################################################################## message(STATUS "==========================================") message(STATUS "\t==>rocalution_VERSION : ${rocalution_VERSION}") message(STATUS "\t==>CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}") message(STATUS "\t==>BUILD_SHARED_LIBS : ${BUILD_SHARED_LIBS}") message(STATUS "\t==>CMAKE_INSTALL_PREFIX link : ${CMAKE_INSTALL_PREFIX}") message(STATUS "\t==>CMAKE_MODULE_PATH link : ${CMAKE_MODULE_PATH}") message(STATUS "\t==>CMAKE_PREFIX_PATH link : ${CMAKE_PREFIX_PATH}") message(STATUS "==============") message(STATUS "\t==>CMAKE_SYSTEM_NAME : ${CMAKE_SYSTEM_NAME}") message(STATUS "\t>>=HIP_ROOT_DIR : ${HIP_ROOT_DIR}") message(STATUS "\t==>CMAKE_CXX_COMPILER : ${CMAKE_CXX_FLAGS}") message(STATUS "\t==>CMAKE_CXX_COMPILER_VERSION : ${CMAKE_CXX_COMPILER_VERSION}") message(STATUS "\t==>CMAKE_CXX_COMPILER debug : ${CMAKE_CXX_FLAGS_DEBUG}") message(STATUS "\t==>CMAKE_CXX_COMPILER release : ${CMAKE_CXX_FLAGS_RELEASE}") message(STATUS "\t==>CMAKE_CXX_COMPILER relwithdebinfo : ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") message(STATUS "\t==>CMAKE_EXE_LINKER_FLAGS : ${CMAKE_EXE_LINKER_FLAGS}") message(STATUS "\t==>CMAKE_EXE_LINKER_FLAGS_RELEASE : ${CMAKE_EXE_LINKER_FLAGS_RELEASE}") message(STATUS "\t==>CMAKE_SHARED_LINKER_FLAGS : ${CMAKE_SHARED_LINKER_FLAGS}") message(STATUS "\t==>CMAKE_SHARED_LINKER_FLAGS_RELEASE : ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") message(STATUS "==============" ) message(STATUS "\t==>CMAKE_SHARED_LIBRARY_C_FLAGS : ${CMAKE_SHARED_LIBRARY_C_FLAGS}") message(STATUS "\t==>CMAKE_SHARED_LIBRARY_CXX_FLAGS : ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") message(STATUS "\t==>CMAKE_SHARED_LINKER_FLAGS : ${CMAKE_SHARED_LINKER_FLAGS}") message(STATUS "\t==>CMAKE_SHARED_LINKER_FLAGS_DEBUG : ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") message(STATUS "\t==>CMAKE_SHARED_LINKER_FLAGS_RELEASE : ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") message(STATUS "==============" ) message(STATUS "\t==>SUPPORT_HIP : ${SUPPORT_HIP}") if(SUPPORT_HIP) message(STATUS "\t\t-->HIP_VERSION : ${HIP_VERSION}") endif() message(STATUS "\t==>SUPPORT_OMP : ${SUPPORT_OMP}") if(SUPPORT_OMP) message(STATUS "\t\t-->OpenMP_CXX_VERSION : ${OpenMP_CXX_VERSION}") message(STATUS "\t\t-->OpenMP_CXX_LIBRARIES : ${OpenMP_CXX_LIBRARIES}") endif() message(STATUS "\t==>SUPPORT_MPI : ${SUPPORT_MPI}") if(SUPPORT_MPI) message(STATUS "\t\t-->MPI_CXX_VERSION : ${MPI_CXX_VERSION}") message(STATUS "\t\t-->MPI_CXX_LIBRARIES : ${MPI_CXX_LIBRARIES}") endif() message(STATUS "==============" ) message(STATUS "\t==>BUILD_CLIENTS_TESTS : ${BUILD_CLIENTS_TESTS}") message(STATUS "\t==>BUILD_CLIENTS_SAMPLES : ${BUILD_CLIENTS_SAMPLES}") message(STATUS "==============" ) message(STATUS "==========================================") message(STATUS "\t==>AMDGPU_TARGETS : ${AMDGPU_TARGETS}") rocALUTION-rocm-5.7.1/cmake/get-cli-arguments.cmake000066400000000000000000000020001445302240700217030ustar00rootroot00000000000000# Attempt (best effort) to return a list of user specified parameters cmake was invoked with # NOTE: Even if the user specifies CMAKE_INSTALL_PREFIX on the command line, the parameter is # not returned because it does not have the matching helpstring function( append_cmake_cli_arguments initial_cli_args return_cli_args ) # Retrieves the contents of CMakeCache.txt get_cmake_property( cmake_properties CACHE_VARIABLES ) foreach( property ${cmake_properties} ) get_property(help_string CACHE ${property} PROPERTY HELPSTRING ) # Properties specified on the command line have boilerplate text if( help_string MATCHES "variable specified on the command line" ) # message( STATUS "property: ${property}") # message( STATUS "value: ${${property}}") list( APPEND cli_args "-D${property}=${${property}}") endif( ) endforeach( ) # message( STATUS "get_command_line_arguments: ${cli_args}") set( ${return_cli_args} ${${initial_cli_args}} ${cli_args} PARENT_SCOPE ) endfunction( ) rocALUTION-rocm-5.7.1/custom.properties000066400000000000000000000001411445302240700177260ustar00rootroot00000000000000booktitle=rocALUTION API Guide spreadsheet.xml=docs/classification-map.xml document.locale=enusrocALUTION-rocm-5.7.1/deps/000077500000000000000000000000001445302240700152355ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/deps/CMakeLists.txt000066400000000000000000000066231445302240700200040ustar00rootroot00000000000000# ######################################################################## # Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ######################################################################## # Helper cmake script to automate building dependencies for rocsparse # This script can be invoked manually by the user with 'cmake -P' # The ROCm platform requires Ubuntu 16.04 or Fedora 24, which has cmake 3.5 cmake_minimum_required( VERSION 3.5 ) list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake ) # Consider removing this in the future # It can be annoying for visual studio developers to build a project that tries to install into 'program files' if( WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) set( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories" FORCE ) endif( ) # This has to be initialized before the project() command appears # Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE if( NOT DEFINED CMAKE_CONFIGURATION_TYPES AND NOT DEFINED CMAKE_BUILD_TYPE ) set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." ) endif() # The superbuild does not build anything itself; all compiling is done in external projects project( rocsparse-dependencies NONE ) option( BUILD_GTEST "Download and build googletest library" OFF ) # option( BUILD_VERBOSE "Print helpful build debug information" OFF ) # This module scrapes the CMakeCache.txt file and attempts to get all the cli options the user specified to cmake invocation include( get-cli-arguments ) # The following is a series of super-build projects; this cmake project will download and build if( BUILD_GTEST ) include( external-gtest ) list( APPEND rocsparse_dependencies googletest ) set( gtest_custom_target COMMAND cd ${GTEST_BINARY_ROOT}$ ${CMAKE_COMMAND} --build . --target install ) endif( ) # POLICY CMP0037 - "Target names should not be reserved and should match a validity pattern" # Familiar target names like 'install' should be OK at the super-build level if( POLICY CMP0037 ) cmake_policy( SET CMP0037 OLD ) endif( ) add_custom_target( install ${gtest_custom_target} DEPENDS ${rocsparse_dependencies} ) rocALUTION-rocm-5.7.1/deps/external-gtest.cmake000066400000000000000000000115231445302240700212070ustar00rootroot00000000000000# ######################################################################## # Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ######################################################################## message( STATUS "Configuring gtest external dependency" ) include( ExternalProject ) # set( gtest_cmake_args -DCMAKE_INSTALL_PREFIX=/package ) set( PREFIX_GTEST ${CMAKE_INSTALL_PREFIX} CACHE PATH "Location where boost should install, defaults to /usr/local" ) set( gtest_cmake_args -DCMAKE_INSTALL_PREFIX=${PREFIX_GTEST} -DBUILD_SHARED_LIBS=OFF ) append_cmake_cli_arguments( gtest_cmake_args gtest_cmake_args ) set( gtest_git_repository "https://github.com/google/googletest.git" CACHE STRING "URL to download gtest from" ) set( gtest_git_tag "release-1.8.0" CACHE STRING "URL to download gtest from" ) if( MSVC ) list( APPEND gtest_cmake_args -Dgtest_force_shared_crt=ON -DCMAKE_DEBUG_POSTFIX=d ) # else( ) # GTEST_USE_OWN_TR1_TUPLE necessary to compile with hipcc # list( APPEND gtest_cmake_args -DGTEST_USE_OWN_TR1_TUPLE=1 ) endif( ) if( CMAKE_CONFIGURATION_TYPES ) set( gtest_make COMMAND ${CMAKE_COMMAND} --build --config Release COMMAND ${CMAKE_COMMAND} --build --config Debug ) else( ) # Add build thread in addition to the number of cores that we have include( ProcessorCount ) ProcessorCount( Cores ) # If we are not using an IDE, assume nmake with visual studio if( MSVC ) set( gtest_make "nmake" ) else( ) set( gtest_make "make" ) # The -j paramter does not work with nmake if( NOT Cores EQUAL 0 ) math( EXPR Cores "${Cores} + 1 " ) list( APPEND gtest_make -j ${Cores} ) else( ) # If we could not detect # of cores, assume 1 core and add an additional build thread list( APPEND gtest_make -j 2 ) endif( ) endif( ) message( STATUS "ExternalGmock using ( " ${Cores} " ) cores to build with" ) endif( ) # message( STATUS "gtest_make ( " ${gtest_make} " ) " ) # message( STATUS "gtest_cmake_args ( " ${gtest_cmake_args} " ) " ) # Master branch has a new structure that combines googletest with googlemock ExternalProject_Add( googletest PREFIX ${CMAKE_BINARY_DIR}/gtest GIT_REPOSITORY ${gtest_git_repository} GIT_TAG ${gtest_git_tag} CMAKE_ARGS ${gtest_cmake_args} BUILD_COMMAND ${gtest_make} LOG_BUILD 1 INSTALL_COMMAND "" LOG_INSTALL 1 ) ExternalProject_Get_Property( googletest source_dir ) # For visual studio, the path 'debug' is hardcoded because that is the default VS configuration for a build. # Doesn't matter if its the gtest or gtestd project above set( package_dir "${PREFIX_GTEST}" ) if( CMAKE_CONFIGURATION_TYPES ) # Create a package by bundling libraries and header files if( BUILD_64 ) set( LIB_DIR lib64 ) else( ) set( LIB_DIR lib ) endif( ) set( gtest_lib_dir "/${LIB_DIR}" ) ExternalProject_Add_Step( googletest createPackage COMMAND ${CMAKE_COMMAND} -E copy_directory ${gtest_lib_dir}/Debug ${package_dir}/${LIB_DIR} COMMAND ${CMAKE_COMMAND} -E copy_directory ${gtest_lib_dir}/Release ${package_dir}/${LIB_DIR} COMMAND ${CMAKE_COMMAND} -E copy_directory ${gtest_lib_dir}/Debug ${package_dir}/${LIB_DIR} COMMAND ${CMAKE_COMMAND} -E copy_directory ${gtest_lib_dir}/Release ${package_dir}/${LIB_DIR} COMMAND ${CMAKE_COMMAND} -E copy_directory /include ${package_dir}/include COMMAND ${CMAKE_COMMAND} -E copy_directory /gtest/include/gtest ${package_dir}/include/gtest DEPENDEES install ) endif( ) set_property( TARGET googletest PROPERTY FOLDER "extern") ExternalProject_Get_Property( googletest install_dir ) ExternalProject_Get_Property( googletest binary_dir ) # For use by the user of ExternalGtest.cmake set( GTEST_INSTALL_ROOT ${install_dir} ) set( GTEST_BINARY_ROOT ${binary_dir} ) rocALUTION-rocm-5.7.1/docs/000077500000000000000000000000001445302240700152325ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/docs/.doxygen/000077500000000000000000000000001445302240700167655ustar00rootroot00000000000000rocALUTION-rocm-5.7.1/docs/.doxygen/Doxyfile000066400000000000000000003227651445302240700205120ustar00rootroot00000000000000# Doxyfile 1.8.10 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a double hash (##) is considered a comment and is placed in # front of the TAG it is preceding. # # All text after a single hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all text # before the first occurrence of this tag. Doxygen uses libiconv (or the iconv # built into libc) for the transcoding. See http://www.gnu.org/software/libiconv # for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by # double-quotes, unless you are using Doxywizard) that should identify the # project for which the documentation is generated. This name is used in the # title of most generated pages and in a few other places. # The default value is: My Project. PROJECT_NAME = "rocALUTION" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. PROJECT_NUMBER = v2.0.2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "prototype interfaces compatible with ROCm platform and HiP" # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. OUTPUT_DIRECTORY = docBin # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and # will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes # performance problems for the file system. # The default value is: NO. CREATE_SUBDIRS = NO # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode # U+3044. # The default value is: NO. ALLOW_UNICODE_NAMES = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, # Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), # Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, # Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), # Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, # Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, # Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, # Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # description of a member or function before the detailed description # # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. # The default value is: YES. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator that is # used to form the text in various listings. Each string in this list, if found # as the leading text of the brief description, will be stripped from the text # and the result, after processing the whole list, is used as the annotated # text. Otherwise, the brief description is used as-is. If left blank, the # following values are used ($name is automatically replaced with the name of # the entity):The $name class, The $name widget, The $name file, is, provides, # specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # doxygen will generate a detailed section even if there is only a brief # description. # The default value is: NO. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. # The default value is: NO. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the # shortest path that makes the file name unique will be used # The default value is: YES. FULL_PATH_NAMES = YES # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand # part of the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the path to # strip. # # Note that you can specify absolute paths here, but also relative paths, which # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which # header file to include in order to use a class. If left blank only the name of # the header file containing the class definition is used. Otherwise one should # specify the list of include paths that are normally passed to the compiler # using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't # support long names like on DOS, Mac, or CD-ROM. # The default value is: NO. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the # first line (until the first dot) of a Javadoc-style comment as the brief # description. If set to NO, the Javadoc-style will behave just like regular Qt- # style comments (thus requiring an explicit @brief command for a brief # description.) # The default value is: NO. JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus # requiring an explicit \brief command for a brief description.) # The default value is: NO. QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a # multi-line C++ special comment block (i.e. a block of //! or /// comments) as # a brief description. This used to be the default behavior. The new default is # to treat a multi-line C++ comment block as a detailed description. Set this # tag to YES if you prefer the old behavior instead. # # Note that setting this tag to YES also means that rational rose comments are # not recognized any more. # The default value is: NO. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new # page for each member. If set to NO, the documentation of a member will be part # of the file/class/namespace that contains it. # The default value is: NO. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen # uses this value to replace tabs by spaces in code fragments. # Minimum value: 1, maximum value: 16, default value: 4. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that act as commands in # the documentation. An alias has the form: # name=value # For example adding # "sideeffect=@par Side Effects:\n" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" # will allow you to use the command class in the itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all # members will be omitted, etc. # The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored # for that language. For instance, namespaces will be presented as packages, # qualified scopes will look different, etc. # The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources. Doxygen will then generate output that is tailored for Fortran. # The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for VHDL. # The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and # language is one of the parsers supported by doxygen: IDL, Java, Javascript, # C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: # FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: # Fortran. In the later case the parser tries to guess whether the code is fixed # or free formatted code, this is the default for Fortran type files), VHDL. For # instance to make doxygen treat .inc files as Fortran files (default is PHP), # and .f files as C (default is Fortran), use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. # The default value is: YES. MARKDOWN_SUPPORT = YES # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should set this # tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); # versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. # The default value is: NO. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. # The default value is: NO. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES will make # doxygen to replace the get and set methods by a property in the documentation. # This will only work if the methods are indeed getting or setting a simple # type. If this is not the case, or you want to show the methods anyway, you # should set this option to NO. # The default value is: YES. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. # The default value is: NO. DISTRIBUTE_GROUP_DOC = YES # If one adds a struct or class to a group and this option is enabled, then also # any nested class or struct is added to the same group. By default this option # is disabled and one has to add nested compounds explicitly via \ingroup. # The default value is: NO. GROUP_NESTED_COMPOUNDS = NO # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that # type (e.g. under the Public Functions section). Set it to NO to prevent # subgrouping. Alternatively, this can be done per class using the # \nosubgrouping command. # The default value is: YES. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions # are shown inside the group in which they are included (e.g. using \ingroup) # instead of on a separate page (for HTML and Man pages) or section (for LaTeX # and RTF). # # Note that this feature does not work in combination with # SEPARATE_MEMBER_PAGES. # The default value is: NO. INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions # with only public data fields or simple typedef fields will be shown inline in # the documentation of the scope in which they are defined (i.e. file, # namespace, or group documentation), provided this scope is documented. If set # to NO, structs, classes, and unions are shown on a separate page (for HTML and # Man pages) or section (for LaTeX and RTF). # The default value is: NO. INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically be # useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. # The default value is: NO. TYPEDEF_HIDES_STRUCT = YES # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This # cache is used to resolve symbols given their name and scope. Since this can be # an expensive process and often the same symbol appears multiple times in the # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small # doxygen will become slower. If the cache is too large, memory is wasted. The # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range # is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 # symbols. At the end of a run doxygen will report the cache usage and suggest # the optimal cache size from a speed point of view. # Minimum value: 0, maximum value: 9, default value: 0. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- SHOW_NAMESPACES = NO # If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in # documentation are documented, even if no documentation was available. Private # class members and static file members will be hidden unless the # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. # Note: This will also disable the warnings about undocumented members that are # normally produced when WARNINGS is set to YES. # The default value is: NO. EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES, all static members of a file will be # included in the documentation. # The default value is: NO. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, # only classes defined in header files are included. Does not have any effect # for Java sources. # The default value is: YES. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are # included in the documentation. If set to NO, only methods in the interface are # included. # The default value is: NO. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base name of # the file that contains the anonymous namespace. By default anonymous namespace # are hidden. # The default value is: NO. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation # section is generated. This option has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option # has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # (class|struct|union) declarations. If set to NO, these declarations will be # included in the documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any # documentation blocks found inside the body of a function. If set to NO, these # blocks will be appended to the function's detailed documentation block. # The default value is: NO. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation that is typed after a # \internal command is included. If the tag is set to NO then the documentation # will be excluded. Set it to YES to include the internal documentation. # The default value is: NO. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file # names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. # The default value is: system dependent. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the # scope will be hidden. # The default value is: NO. HIDE_SCOPE_NAMES = NO # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will # append additional text to a page's title, such as Class Reference. If set to # YES the compound reference will be hidden. # The default value is: NO. HIDE_COMPOUND_REFERENCE= NO # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. SHOW_INCLUDE_FILES = YES # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each # grouped member an include statement to the documentation, telling the reader # which file to include in order to use the member. # The default value is: NO. SHOW_GROUPED_MEMB_INC = NO # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include # files with double quotes in the documentation rather than with sharp brackets. # The default value is: NO. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the # documentation for inline members. # The default value is: YES. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the # (detailed) documentation of file and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. # The default value is: YES. SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. Note that # this will also influence the order of the classes in the class list. # The default value is: NO. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the # (brief and detailed) documentation of class members so that constructors and # destructors are listed first. If set to NO the constructors will appear in the # respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. # Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief # member documentation. # Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting # detailed member documentation. # The default value is: NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy # of group names into alphabetical order. If set to NO the group names will # appear in their defined order. # The default value is: NO. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will # be sorted only by class name, not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the alphabetical # list. # The default value is: NO. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper # type resolution of all parameters of a function it will reject a match between # the prototype and the implementation of a member function even if there is # only one candidate or it is obvious which candidate to choose by doing a # simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still # accept a match between prototype and implementation in such cases. # The default value is: NO. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo # list. This list is created by putting \todo commands in the documentation. # The default value is: YES. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test # list. This list is created by putting \test commands in the documentation. # The default value is: YES. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug # list. This list is created by putting \bug commands in the documentation. # The default value is: YES. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) # the deprecated list. This list is created by putting \deprecated commands in # the documentation. # The default value is: YES. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional documentation # sections, marked by \if ... \endif and \cond # ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the # documentation. If the initializer consists of more lines than specified here # it will be hidden. Use a value of 0 to hide initializers completely. The # appearance of the value of individual variables and macros / defines can be # controlled using \showinitializer or \hideinitializer command in the # documentation regardless of this setting. # Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at # the bottom of the documentation of classes and structs. If set to YES, the # list will mention the files that were used to generate the documentation. # The default value is: YES. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This # will remove the Files entry from the Quick Index and from the Folder Tree View # (if specified). # The default value is: YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # page. This will remove the Namespaces entry from the Quick Index and from the # Folder Tree View (if specified). # The default value is: YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command command input-file, where command is the value of the # FILE_VERSION_FILTER tag, and input-file is the name of an input file provided # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml # will be used as the name of the layout file. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool # to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated to # standard output by doxygen. If QUIET is set to YES this implies that the # messages are off. # The default value is: NO. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated to standard error (stderr) by doxygen. If WARNINGS is set to YES # this implies that the warnings are on. # # Tip: Turn warnings on while writing the documentation. # The default value is: YES. WARNINGS = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag # will automatically be disabled. # The default value is: YES. WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters # in a documented function, or documenting parameters that don't exist or using # markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete # parameter documentation, but not about the absence of documentation. # The default value is: NO. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) # The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard # error (stderr). WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag is used to specify the files and/or directories that contain # documented source files. You may enter file names like myfile.cpp or # directories like /usr/src/myproject. Separate the files or directories with # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. INPUT = modules.dox \ ../../src/base/backend_manager.hpp \ ../../src/base/parallel_manager.hpp \ ../../src/utils/allocate_free.hpp \ ../../src/utils/time_functions.hpp \ ../../src/base/operator.hpp \ ../../src/base/vector.hpp \ ../../src/base/base_rocalution.hpp \ ../../src/base/local_vector.hpp \ ../../src/base/global_vector.hpp \ ../../src/base/local_matrix.hpp \ ../../src/base/global_matrix.hpp \ ../../src/base/local_stencil.hpp \ ../../src/solvers \ ../../src/solvers/krylov \ ../../src/solvers/direct \ ../../src/solvers/multigrid \ ../../src/solvers/preconditioners # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: http://www.gnu.org/software/libiconv) for the list of # possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, # *.vhdl, *.ucf, *.qsf, *.as and *.js. FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ *.c++ \ *.java \ *.ii \ *.ixx \ *.ipp \ *.i++ \ *.inl \ *.idl \ *.ddl \ *.odl \ *.h \ *.hh \ *.hxx \ *.hpp \ *.h++ \ *.cs \ *.d \ *.php \ *.php4 \ *.php5 \ *.phtml \ *.inc \ *.m \ *.markdown \ *.md \ *.mm \ *.dox \ *.py \ *.f90 \ *.f \ *.for \ *.tcl \ *.vhd \ *.vhdl \ *.ucf \ *.qsf \ *.as \ *.js # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. # The default value is: NO. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. # The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and # *.h) to filter out the source-files in the directories. If left blank all # files are included. EXAMPLE_PATTERNS = * # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude commands # irrespective of the value of the RECURSIVE tag. # The default value is: NO. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or directories # that contain images that are to be included in the documentation (see the # \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command: # # # # where is the value of the INPUT_FILTER tag, and is the # name of an input file. Doxygen will then use the output that the filter # program writes to standard output. If FILTER_PATTERNS is specified, this tag # will be ignored. # # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: pattern=filter # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will also be used to filter the input files that are used for # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). # The default value is: NO. FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) and # it is also possible to disable source filtering for a specific pattern using # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = ../README.md #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will be # generated. Documented entities will be cross-referenced with these sources. # # Note: To get rid of all source code in the generated output, make sure that # also VERBATIM_HEADERS is set to NO. # The default value is: NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body of functions, # classes and enums directly into the documentation. # The default value is: NO. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any # special comment blocks from generated source code fragments. Normal C, C++ and # Fortran comments will always remain visible. # The default value is: YES. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented # function all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES then for each documented function # all documented entities called/used by that function will be listed. # The default value is: NO. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set # to YES then the hyperlinks from functions in REFERENCES_RELATION and # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will # link to the documentation. # The default value is: YES. REFERENCES_LINK_SOURCE = YES # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the # source code will show a tooltip with additional information such as prototype, # brief description and links to the definition and documentation. Since this # will make the HTML file larger and loading of large files a bit slower, you # can opt to disable this feature. # The default value is: YES. # This tag requires that the tag SOURCE_BROWSER is set to YES. SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system # (see http://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global # - Enable SOURCE_BROWSER and USE_HTAGS in the config file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # # Doxygen will invoke htags (and that will in turn invoke gtags), so these # tools must be available from the command line (i.e. in the search path). # # The result: instead of the source browser generated by doxygen, the links to # source code will now point to the output of htags. # The default value is: NO. # This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a # verbatim copy of the header file for each class for which an include is # specified. Set to NO to disable this. # See also: Section \class. # The default value is: YES. VERBATIM_HEADERS = YES # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the # clang parser (see: http://clang.llvm.org/) for more accurate parsing at the # cost of reduced performance. This can be particularly helpful with template # rich C++ code for which doxygen's built-in parser lacks the necessary type # information. # Note: The availability of this option depends on whether or not doxygen was # compiled with the --with-libclang option. # The default value is: NO. CLANG_ASSISTED_PARSING = NO # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that # the include paths will already be set by doxygen for the files and directories # specified with INPUT and INCLUDE_PATH. # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. CLANG_OPTIONS = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all # compounds will be generated. Enable this if the project contains a lot of # classes, structs, unions or interfaces. # The default value is: YES. ALPHABETICAL_INDEX = YES # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in # which the alphabetical index list will be split. # Minimum value: 1, maximum value: 20, default value: 5. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). # The default value is: .html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a user-defined HTML header file for # each generated HTML page. If the tag is left blank doxygen will generate a # standard header. # # To get valid HTML the header file that includes any scripts and style sheets # that doxygen needs, which is dependent on the configuration options used (e.g. # the setting GENERATE_TREEVIEW). It is highly recommended to start with a # default header using # doxygen -w html new_header.html new_footer.html new_stylesheet.css # YourConfigFile # and then modify the file new_header.html. See also section "Doxygen usage" # for information on how to generate the default header that doxygen normally # uses. # Note: The header is subject to change so you typically have to regenerate the # default header when upgrading to a newer version of doxygen. For a description # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard # footer. See HTML_HEADER for more information on how to generate a default # footer and what special commands can be used inside the footer. See also # section "Doxygen usage" for information on how to generate the default footer # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of # the HTML output. If left blank doxygen will generate a default style sheet. # See also section "Doxygen usage" for information on how to generate the style # sheet that doxygen normally uses. # Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as # it is more robust and this tag (HTML_STYLESHEET) will in the future become # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the # standard style sheet and is therefore more robust against future updates. # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that the # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see # http://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors # in the HTML output. For a value of 0 the output will use grayscales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the # luminance component of the colors in the HTML output. Values below 100 # gradually make the output lighter, whereas values above 100 make the output # darker. The value divided by 100 is the actual gamma applied, so 80 represents # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not # change the gamma. # Minimum value: 40, maximum value: 240, default value: 80. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this # to YES can help to show when doxygen was last run and thus if the # documentation is up to date. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand # and collapse entries dynamically later on. Doxygen will expand the tree to # such a level that at most the specified number of entries are visible (unless # a fully collapsed tree already exceeds this amount). So setting the number of # entries 1 will produce a full collapsed tree by default. 0 is a special value # representing an infinite number of entries and will result in a full expanded # tree by default. # Minimum value: 0, maximum value: 9999, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development # environment (see: http://developer.apple.com/tools/xcode/), introduced with # OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO # This tag determines the name of the docset feed. A documentation feed provides # an umbrella under which multiple documentation sets from a single provider # (such as a company or product suite) can be grouped. # The default value is: Doxygen generated docs. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project # The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. # The default value is: org.doxygen.Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. # The default value is: Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop # (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on # Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML # files are now used as the Windows 98 help format, and will replace the old # Windows help format (.hlp) on all Windows platforms in the future. Compressed # HTML files also contain an index, a table of contents, and you can search for # words in the documentation. The HTML workshop also contains a viewer for # compressed HTML files. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO # The CHM_FILE tag can be used to specify the file name of the resulting .chm # file. You can add a path in front of the file if the result should not be # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler (hhc.exe). If non-empty, # doxygen will try to run the HTML help compiler on the generated index.hhp. # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated # (YES) or that it should be included in the master .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO # The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it # enables the Previous and Next buttons. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members to # the table of contents of the HTML help documentation and to the tree view. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help # (.qch) of the generated HTML documentation. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify # the file name of the resulting .qch file. The path specified is relative to # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace # (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual # Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- # folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To # install this plugin and make it available under the help contents menu in # Eclipse, the contents of the directory containing the HTML and XML files needs # to be copied into the plugins directory of eclipse. The name of the directory # within the plugins directory should be the same as the ECLIPSE_DOC_ID value. # After copying Eclipse needs to be restarted before the help appears. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO # A unique identifier for the Eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have this # name. Each documentation set should have its own identifier. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project # If you want full control over the layout of the generated HTML pages it might # be necessary to disable the index and replace it with your own. The # DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top # of each HTML page. A value of NO enables the index and the value YES disables # it. Since the tabs in the index contain the same information as the navigation # tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. If the tag # value is set to YES, a side panel will be generated containing a tree-like # index structure (just like the one that is generated for HTML Help). For this # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can # further fine-tune the look of the index. As an example, the default style # sheet generated by doxygen has an example that shows how to put an image at # the root of the tree instead of the PROJECT_NAME. Since the tree basically has # the same information as the tab index, you could consider setting # DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # # Note that a value of 0 will completely suppress the enum values from appearing # in the overview section. # Minimum value: 0, maximum value: 20, default value: 4. # This tag requires that the tag GENERATE_HTML is set to YES. ENUM_VALUES_PER_LINE = 1 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used # to set the initial width (in pixels) of the frame in which the tree is shown. # Minimum value: 0, maximum value: 1500, default value: 250. # This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 250 # If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to # external symbols imported via tag files in a separate window. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML # output directory to force them to be regenerated. # Minimum value: 8, maximum value: 50, default value: 10. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # # Note that when changing this option you need to delete any form_*.png files in # the HTML output directory before the changes have effect. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # http://www.mathjax.org) which uses client side Javascript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path # to it using the MATHJAX_RELPATH option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = YES # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: # http://docs.mathjax.org/en/latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the HTML # output directory using the MATHJAX_RELPATH option. The destination directory # should contain the MathJax.js script. For instance, if the mathjax directory # is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from http://www.mathjax.org before deployment. # The default value is: http://cdn.mathjax.org/mathjax/latest. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site # (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and # should work on any modern browser. Note that when using HTML help # (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) # there is already a search function so this one should typically be disabled. # For large projects the javascript based search engine can be slow, then # enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to # search using the keyboard; to jump to the search box use + S # (what the is depends on the OS and browser, but it is typically # , /