pax_global_header 0000666 0000000 0000000 00000000064 15073773325 0014526 g ustar 00root root 0000000 0000000 52 comment=b0adf826d3ea50e695a4a0425f74fd85c17fa931
rocALUTION-rocm-7.1.0/ 0000775 0000000 0000000 00000000000 15073773325 0014310 5 ustar 00root root 0000000 0000000 rocALUTION-rocm-7.1.0/.azuredevops/ 0000775 0000000 0000000 00000000000 15073773325 0016735 5 ustar 00root root 0000000 0000000 rocALUTION-rocm-7.1.0/.azuredevops/rocm-ci.yml 0000664 0000000 0000000 00000001244 15073773325 0021012 0 ustar 00root root 0000000 0000000 resources:
repositories:
- repository: pipelines_repo
type: github
endpoint: ROCm
name: ROCm/ROCm
variables:
- group: common
- template: /.azuredevops/variables-global.yml@pipelines_repo
trigger:
batch: true
branches:
include:
- develop
- mainline
paths:
exclude:
- .githooks
- .github
- .jenkins
- docs
- '.*.y*ml'
- '*.md'
pr:
autoCancel: true
branches:
include:
- develop
- mainline
paths:
exclude:
- .githooks
- .github
- .jenkins
- docs
- '.*.y*ml'
- '*.md'
drafts: false
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/rocALUTION.yml@pipelines_repo
rocALUTION-rocm-7.1.0/.clang-format 0000664 0000000 0000000 00000006542 15073773325 0016672 0 ustar 00root root 0000000 0000000 # 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-7.1.0/.githooks/ 0000775 0000000 0000000 00000000000 15073773325 0016215 5 ustar 00root root 0000000 0000000 rocALUTION-rocm-7.1.0/.githooks/install 0000775 0000000 0000000 00000000223 15073773325 0017606 0 ustar 00root root 0000000 0000000 #!/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-7.1.0/.githooks/pre-commit 0000775 0000000 0000000 00000004120 15073773325 0020214 0 ustar 00root root 0000000 0000000 #!/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-7.1.0/.github/ 0000775 0000000 0000000 00000000000 15073773325 0015650 5 ustar 00root root 0000000 0000000 rocALUTION-rocm-7.1.0/.github/CODEOWNERS 0000775 0000000 0000000 00000000316 15073773325 0017246 0 ustar 00root root 0000000 0000000 * @ntrost57 @YvanMokwinski @jsandham @kliegeois
# Documentation files
docs/* @ROCm/rocm-documentation
*.md @ROCm/rocm-documentation
*.rst @ROCm/rocm-documentation
.readthedocs.yaml @ROCm/rocm-documentation
rocALUTION-rocm-7.1.0/.github/CONTRIBUTING.md 0000664 0000000 0000000 00000022454 15073773325 0020110 0 ustar 00root root 0000000 0000000
# Contributing to rocALUTION #
AMD welcomes contributions to rocALUTION from the community. Whether those contributions are bug reports, bug fixes, documentation additions, performance notes, or other improvements, we value collaboration with our users. We can build better solutions together. Please follow these details to help ensure your contributions will be successfully accepted.
Our code contriubtion guidelines closely follow the model of [GitHub pull-requests](https://help.github.com/articles/using-pull-requests/). This repository follows the [git flow](http://nvie.com/posts/a-successful-git-branching-model/) workflow, which dictates a /master branch where releases are cut, and a /develop branch which serves as an integration branch for new code.
## Issue Discussion ##
Please use the GitHub Issues tab to notify us of issues.
* Use your best judgement for issue creation. If your issue is already listed, upvote the issue and
comment or post to provide additional details, such as how you reproduced this issue.
* If you're not sure if your issue is the same, err on the side of caution and file your issue.
You can add a comment to include the issue number (and link) for the similar issue. If we evaluate
your issue as being the same as the existing issue, we'll close the duplicate.
* If your issue doesn't exist, use the issue template to file a new issue.
* When filing an issue, be sure to provide as much information as possible, including script output so
we can collect information about your configuration. This helps reduce the time required to
reproduce your issue.
* Check your issue regularly, as we may require additional information to successfully reproduce the
issue.
* You may also open an issue to ask questions to the maintainers about whether a proposed change
meets the acceptance criteria, or to discuss an idea pertaining to the library.
## Acceptance Criteria ##
rocALUTION is a sparse linear algebra library with focus on exploring fine-grained parallelism on top of the AMD 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.
In rocALUTION we are interested in contributions that:
* Fix bugs, improve documentation, enhance testing, reduce complexity.
* Improve the performance of existing routines.
* Add missing functionality such as new multigrid solvers, iterative solvers, direct solvers, or preconditioners.
* Extending new or existing functionality to work with MPI or accelerators (such as GPU devices).
We encourage contributors to leverage the GitHub "Issues" tab to discuss possible additions they would like to add.
### Exceptions ###
rocALUTION places a heavy emphasis on being high performance. Because of this, contributions that add new routines (or that modify existing routines) must do so from the perspective that they offer high performance in relation to the hardware they are run on. Furthermore, all routines added to rocalution must have at a minimum a host solution as all routines must have the ability to fall back to a host solution if a GPU accelerator is not avaiable. Because compile times, binary sizes, and general library complexity are important considerations, we reserve the right to make decisions on whether a proposed routine is too niche or specialized to be worth including.
## Code Structure ##
The following is the structure of the rocALUTION library in the GitHub repository. A more detailed description of the directory structure can be found in the rocALUTION [documentation](https://rocm.docs.amd.com/projects/rocALUTION/en/latest/design/orga.html).
The `src/` directory contains the library source code. This is broken up into three sub-directories:
* `src/base`
* `src/solvers`
* `src/utils`
The `src/base` Contains source code related to rocALUTION's vector, matrix, and stencil operator types as well as classes related to parallel management. This directory is further broken up into:
* `src/base/hip` Contains HIP implementations of vector, matrix, and stencil operators.
* `src/base/host` Contains host implementations of vector, matrix, and stencil operators.
The `src/solvers` directory contains all the source code related to direct (`src/solvers/direct`), krylov (`src/solvers/krylov`), and multigrid solvers `src/solvers/multigrid`.
The `src/utils` directory contains source code related to logging, memory allocation, math and timing functions.
The `clients/` directory contains the testing and benchmarking code as well as all the samples demonstrating rocALUTION usage.
The `docs/` directory contains all of the documentation files.
## Coding Style ##
In general, follow the style of the surrounding code. C and C++ code is formatted using `clang-format`. Use the clang-format version installed with ROCm (found in the `/opt/rocm/llvm/bin` directory). Please do not use your system's built-in `clang-format`, as this is a different version that may result in incorrect results.
To format a file, use:
```
/opt/rocm/llvm/bin/clang-format -style=file -i
```
To format all files, run the following script in rocALUTION directory:
```
#!/bin/bash
git ls-files -z *.cc *.cpp *.h *.hpp *.cl *.h.in *.hpp.in *.cpp.in | xargs -0 /opt/rocm/llvm/bin/clang-format -style=file -i
```
Also, githooks can be installed to format the code per-commit:
```
./.githooks/install
```
## Pull Request Guidelines ##
When you create a pull request, you should target the default branch. Our current default branch is the **develop** branch, which serves as our integration branch.
By submitting a pull request, you acknowlege and agree with the CLA below:
Contribution License Agreement
1. The code I am contributing is mine, and I have the right to license it.
2. By submitting a pull request for this project I am granting you a license to distribute said code under the MIT License for the project.
### Deliverables ###
When raising a PR in rocALUTION here are some important things to include:
1. For each new file in the repository, Please include the licensing header
```
/* ************************************************************************
* Copyright (C) 20xx 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.
*
* ************************************************************************ */
```
and adjust the date to the current year. When simply modifying a file, the date should automatically be updated pre-commit as long as the githook has been installed (./.githooks/install).
2. When adding a new routine, please make sure you are also adding appropriate testing code. These new unit tests should integrate within the existing [googletest framework](https://github.com/google/googletest/blob/master/googletest/docs/primer.md). This typically involves adding the following files:
* testing_.hpp file in the directory `clients/include/`
* test_.cpp file in directory `clients/tests/`
See existing tests for guidance when adding your own.
3. When modifiying an existing routine, add appropriate testing to test_.cpp file in directory `clients/tests/`.
4. Tests must have good code coverage.
5. At a minimum, rocALUTION must have a host solution for each direct, iterative, multigrid, or preconditioner. If you add a accelerator solution (say using HIP targetting GPU devices) please also add a fall back host solution.
6. Ensure code builds successfully. This includes making sure that the code can compile, that the code is properly formatted, and that all tests pass.
7. Do not break existing test cases
### Process ###
When a PR is raised targetting the develop branch in rocALUTION, CI will be automatically triggered. This will:
* Test that the PR passes static analysis (i.e ensure clang formatting rules have been followed).
* Test that the documentation can be properly built
* Ensure that the PR compiles on different OS and GPU device architecture combinations
* Ensure that all tests pass on different OS and GPU device architecture combinations
Feel free to ask questions on your PR regarding any CI failures you encounter.
* Reviewers are listed in the CODEOWNERS file
rocALUTION-rocm-7.1.0/.github/dependabot.yml 0000664 0000000 0000000 00000001260 15073773325 0020477 0 ustar 00root root 0000000 0000000 # 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"
target-branch: "develop"
labels:
- "documentation"
- "dependencies"
- "ci:docs-only"
reviewers:
- "samjwu"
rocALUTION-rocm-7.1.0/.gitignore 0000664 0000000 0000000 00000000610 15073773325 0016275 0 ustar 00root root 0000000 0000000 # 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
# Visual Studio stuff
*.vcxproj.user
*.suo
*.sdf
*.pdb
*.opensdf
rocALUTION-rocm-7.1.0/.jenkins/ 0000775 0000000 0000000 00000000000 15073773325 0016027 5 ustar 00root root 0000000 0000000 rocALUTION-rocm-7.1.0/.jenkins/codecov.groovy 0000664 0000000 0000000 00000004541 15073773325 0020724 0 ustar 00root root 0000000 0000000 #!/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', 'hipBLAS-common', 'hipBLASLt', 'rocBLAS', 'rocSPARSE', '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 = []
propertyList = auxiliary.appendPropertyList(propertyList)
def jobNameList = []
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([], urlJobName)
}
}
}
rocALUTION-rocm-7.1.0/.jenkins/common.groovy 0000664 0000000 0000000 00000012275 15073773325 0020575 0 ustar 00root root 0000000 0000000 // 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, 'develop', 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)
}
def runCoverageCommand (platform, project, gfilter, String dirmode = "release")
{
String commitSha
String repoUrl
(commitSha, repoUrl) = util.getGitHubCommitInformation(project.paths.project_src_prefix)
withCredentials([string(credentialsId: "mathlibs-codecov-token-rocalution", variable: 'CODECOV_TOKEN')])
{
def command = """#!/usr/bin/env bash
set -x
cd ${project.paths.project_build_prefix}/build/${dirmode}
export LD_LIBRARY_PATH=/opt/rocm/lib/
export ROCALUTION_CODE_COVERAGE=1
GTEST_LISTENER=NO_PASS_LINE_IN_LOG make coverage_cleanup coverage GTEST_FILTER=${gfilter}-*known_bug*
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -v -U \$http_proxy -t ${CODECOV_TOKEN} --file lcoverage/main_coverage.info --name rocALUTION --sha ${commitSha}
"""
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-7.1.0/.jenkins/debug.groovy 0000664 0000000 0000000 00000006246 15073773325 0020374 0 ustar 00root root 0000000 0000000 #!/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', 'hipBLAS-common', 'hipBLASLt', 'rocBLAS', 'rocSPARSE', '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-7.1.0/.jenkins/extended.groovy 0000664 0000000 0000000 00000007162 15073773325 0021104 0 ustar 00root root 0000000 0000000 #!/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', 'hipBLAS-common', 'hipBLASLt', 'rocBLAS', 'rocSPARSE', '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-7.1.0/.jenkins/precheckin.groovy 0000664 0000000 0000000 00000007176 15073773325 0021424 0 ustar 00root root 0000000 0000000 #!/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', 'hipBLAS-common', 'hipBLASLt', 'rocBLAS', 'rocSPARSE', '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-7.1.0/.jenkins/staticanalysis.groovy 0000664 0000000 0000000 00000003355 15073773325 0022337 0 ustar 00root root 0000000 0000000 #!/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)
def propertyList = ["compute-rocm-dkms-no-npi-hipclang":[pipelineTriggers([cron('0 1 * * 0')])],
"rocm-docker":[]]
propertyList = auxiliary.appendPropertyList(propertyList)
def jobNameList = ["compute-rocm-dkms-no-npi-hipclang":[]]
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)
}
}
}
rocALUTION-rocm-7.1.0/.jenkins/staticlibrary.groovy 0000664 0000000 0000000 00000007257 15073773325 0022165 0 ustar 00root root 0000000 0000000 #!/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 = 'amdclang++'
prj.compiler.compiler_path = '/opt/rocm/bin/amdclang++'
prj.libraryDependencies = ['rocPRIM', 'hipBLAS-common', 'hipBLASLt', 'rocBLAS', 'rocSPARSE', '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-7.1.0/.readthedocs.yaml 0000664 0000000 0000000 00000000475 15073773325 0017545 0 ustar 00root root 0000000 0000000 # 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, epub]
python:
install:
- requirements: docs/sphinx/requirements.txt
build:
os: ubuntu-22.04
tools:
python: "3.10"
rocALUTION-rocm-7.1.0/CHANGELOG.md 0000664 0000000 0000000 00000020721 15073773325 0016123 0 ustar 00root root 0000000 0000000 # Changelog for rocALUTION
Full documentation forrocALUTION is available at [https://rocm.docs.amd.com/projects/rocALUTION/en/latest/](https://rocm.docs.amd.com/projects/rocALUTION/en/latest/).
## rocALUTION 4.0.1 for ROCm 7.1.0
### Added
* Added support for gfx950.
### Changed
* Updated the default build standard to C++17 when compiling rocALUTION from source (previously C++14).
### Optimized
* Improved and expanded user documentation.
### Resolved issues
* Fixed a bug in the GPU hashing algorithm that occurred when not compiling with -O2/-O3.
* Fixed an issue with the SPAI preconditioner when using complex numbers.
## rocALUTION 3.2.3 for ROCm 6.4.1
### Added
* The `-a` option has been added to the `rmake.py` build script. This option provides a way to select specific architectures when building on Windows.
### Resolved issues
* Fixed an issue where the `HIP_PATH` environment variable was being ignored when compiling on Windows.
## rocALUTION 3.2.2 for ROCm 6.4.0
### Changed
* Improved documentation
## rocALUTION 3.2.1 for ROCm 6.3.0
### Added
* Support for gfx1200, gfx1201, and gfx1151.
### Changed
* Changed the default compiler from `hipcc` to `amdclang` in the installation script and cmake files.
* Changed the address sanitizer build targets. Now only `gfx908:xnack+`, `gfx90a:xnack+`, `gfx940:xnack+`, `gfx941:xnack+`, and `gfx942:xnack+` are built with `BUILD_ADDRESS_SANITIZER=ON`.
### Resolved issues
* Fix hang in `RS-AMG` for Navi on some specific matrix sparsity patterns.
* Fix wrong results in `Apply` on multi-GPU setups.
## rocALUTION 3.2.0 for ROCm 6.2.0
### Additions
* New file I/O based on rocsparse I/O format
* `GetConvergenceHistory` for ItILU0 preconditioner
### Deprecations
* `LocalMatrix::ReadFileCSR`
* `LocalMatrix::WriteFileCSR`
* `GlobalMatrix::ReadFileCSR`
* `GlobalMatrix::WriteFileCSR`
## rocALUTION 3.1.1 for ROCm 6.1.0
### Additions
* `TripleMatrixProduct` functionality for `GlobalMatrix`
* Multi-Node/GPU support for `UA-AMG`, `SA-AMG` and `RS-AMG`
* Iterative ILU0 preconditioner `ItILU0`
* Iterative triangular solve, selectable via `SolverDecr` class
### Deprecations
* `LocalMatrix::AMGConnect`
* `LocalMatrix::AMGAggregate`
* `LocalMatrix::AMGPMISAggregate`
* `LocalMatrix::AMGSmoothedAggregation`
* `LocalMatrix::AMGAggregation`
* `PairwiseAMG`
### Known Issues
* `PairwiseAMG` does currently not support matrix sizes that exceed int32 range
* `PairwiseAMG` might fail building the hierarchy on certain input matrices
## rocALUTION 3.0.3 for ROCm 6.0.0
### Additions
* Support for 64bit integer vectors
* Inclusive and exclusive sum functionality for vector classes
* Transpose functionality for `GlobalMatrix` and `LocalMatrix`
* `TripleMatrixProduct` functionality for `LocalMatrix`
* `Sort()` function for `LocalVector` class
* Multiple stream support to the HIP backend
### Optimizations
* `GlobalMatrix::Apply()` now uses multiple streams to better hide communication
### Changes
* Matrix dimensions and number of non-zeros are now stored using 64-bit integers
* Improved the ILUT preconditioner
### Deprecations
* `LocalVector::GetIndexValues(ValueType*)`
* `LocalVector::SetIndexValues(const ValueType*)`
* `LocalMatrix::RSDirectInterpolation(const LocalVector&, const LocalVector&, LocalMatrix*, LocalMatrix*)`
* `LocalMatrix::RSExtPIInterpolation(const LocalVector&, const LocalVector&, bool, float, LocalMatrix*, LocalMatrix*)`
* `LocalMatrix::RugeStueben()`
* `LocalMatrix::AMGSmoothedAggregation(ValueType, const LocalVector&, const LocalVector&, LocalMatrix*, LocalMatrix*, int)`
* `LocalMatrix::AMGAggregation(const LocalVector&, LocalMatrix*, LocalMatrix*)`
### Fixes
* Unit tests no longer ignore BCSR block dimension
* Fixed documentation typos
* Bug in multi-coloring for non-symmetric matrix patterns
## rocALUTION 2.1.11 for ROCm 5.7.0
### Additions
* Support for gfx940, gfx941, and gfx942
### Fixes
* OpenMP runtime issue with Windows toolchain
## rocALUTION 2.1.9 for ROCm 5.6.0
### Fixes
* Synchronization issues in level 1 routines
## rocALUTION 2.1.8 for ROCm 5.5.0
### Additions
* Build support for Navi32
### Fixes
* Typo in MPI backend
* Bug with the backend when HIP support is disabled
* Bug in SAAMG hierarchy building on the HIP backend
* Improved SAAMG hierarchy build performance on the HIP backend
### Deprecations
* `LocalVector::GetIndexValues(ValueType*)`: use
`LocalVector::GetIndexValues(const LocalVector&, LocalVector*)` instead
* `LocalVector::SetIndexValues(const ValueType*)`: use
`LocalVector::SetIndexValues(const LocalVector&, const LocalVector&)` instead
* `LocalMatrix::RSDirectInterpolation(const LocalVector&, const LocalVector&, LocalMatrix*, LocalMatrix*)`:
use `LocalMatrix::RSDirectInterpolation(const LocalVector&, const LocalVector&, LocalMatrix*)`
instead
* `LocalMatrix::RSExtPIInterpolation(const LocalVector&, const LocalVector&, bool, float, LocalMatrix*, LocalMatrix*)`:
use `LocalMatrix::RSExtPIInterpolation(const LocalVector&, const LocalVector&, bool, LocalMatrix*)`
instead
* `LocalMatrix::RugeStueben()`
* `LocalMatrix::AMGSmoothedAggregation(ValueType, const LocalVector&, const LocalVector&, LocalMatrix*, LocalMatrix*, int)`:
use `LocalMatrix::AMGAggregation(ValueType, const LocalVector&, const LocalVector&, LocalMatrix*, int)`
instead
* `LocalMatrix::AMGAggregation(const LocalVector&, LocalMatrix*, LocalMatrix*)`: use
`LocalMatrix::AMGAggregation(const LocalVector&, LocalMatrix*)` instead
## rocALUTION 2.1.3 for ROCm 5.4.0
### Additions
* Build support for Navi31 and Navi33
* Support for non-squared global matrices
### Fixes
* Memory leak in MatrixMult on HIP backend
* Global structures can now be used with a single process
### Changes
* Switched GTest death test style to 'threadsafe'
* Removed the native compiler option that was used during default library compilation
### Deprecations
* `GlobalVector::GetGhostSize()`
* `ParallelManager::GetGlobalSize(), ParallelManager::GetLocalSize()`, `ParallelManager::SetGlobalSize()`,
and `ParallelManager::SetLocalSize()`
* `Vector::GetGhostSize()`
* `Multigrid::SetOperatorFormat(unsigned int)`: use `Multigrid::SetOperatorFormat(unsigned int, int)`
instead
* `RugeStuebenAMG::SetCouplingStrength(ValueType)`: use `SetStrengthThreshold(float)` instead
## rocALUTION 2.1.0 for ROCm 5.3.0
### Additions
* Benchmarking tool
* Ext+I Interpolation with sparsify strategies added for RS-AMG
### Optimizations
* ParallelManager
## rocALUTION 2.0.3 for ROCm 5.2.0
### Additions
* New packages for test and benchmark executables on all supported operating systems using CPack
## rocALUTION 2.0.2 for ROCm 5.1.0
### Additions
* Added out-of-place matrix transpose functionality
* Added LocalVector
## rocALUTION 2.0.1 for ROCm 5.0.0
### Changes
* Changed to C++ 14 Standard
* Added sanitizer option
* Improved documentation
### Deprecations
* `GlobalPairwiseAMG` class: use `PairwiseAMG` instead
## rocALUTION 1.13.2 for ROCm 4.5.0
### Additions
* AddressSanitizer build option
* Enabled beta support for Windows 10
### Changes
* Packaging has been split into a runtime package (`rocalution`) and a development package
(`rocalution-devel`):
The development package depends on the runtime package. When installing the runtime package,
the package manager will suggest the installation of the development package to aid users
transitioning from the previous version's combined package. This suggestion by package manager is
for all supported operating systems (except CentOS 7) to aid in the transition. The `suggestion`
feature in the runtime package is introduced as a deprecated feature and will be removed in a future
ROCm release.
### Deprecations
* `GlobalPairwiseAMG`: use `PairwiseAMG` instead
### Optimizations
* Improved (A)MG smoothing and convergence rate
* Improved IDR Gram-Schmidt process
* Optimized (A)MG solving phase
## rocALUTION 1.12.1 for ROCm 4.3.0
### Additions
* Support for gfx90a target
* Support for gfx1030 target
### Optimizations
* Install script
## rocALUTION 1.11.5 for ROCm 4.0.0
### Additions
* Changelog
* Block compressed sparse row (BCSRR) format support
### Changes
* Update to the Debian package name
* CMake file adjustments
### Fixes
* NaN issues
## rocALUTION 1.10 for ROCm 3.9
### Additions
* rocRAND support for GPU sampling of random data
## rocALUTION 1.9.3 for ROCm 3.8
### Additions
* `csr2dense` and `dense2csr` to HIP backend
## rocALUTION 1.9.1 for ROCm 3.5
### Additions
* Static build
* BCSR matrix format for SpMV
### Fixes
* Bug in conversion from CSR to HYB format
rocALUTION-rocm-7.1.0/CMakeLists.txt 0000664 0000000 0000000 00000022062 15073773325 0017052 0 ustar 00root root 0000000 0000000 # ########################################################################
# Copyright (C) 2018-2025 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
${ROCM_PATH}/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 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_HIP_STANDARD 17)
set(CMAKE_HIP_STANDARD_REQUIRED ON)
set(CMAKE_HIP_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_GLOBALTYPE_64 "Support global number of rows / columns exceeding 32 bits" OFF)
option(BUILD_LOCALTYPE_64 "Support local number of rows / columns exceeding 32 bits" OFF)
option(BUILD_PTRTYPE_64 "Support local number of non-zeros exceeding 32 bits" OFF)
option(BUILD_OPTCPU "Enable all instruction subsets supported by the local machine" OFF)
option(BUILD_SUPPORT_COMPLEX "Enable complex number support" ON)
# Dependencies
include(cmake/Dependencies.cmake)
if(BUILD_ADDRESS_SANITIZER)
set(DEFAULT_AMDGPU_TARGETS
gfx908:xnack+
gfx90a:xnack+
gfx942:xnack+
)
else()
set(DEFAULT_AMDGPU_TARGETS
gfx803
gfx900:xnack-
gfx906:xnack-
gfx908:xnack-
gfx90a:xnack-
gfx90a:xnack+
gfx942
gfx950
gfx1030
gfx1100
gfx1101
gfx1102
gfx1151
gfx1200
gfx1201
)
endif()
if(AMDGPU_TARGETS AND NOT GPU_TARGETS)
message( DEPRECATION "AMDGPU_TARGETS use is deprecated. Use GPU_TARGETS." )
endif()
set(AMDGPU_TARGETS "${DEFAULT_AMDGPU_TARGETS}" CACHE STRING "Target default GPUs if AMDGPU_TARGETS is not defined. (Deprecated, prefer GPU_TARGETS)")
# Don't force, users should be able to override GPU_TARGETS at the command line if desired
set(GPU_TARGETS "${AMDGPU_TARGETS}" CACHE STRING "GPU architectures to build for")
include(CheckLanguage)
include(CMakeDependentOption)
check_language(HIP)
cmake_dependent_option(USE_HIPCXX "Use CMake HIP language support" OFF CMAKE_HIP_COMPILER OFF)
if(USE_HIPCXX)
enable_language(HIP)
else()
find_package(HIP MODULE) # hip_add_library is only provided by the find module
if(NOT HIP_FOUND)
message("-- HIP not found. Compiling WITHOUT HIP support.")
endif()
endif()
cmake_dependent_option(SUPPORT_HIP "Compile WITH HIP support" ON "USE_HIPCXX OR HIP_FOUND" OFF)
# HIP related library dependencies
if(SUPPORT_HIP)
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
find_package( hip REQUIRED CONFIG PATHS ${HIP_DIR} ${ROCM_PATH} /opt/rocm )
endif( )
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
rocm_setup_version(VERSION "4.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)
if(BUILD_ADDRESS_SANITIZER)
set(DEPENDS_HIP_RUNTIME "hip-runtime-amd-asan >= 4.5.0" )
else()
set(DEPENDS_HIP_RUNTIME "hip-runtime-amd >= 4.5.0" )
endif()
rocm_package_add_dependencies(DEPENDS "${DEPENDS_HIP_RUNTIME}" "rocsparse >= 1.12.10" "rocblas >= 2.22.0" "rocrand >= 2.1.0")
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 "ROCm 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
)
#
# Generate coverage output.
#
add_custom_command(TARGET coverage_output
COMMAND lcov --directory . --base-directory . --capture -o lcoverage/raw_main_coverage.info
COMMAND lcov --remove lcoverage/raw_main_coverage.info "'${CMAKE_SOURCE_DIR}/src/utils/*'" "'${CMAKE_SOURCE_DIR}/src/base/host/host_io.*'" "'${CMAKE_SOURCE_DIR}/clients/*'" "'${CMAKE_SOURCE_DIR}/build/*'" "'/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-7.1.0/LICENSE.md 0000664 0000000 0000000 00000002122 15073773325 0015711 0 ustar 00root root 0000000 0000000 MIT License
Copyright (C) 2024 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-7.1.0/README.md 0000664 0000000 0000000 00000011466 15073773325 0015577 0 ustar 00root root 0000000 0000000 # rocALUTION
> [!NOTE]
> The published documentation is available at [rocALUTION](https://rocm.docs.amd.com/projects/rocALUTION/en/latest/) in an organized, easy-to-read format, with search and a table of contents. The documentation source files reside in the `docs` folder of this repository. As with all ROCm projects, the documentation is open source. For more information on contributing to the documentation, see [Contribute to ROCm documentation](https://rocm.docs.amd.com/en/latest/contribute/contributing.html).
rocALUTION is a sparse linear algebra library that can be used to explore fine-grained parallelism on
top of the [ROCm](https://github.com/ROCm/ROCm) platform runtime and toolchains.
Based on C++ and [HIP](https://github.com/ROCm/HIP/), rocALUTION
provides a portable, generic, and flexible design that allows seamless integration with other scientific
software packages.
rocALUTION offers various backends for different (parallel) hardware:
* Host
* [OpenMP](http://www.openmp.org/): Designed for multi-core CPUs
* [HIP](https://github.com/ROCm/HIP/): Designed for ROCm-compatible devices
* [MPI](https://www.open-mpi.org/): Designed for multi-node clusters and multi-GPU setups
## Requirements
To use rocALUTION on GPU devices, you must first install the
[rocBLAS](https://github.com/ROCm/rocBLAS),
[rocSPARSE](https://github.com/ROCm/rocSPARSE), and
[rocRAND](https://github.com/ROCm/rocRAND) libraries. You can install these from
the ROCm repository, the GitHub 'releases' tab, or you can manually compile them.
## Documentation
Documentation for rocALUTION is available at
[https://rocm.docs.amd.com/projects/rocALUTION/en/latest/](https://rocm.docs.amd.com/projects/rocALUTION/en/latest/).
To build our documentation locally, use the following code:
```bash
cd docs
pip3 install -r sphinx/requirements.txt
python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html
```
## Build
You can compile rocALUTION using CMake 3.5 or later. Note that all compiler specifications are
determined automatically.
```bash
# Clone rocALUTION using git
git clone https://github.com/ROCm/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
```
To test your installation, run a CG solver on a Laplacian matrix:
```bash
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
```
## General information
rocALUTION is based on a generic and robust design that allows expansion in the direction of new
solvers and preconditioners with support for various hardware types. The library's design allows the
use of all solvers as preconditioners in other solvers. For example, you can define a CG solver with a
multi-elimination preconditioner, in which the last-block is preconditioned with another Chebyshev
iteration method that itself is preconditioned with a multi-colored symmetric Gauss-Seidel scheme.
### 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
* Additive Schwarz (restricted)
* 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)
## Portability
All code based on rocALUTION is portable and hardware-independent. It compiles and runs on any
supported platform. All solvers and preconditioners are based on a single source code implementation
that delivers portable results across all backends (note that variations are possible due to different
hardware rounding modes). The only visible difference between hardware is performance variation.
rocALUTION-rocm-7.1.0/clients/ 0000775 0000000 0000000 00000000000 15073773325 0015751 5 ustar 00root root 0000000 0000000 rocALUTION-rocm-7.1.0/clients/CMakeLists.txt 0000664 0000000 0000000 00000006466 15073773325 0020525 0 ustar 00root root 0000000 0000000 # ########################################################################
# 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-7.1.0/clients/benchmarks/ 0000775 0000000 0000000 00000000000 15073773325 0020066 5 ustar 00root root 0000000 0000000 rocALUTION-rocm-7.1.0/clients/benchmarks/CMakeLists.txt 0000664 0000000 0000000 00000004711 15073773325 0022631 0 ustar 00root root 0000000 0000000 # ########################################################################
# Copyright (C) 2022-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.
#
# ########################################################################
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_itilu0_alg.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 -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-7.1.0/clients/benchmarks/client.cpp 0000664 0000000 0000000 00000007554 15073773325 0022063 0 ustar 00root root 0000000 0000000 /*! \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-7.1.0/clients/benchmarks/program_options.hpp 0000664 0000000 0000000 00000030234 15073773325 0024023 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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-7.1.0/clients/benchmarks/rocalution_arguments_config.cpp 0000664 0000000 0000000 00000031237 15073773325 0026371 0 ustar 00root root 0000000 0000000 /*! \file */
/* ************************************************************************
* Copyright (C) 2022-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 "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::itsolve_tol:
{
ADD_OPTION(double, e, 1e-03, "iterative solve tolerance (see --iterative_solve).");
break;
}
case rocalution_bench_solver_parameters::itilu0_tol:
{
ADD_OPTION(double, e, 2e-07, "itilu0 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::itsolve_max_iter:
{
ADD_OPTION(int,
e,
30,
"iterative solve maximum number of iterations (see "
"--iterative_solve).");
break;
}
case rocalution_bench_solver_parameters::itilu0_max_iter:
{
ADD_OPTION(int, e, 1000, "itilu0 maximum number of iterations.");
break;
}
case rocalution_bench_solver_parameters::itilu0_options:
{
ADD_OPTION(int, e, 1000, "itilu0 combination of options.");
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::itilu0_alg:
{
ADD_OPTION(std::string, e, "Default", "ItILU0 algorithm");
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::iterative_solve:
{
ADD_OPTION(bool, e, false, "perform triangular iterative solve during solving step.");
break;
}
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::itilu0_alg:
{
auto itilu0_alg_string = this->Get(rocalution_bench_solver_parameters::itilu0_alg);
if(itilu0_alg_string != "")
{
this->m_enum_itilu0_alg(itilu0_alg_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-7.1.0/clients/benchmarks/rocalution_arguments_config.hpp 0000664 0000000 0000000 00000004231 15073773325 0026370 0 ustar 00root root 0000000 0000000 /*! \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-7.1.0/clients/benchmarks/rocalution_bench.cpp 0000664 0000000 0000000 00000006346 15073773325 0024121 0 ustar 00root root 0000000 0000000 /*! \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-7.1.0/clients/benchmarks/rocalution_bench.hpp 0000664 0000000 0000000 00000005126 15073773325 0024121 0 ustar 00root root 0000000 0000000 /*! \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-7.1.0/clients/benchmarks/rocalution_bench_app.cpp 0000664 0000000 0000000 00000036324 15073773325 0024760 0 ustar 00root root 0000000 0000000 /*! \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-7.1.0/clients/benchmarks/rocalution_bench_app.hpp 0000664 0000000 0000000 00000020363 15073773325 0024761 0 ustar 00root root 0000000 0000000 /*! \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-7.1.0/clients/benchmarks/rocalution_bench_cmdlines.cpp 0000664 0000000 0000000 00000005432 15073773325 0025772 0 ustar 00root root 0000000 0000000 #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-7.1.0/clients/benchmarks/rocalution_bench_cmdlines.hpp 0000664 0000000 0000000 00000044241 15073773325 0026000 0 ustar 00root root 0000000 0000000 /*! \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-7.1.0/clients/benchmarks/rocalution_bench_itsolver.hpp 0000664 0000000 0000000 00000020025 15073773325 0026043 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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-7.1.0/clients/benchmarks/rocalution_bench_itsolver_impl.hpp 0000664 0000000 0000000 00000016642 15073773325 0027076 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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-7.1.0/clients/benchmarks/rocalution_bench_solver.hpp 0000664 0000000 0000000 00000007224 15073773325 0025514 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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-7.1.0/clients/benchmarks/rocalution_bench_solver_parameters.cpp 0000664 0000000 0000000 00000015241 15073773325 0027730 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* Copyright (C) 2022-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 "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_itilu0_alg rocalution_bench_solver_parameters::GetEnumItILU0Algorithm() const
{
return this->m_enum_itilu0_alg;
};
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-7.1.0/clients/benchmarks/rocalution_bench_solver_parameters.hpp 0000664 0000000 0000000 00000027153 15073773325 0027742 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* Copyright (C) 2022-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.
*
* ************************************************************************ */
#pragma once
#include "rocalution_enum_coarsening_strategy.hpp"
#include "rocalution_enum_directsolver.hpp"
#include "rocalution_enum_itilu0_alg.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 ItILU0 algorithm.
//
rocalution_enum_itilu0_alg m_enum_itilu0_alg{};
//
// @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 ItILU0 algorithm.
//
rocalution_enum_itilu0_alg GetEnumItILU0Algorithm() 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(iterative_solve) \
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(itsolve_max_iter) \
PINT_TRANSFORM(itilu0_max_iter) \
PINT_TRANSFORM(itilu0_options) \
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(itilu0_alg) \
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(itsolve_tol) \
PDOUBLE_TRANSFORM(itilu0_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-7.1.0/clients/benchmarks/rocalution_bench_solver_results.cpp 0000664 0000000 0000000 00000007554 15073773325 0027276 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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-7.1.0/clients/benchmarks/rocalution_bench_solver_results.hpp 0000664 0000000 0000000 00000011311 15073773325 0027265 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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-7.1.0/clients/benchmarks/rocalution_bench_template.hpp 0000664 0000000 0000000 00000003712 15073773325 0026013 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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-7.1.0/clients/benchmarks/rocalution_driver_itsolver.hpp 0000664 0000000 0000000 00000035503 15073773325 0026266 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* Copyright (C) 2022-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.
*
* ************************************************************************ */
#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;
break;
}
case rocalution_enum_preconditioner::FSAI:
{
auto* p
= new rocalution::FSAI, rocalution::LocalVector, T>;
this->m_preconditioner = p;
break;
}
case rocalution_enum_preconditioner::SPAI:
{
auto* p
= new rocalution::SPAI, rocalution::LocalVector, T>;
this->m_preconditioner = p;
break;
}
case rocalution_enum_preconditioner::TNS:
{
auto* p
= new rocalution::TNS, rocalution::LocalVector, T>;
this->m_preconditioner = p;
break;
}
case rocalution_enum_preconditioner::Jacobi:
{
auto* p
= new rocalution::Jacobi, rocalution::LocalVector, T>;
//
// no specific parameters
//
this->m_preconditioner = p;
break;
}
case rocalution_enum_preconditioner::GS:
{
auto* p = new rocalution::GS, rocalution::LocalVector, T>;
//
// no specific parameters
//
this->m_preconditioner = p;
break;
}
case rocalution_enum_preconditioner::SGS:
{
auto* p
= new rocalution::SGS, rocalution::LocalVector, T>;
//
// no specific parameters
//
this->m_preconditioner = p;
break;
}
case rocalution_enum_preconditioner::ILU:
{
auto* p
= new rocalution::ILU, rocalution::LocalVector, T>;
//
// no specific parameters
//
this->m_preconditioner = p;
break;
}
case rocalution_enum_preconditioner::ItILU0:
{
auto enum_itilu0_alg = parameters.GetEnumItILU0Algorithm();
if(enum_itilu0_alg.is_invalid())
{
rocalution_bench_errmsg << "enum_itilu0_alg is invalid." << std::endl;
return false;
}
auto* p
= new rocalution::ItILU0, rocalution::LocalVector, T>;
p->SetMaxIter(parameters.Get(params_t::itilu0_max_iter));
p->SetTolerance(parameters.Get(params_t::itilu0_tol));
p->SetOptions(parameters.Get(params_t::itilu0_options));
switch(enum_itilu0_alg.value)
{
case rocalution_enum_itilu0_alg::Default:
{
p->SetAlgorithm(ItILU0Algorithm::Default);
break;
}
case rocalution_enum_itilu0_alg::AsyncInPlace:
{
p->SetAlgorithm(ItILU0Algorithm::AsyncInPlace);
break;
}
case rocalution_enum_itilu0_alg::AsyncSplit:
{
p->SetAlgorithm(ItILU0Algorithm::AsyncSplit);
break;
}
case rocalution_enum_itilu0_alg::SyncSplit:
{
p->SetAlgorithm(ItILU0Algorithm::SyncSplit);
break;
}
case rocalution_enum_itilu0_alg::SyncSplitFusion:
{
p->SetAlgorithm(ItILU0Algorithm::SyncSplitFusion);
break;
}
}
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;
break;
}
case rocalution_enum_preconditioner::IC:
{
auto* p = new rocalution::IC, rocalution::LocalVector, T>;
//
// no specific parameters
//
this->m_preconditioner = p;
break;
}
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;
break;
}
case rocalution_enum_preconditioner::MCSGS:
{
auto* p = new rocalution::
MultiColoredSGS, rocalution::LocalVector, T>;
//
// no specific parameters
//
this->m_preconditioner = p;
break;
}
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;
break;
}
}
if(this->m_preconditioner != nullptr)
{
const auto itsolve = parameters.Get(params_t::iterative_solve);
rocalution::SolverDescr descr;
if(itsolve)
{
descr.SetTriSolverAlg(TriSolverAlg_Iterative);
descr.SetIterativeSolverMaxIteration(parameters.Get(params_t::itsolve_max_iter));
descr.SetIterativeSolverTolerance(parameters.Get(params_t::itsolve_tol));
}
else
{
descr.SetTriSolverAlg(TriSolverAlg_Default);
}
this->m_preconditioner->SetSolverDescriptor(descr);
return true;
}
return false;
}
};
//
// @Brief Default definition.
//
template
struct rocalution_driver_itsolver : rocalution_driver_itsolver_default
{
};
rocALUTION-rocm-7.1.0/clients/benchmarks/rocalution_driver_itsolver_fgmres.hpp 0000664 0000000 0000000 00000004373 15073773325 0027632 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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-7.1.0/clients/benchmarks/rocalution_driver_itsolver_gmres.hpp 0000664 0000000 0000000 00000004367 15073773325 0027467 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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-7.1.0/clients/benchmarks/rocalution_driver_itsolver_template.hpp 0000664 0000000 0000000 00000027076 15073773325 0030167 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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-7.1.0/clients/benchmarks/rocalution_driver_itsolver_traits.hpp 0000664 0000000 0000000 00000011021 15073773325 0027641 0 ustar 00root root 0000000 0000000 /* ************************************************************************
* 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