├── .azuredevops └── rocm-ci.yml ├── .clang-format ├── .githooks ├── install └── pre-commit ├── .github ├── CODEOWNERS ├── CONTRIBUTING.md └── dependabot.yml ├── .gitignore ├── .jenkins ├── codecov.groovy ├── common.groovy ├── debug.groovy ├── extended.groovy ├── precheckin.groovy ├── staticanalysis.groovy └── staticlibrary.groovy ├── .readthedocs.yaml ├── CHANGELOG.md ├── CMakeLists.txt ├── LICENSE.md ├── README.md ├── clients ├── CMakeLists.txt ├── benchmarks │ ├── CMakeLists.txt │ ├── client.cpp │ ├── program_options.hpp │ ├── rocalution_arguments_config.cpp │ ├── rocalution_arguments_config.hpp │ ├── rocalution_bench.cpp │ ├── rocalution_bench.hpp │ ├── rocalution_bench_app.cpp │ ├── rocalution_bench_app.hpp │ ├── rocalution_bench_cmdlines.cpp │ ├── rocalution_bench_cmdlines.hpp │ ├── rocalution_bench_itsolver.hpp │ ├── rocalution_bench_itsolver_impl.hpp │ ├── rocalution_bench_solver.hpp │ ├── rocalution_bench_solver_parameters.cpp │ ├── rocalution_bench_solver_parameters.hpp │ ├── rocalution_bench_solver_results.cpp │ ├── rocalution_bench_solver_results.hpp │ ├── rocalution_bench_template.hpp │ ├── rocalution_driver_itsolver.hpp │ ├── rocalution_driver_itsolver_fgmres.hpp │ ├── rocalution_driver_itsolver_gmres.hpp │ ├── rocalution_driver_itsolver_template.hpp │ ├── rocalution_driver_itsolver_traits.hpp │ ├── rocalution_driver_itsolver_uaamg.hpp │ ├── rocalution_enum_coarsening_strategy.cpp │ ├── rocalution_enum_coarsening_strategy.hpp │ ├── rocalution_enum_directsolver.cpp │ ├── rocalution_enum_directsolver.hpp │ ├── rocalution_enum_directsolver_traits.hpp │ ├── rocalution_enum_itilu0_alg.cpp │ ├── rocalution_enum_itilu0_alg.hpp │ ├── rocalution_enum_itsolver.cpp │ ├── rocalution_enum_itsolver.hpp │ ├── rocalution_enum_matrix_init.cpp │ ├── rocalution_enum_matrix_init.hpp │ ├── rocalution_enum_preconditioner.cpp │ ├── rocalution_enum_preconditioner.hpp │ ├── rocalution_enum_smoother.cpp │ └── rocalution_enum_smoother.hpp ├── include │ ├── common.hpp │ ├── random.cpp │ ├── random.hpp │ ├── testing_backend.hpp │ ├── testing_bicgstab.hpp │ ├── testing_bicgstabl.hpp │ ├── testing_cg.hpp │ ├── testing_cr.hpp │ ├── testing_fcg.hpp │ ├── testing_fgmres.hpp │ ├── testing_global_matrix.hpp │ ├── testing_global_vector.hpp │ ├── testing_gmres.hpp │ ├── testing_idr.hpp │ ├── testing_inversion.hpp │ ├── testing_local_matrix.hpp │ ├── testing_local_matrix_itsolve.hpp │ ├── testing_local_matrix_multicoloring.hpp │ ├── testing_local_matrix_solve.hpp │ ├── testing_local_stencil.hpp │ ├── testing_local_vector.hpp │ ├── testing_lu.hpp │ ├── testing_pairwise_amg.hpp │ ├── testing_parallel_manager.hpp │ ├── testing_qmrcgstab.hpp │ ├── testing_qr.hpp │ ├── testing_ruge_stueben_amg.hpp │ ├── testing_saamg.hpp │ ├── testing_uaamg.hpp │ ├── utility.hpp │ └── validate.hpp ├── samples │ ├── CMakeLists.txt │ ├── amg.cpp │ ├── as-precond.cpp │ ├── async.cpp │ ├── benchmark.cpp │ ├── benchmark_mpi.cpp │ ├── bicgstab.cpp │ ├── bicgstab_mpi.cpp │ ├── block-precond.cpp │ ├── cg-amg.cpp │ ├── cg-amg_mpi.cpp │ ├── cg-rsamg.cpp │ ├── cg-rsamg_mpi.cpp │ ├── cg-saamg.cpp │ ├── cg-saamg_mpi.cpp │ ├── cg-uaamg_mpi.cpp │ ├── cg.cpp │ ├── cg_mpi.cpp │ ├── cmk.cpp │ ├── complex.cpp │ ├── direct.cpp │ ├── fcg.cpp │ ├── fcg_mpi.cpp │ ├── fgmres.cpp │ ├── fgmres_mpi.cpp │ ├── fixed-point.cpp │ ├── global-io_mpi.cpp │ ├── gmres.cpp │ ├── idr.cpp │ ├── idr_mpi.cpp │ ├── itsolve.cpp │ ├── key.cpp │ ├── laplace_2d_weak_scaling.cpp │ ├── laplace_3d_weak_scaling.cpp │ ├── me-preconditioner.cpp │ ├── mixed-precision.cpp │ ├── power-method.cpp │ ├── qmrcgstab_mpi.cpp │ ├── sa-amg.cpp │ ├── simple-spmv.cpp │ ├── sp-precond.cpp │ ├── stencil.cpp │ ├── tns.cpp │ ├── ua-amg.cpp │ └── var-precond.cpp └── tests │ ├── CMakeLists.txt │ ├── rocalution_host_gtest_main.cpp │ ├── test_backend.cpp │ ├── test_bicgstab.cpp │ ├── test_bicgstabl.cpp │ ├── test_cg.cpp │ ├── test_cr.cpp │ ├── test_fcg.cpp │ ├── test_fgmres.cpp │ ├── test_global_matrix.cpp │ ├── test_global_vector.cpp │ ├── test_gmres.cpp │ ├── test_idr.cpp │ ├── test_inversion.cpp │ ├── test_local_matrix.cpp │ ├── test_local_matrix_itsolve.cpp │ ├── test_local_matrix_multicoloring.cpp │ ├── test_local_matrix_solve.cpp │ ├── test_local_stencil.cpp │ ├── test_local_vector.cpp │ ├── test_lu.cpp │ ├── test_pairwise_amg.cpp │ ├── test_parallel_manager.cpp │ ├── test_qmrcgstab.cpp │ ├── test_qr.cpp │ ├── test_ruge_stueben_amg.cpp │ ├── test_saamg.cpp │ └── test_uaamg.cpp ├── cmake ├── Dependencies.cmake ├── Packaging.cmake ├── Verbose.cmake └── get-cli-arguments.cmake ├── custom.properties ├── deps ├── CMakeLists.txt └── external-gtest.cmake ├── docs ├── .gitignore ├── classification-map.xml ├── conceptual │ ├── rocALUTION-design.rst │ └── rocALUTION-organization.rst ├── conf.py ├── data │ ├── 4x4_mpi.png │ ├── 4x4_mpi_rank0.png │ ├── AS.png │ ├── BJ.png │ ├── domain1.png │ ├── global_objects.png │ ├── multi-node1.png │ ├── multi-node2.png │ ├── operators.png │ ├── receiving.png │ ├── sending.png │ ├── single-node.png │ └── solvers.png ├── doxygen │ ├── Doxyfile │ ├── bibliography.bib │ └── modules.dox ├── how-to │ ├── extending-rocALUTION.rst │ └── include-rocALUTION.rst ├── index.rst ├── install │ ├── rocALUTION-general-install.rst │ ├── rocALUTION-linux-build-and-install.rst │ ├── rocALUTION-prerequisites.rst │ └── rocALUTION-windows-build-and-install.rst ├── license.rst ├── reference │ ├── rocALUTION-accelerators.rst │ ├── rocALUTION-api-basics.rst │ ├── rocALUTION-api.rst │ ├── rocALUTION-functionality-table.rst │ ├── rocALUTION-library-notes.rst │ ├── rocALUTION-multi-node-comp.rst │ ├── rocALUTION-preconditioners.rst │ ├── rocALUTION-single-node-comp.rst │ └── rocALUTION-solvers.rst ├── sphinx │ ├── _toc.yml.in │ ├── requirements.in │ └── requirements.txt ├── tutorials │ └── rocALUTION-client-examples.rst └── what-is-rocalution.rst ├── install.sh ├── rmake.py ├── rtest.py ├── rtest.xml ├── scripts ├── rocalution-bench-compare.py ├── rocalution-bench-execute.py ├── rocalution-bench-plot.py ├── rocalution-bench-regression.py └── rocalution_bench_gnuplot_helper.py ├── src ├── CMakeLists.txt ├── base │ ├── CMakeLists.txt │ ├── backend_manager.cpp │ ├── backend_manager.hpp │ ├── base_matrix.cpp │ ├── base_matrix.hpp │ ├── base_rocalution.cpp │ ├── base_rocalution.hpp │ ├── base_stencil.cpp │ ├── base_stencil.hpp │ ├── base_vector.cpp │ ├── base_vector.hpp │ ├── global_matrix.cpp │ ├── global_matrix.hpp │ ├── global_vector.cpp │ ├── global_vector.hpp │ ├── hip │ │ ├── CMakeLists.txt │ │ ├── backend_hip.cpp │ │ ├── backend_hip.hpp │ │ ├── hip_allocate_free.cpp │ │ ├── hip_allocate_free.hpp │ │ ├── hip_atomics.hpp │ │ ├── hip_blas.cpp │ │ ├── hip_blas.hpp │ │ ├── hip_conversion.cpp │ │ ├── hip_conversion.hpp │ │ ├── hip_kernels_conversion.hpp │ │ ├── hip_kernels_coo.hpp │ │ ├── hip_kernels_csr.hpp │ │ ├── hip_kernels_dense.hpp │ │ ├── hip_kernels_dia.hpp │ │ ├── hip_kernels_general.hpp │ │ ├── hip_kernels_mcsr.hpp │ │ ├── hip_kernels_rsamg_csr.hpp │ │ ├── hip_kernels_vector.hpp │ │ ├── hip_matrix_bcsr.cpp │ │ ├── hip_matrix_bcsr.hpp │ │ ├── hip_matrix_coo.cpp │ │ ├── hip_matrix_coo.hpp │ │ ├── hip_matrix_csr.cpp │ │ ├── hip_matrix_csr.hpp │ │ ├── hip_matrix_dense.cpp │ │ ├── hip_matrix_dense.hpp │ │ ├── hip_matrix_dia.cpp │ │ ├── hip_matrix_dia.hpp │ │ ├── hip_matrix_ell.cpp │ │ ├── hip_matrix_ell.hpp │ │ ├── hip_matrix_hyb.cpp │ │ ├── hip_matrix_hyb.hpp │ │ ├── hip_matrix_mcsr.cpp │ │ ├── hip_matrix_mcsr.hpp │ │ ├── hip_rand.hpp │ │ ├── hip_rand_normal.hpp │ │ ├── hip_rand_uniform.hpp │ │ ├── hip_rsamg_csr.cpp │ │ ├── hip_sparse.cpp │ │ ├── hip_sparse.hpp │ │ ├── hip_unordered_map.hpp │ │ ├── hip_unordered_set.hpp │ │ ├── hip_utils.hpp │ │ ├── hip_vector.cpp │ │ └── hip_vector.hpp │ ├── host │ │ ├── CMakeLists.txt │ │ ├── host_affinity.cpp │ │ ├── host_affinity.hpp │ │ ├── host_conversion.cpp │ │ ├── host_conversion.hpp │ │ ├── host_ilut_driver_csr.cpp │ │ ├── host_ilut_driver_csr.hpp │ │ ├── host_io.cpp │ │ ├── host_io.hpp │ │ ├── host_matrix_bcsr.cpp │ │ ├── host_matrix_bcsr.hpp │ │ ├── host_matrix_coo.cpp │ │ ├── host_matrix_coo.hpp │ │ ├── host_matrix_csr.cpp │ │ ├── host_matrix_csr.hpp │ │ ├── host_matrix_dense.cpp │ │ ├── host_matrix_dense.hpp │ │ ├── host_matrix_dia.cpp │ │ ├── host_matrix_dia.hpp │ │ ├── host_matrix_ell.cpp │ │ ├── host_matrix_ell.hpp │ │ ├── host_matrix_hyb.cpp │ │ ├── host_matrix_hyb.hpp │ │ ├── host_matrix_mcsr.cpp │ │ ├── host_matrix_mcsr.hpp │ │ ├── host_sparse.cpp │ │ ├── host_sparse.hpp │ │ ├── host_stencil_laplace2d.cpp │ │ ├── host_stencil_laplace2d.hpp │ │ ├── host_vector.cpp │ │ └── host_vector.hpp │ ├── local_matrix.cpp │ ├── local_matrix.hpp │ ├── local_stencil.cpp │ ├── local_stencil.hpp │ ├── local_vector.cpp │ ├── local_vector.hpp │ ├── matrix_formats.hpp │ ├── matrix_formats_ind.hpp │ ├── operator.cpp │ ├── operator.hpp │ ├── parallel_manager.cpp │ ├── parallel_manager.hpp │ ├── stencil_types.hpp │ ├── vector.cpp │ ├── vector.hpp │ └── version.hpp.in ├── rocalution.hpp ├── solvers │ ├── CMakeLists.txt │ ├── chebyshev.cpp │ ├── chebyshev.hpp │ ├── direct │ │ ├── inversion.cpp │ │ ├── inversion.hpp │ │ ├── lu.cpp │ │ ├── lu.hpp │ │ ├── qr.cpp │ │ └── qr.hpp │ ├── iter_ctrl.cpp │ ├── iter_ctrl.hpp │ ├── krylov │ │ ├── bicgstab.cpp │ │ ├── bicgstab.hpp │ │ ├── bicgstabl.cpp │ │ ├── bicgstabl.hpp │ │ ├── cg.cpp │ │ ├── cg.hpp │ │ ├── cr.cpp │ │ ├── cr.hpp │ │ ├── fcg.cpp │ │ ├── fcg.hpp │ │ ├── fgmres.cpp │ │ ├── fgmres.hpp │ │ ├── gmres.cpp │ │ ├── gmres.hpp │ │ ├── idr.cpp │ │ ├── idr.hpp │ │ ├── qmrcgstab.cpp │ │ └── qmrcgstab.hpp │ ├── mixed_precision.cpp │ ├── mixed_precision.hpp │ ├── multigrid │ │ ├── base_amg.cpp │ │ ├── base_amg.hpp │ │ ├── base_multigrid.cpp │ │ ├── base_multigrid.hpp │ │ ├── multigrid.cpp │ │ ├── multigrid.hpp │ │ ├── pairwise_amg.cpp │ │ ├── pairwise_amg.hpp │ │ ├── ruge_stueben_amg.cpp │ │ ├── ruge_stueben_amg.hpp │ │ ├── smoothed_amg.cpp │ │ ├── smoothed_amg.hpp │ │ ├── unsmoothed_amg.cpp │ │ └── unsmoothed_amg.hpp │ ├── preconditioners │ │ ├── preconditioner.cpp │ │ ├── preconditioner.hpp │ │ ├── preconditioner_ai.cpp │ │ ├── preconditioner_ai.hpp │ │ ├── preconditioner_as.cpp │ │ ├── preconditioner_as.hpp │ │ ├── preconditioner_blockjacobi.cpp │ │ ├── preconditioner_blockjacobi.hpp │ │ ├── preconditioner_blockprecond.cpp │ │ ├── preconditioner_blockprecond.hpp │ │ ├── preconditioner_multicolored.cpp │ │ ├── preconditioner_multicolored.hpp │ │ ├── preconditioner_multicolored_gs.cpp │ │ ├── preconditioner_multicolored_gs.hpp │ │ ├── preconditioner_multicolored_ilu.cpp │ │ ├── preconditioner_multicolored_ilu.hpp │ │ ├── preconditioner_multielimination.cpp │ │ ├── preconditioner_multielimination.hpp │ │ ├── preconditioner_saddlepoint.cpp │ │ └── preconditioner_saddlepoint.hpp │ ├── solver.cpp │ └── solver.hpp └── utils │ ├── CMakeLists.txt │ ├── allocate_free.cpp │ ├── allocate_free.hpp │ ├── communicator.cpp │ ├── communicator.hpp │ ├── def.hpp │ ├── log.cpp │ ├── log.hpp │ ├── log_mpi.hpp │ ├── math_functions.cpp │ ├── math_functions.hpp │ ├── rocalution.ptk.in │ ├── rocsparseio.cpp │ ├── rocsparseio.h │ ├── rocsparseio.hpp │ ├── time_functions.cpp │ ├── time_functions.hpp │ ├── type_traits.hpp │ └── types.hpp.in ├── suppr.txt ├── toolchain-linux.cmake └── toolchain-windows.cmake /.azuredevops/rocm-ci.yml: -------------------------------------------------------------------------------- 1 | resources: 2 | repositories: 3 | - repository: pipelines_repo 4 | type: github 5 | endpoint: ROCm 6 | name: ROCm/ROCm 7 | 8 | variables: 9 | - group: common 10 | - template: /.azuredevops/variables-global.yml@pipelines_repo 11 | 12 | trigger: 13 | batch: true 14 | branches: 15 | include: 16 | - develop 17 | - mainline 18 | paths: 19 | exclude: 20 | - .githooks 21 | - .github 22 | - .jenkins 23 | - docs 24 | - '.*.y*ml' 25 | - '*.md' 26 | 27 | pr: 28 | autoCancel: true 29 | branches: 30 | include: 31 | - develop 32 | - mainline 33 | paths: 34 | exclude: 35 | - .githooks 36 | - .github 37 | - .jenkins 38 | - docs 39 | - '.*.y*ml' 40 | - '*.md' 41 | drafts: false 42 | 43 | jobs: 44 | - template: ${{ variables.CI_COMPONENT_PATH }}/rocALUTION.yml@pipelines_repo 45 | -------------------------------------------------------------------------------- /.githooks/install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd $(git rev-parse --git-dir) 4 | cd hooks 5 | 6 | echo "Installing hooks..." 7 | ln -fs ../../.githooks/pre-commit pre-commit 8 | echo "Done!" 9 | -------------------------------------------------------------------------------- /.githooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This pre-commit hook checks if any versions of clang-format 4 | # are installed, and if so, uses the installed version to format 5 | # the staged changes. 6 | 7 | export PATH=/usr/bin:/bin 8 | 9 | set -x 10 | 11 | format=/opt/rocm/llvm/bin/clang-format 12 | 13 | # Redirect stdout to stderr. 14 | exec >&2 15 | 16 | # Do everything from top - level 17 | cd $(git rev-parse --show-toplevel) 18 | 19 | if git rev-parse --verify HEAD >/dev/null 2>&1; then 20 | against=HEAD 21 | else 22 | # Initial commit: diff against an empty tree object 23 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 24 | fi 25 | 26 | if [[ "$1" == "--reformat" ]]; then 27 | files=$(git ls-files --exclude-standard) 28 | else 29 | files=$(git diff-index --cached --name-only $against) 30 | fi 31 | 32 | [[ -z "$files" ]] && exit 33 | 34 | # Change the copyright date at the top of any text files 35 | for file in $files; do 36 | if [[ -e $file ]]; then 37 | /usr/bin/perl -pi -e 'INIT { exit 1 if !-f $ARGV[0] || -B $ARGV[0]; $year = (localtime)[5] + 1900 } 38 | s/^([*\/#[:space:]]*)Copyright\s+(?:\(C\)\s*)?(\d+)(?:\s*-\s*\d+)?/qq($1Copyright (C) $2@{[$year != $2 ? "-$year" : ""]})/ie 39 | if $. < 10' "$file" && git add -u "$file" 40 | fi 41 | done 42 | 43 | # do the formatting 44 | for file in $files; do 45 | if [[ -e $file ]] && echo $file | grep -Eq '\.c$|\.h$|\.hpp$|\.cpp$|\.cl$|\.in$|\.txt$|\.yaml$|\.sh$|\.py$|\.pl$|\.cmake$|\.md$|\.rst$|\.groovy$'; then 46 | sed -i -e 's/[[:space:]]*$//' "$file" # Remove whitespace at end of lines 47 | sed -i -e '$a\' "$file" # Add missing newline to end of file 48 | # Convert UTF8 non-ASCII to ASCII 49 | temp=$(mktemp) 50 | [[ -w $temp ]] || exit 51 | iconv -s -f utf-8 -t ascii//TRANSLIT "$file" > "$temp" || exit 52 | chmod --reference="$file" "$temp" || exit 53 | mv -f "$temp" "$file" || exit 54 | git add -u "$file" 55 | fi 56 | done 57 | 58 | # if clang-format exists, run it on C/C++ files 59 | if [[ -x $format ]]; then 60 | for file in $files; do 61 | if [[ -e $file ]] && echo $file | grep -Eq '\.c$|\.h$|\.hpp$|\.cpp$|\.cl$|\.h\.in$|\.hpp\.in$|\.cpp\.in$'; then 62 | echo "$format $file" 63 | "$format" -i -style=file "$file" 64 | git add -u "$file" 65 | fi 66 | done 67 | fi 68 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @ntrost57 @YvanMokwinski @jsandham @kliegeois 2 | # Documentation files 3 | docs/* @ROCm/rocm-documentation 4 | *.md @ROCm/rocm-documentation 5 | *.rst @ROCm/rocm-documentation 6 | .readthedocs.yaml @ROCm/rocm-documentation 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "pip" # See documentation for possible values 9 | directory: "/docs/sphinx" # Location of package manifests 10 | open-pull-requests-limit: 10 11 | schedule: 12 | interval: "daily" 13 | target-branch: "develop" 14 | labels: 15 | - "documentation" 16 | - "dependencies" 17 | - "ci:docs-only" 18 | reviewers: 19 | - "samjwu" 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | 30 | # vim tags 31 | tags 32 | .tags 33 | .*.swp 34 | 35 | # Editors 36 | .vscode 37 | 38 | # build-in-source directory 39 | build 40 | 41 | # Visual Studio stuff 42 | *.vcxproj.user 43 | *.suo 44 | *.sdf 45 | *.pdb 46 | *.opensdf 47 | -------------------------------------------------------------------------------- /.jenkins/codecov.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | // This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/ 3 | @Library('rocJenkins@pong') _ 4 | 5 | // This is file for internal AMD use. 6 | // If you are interested in running your own Jenkins, please raise a github issue for assistance. 7 | 8 | import com.amd.project.* 9 | import com.amd.docker.* 10 | import java.nio.file.Path 11 | 12 | def runCI = 13 | { 14 | nodeDetails, jobName-> 15 | def prj = new rocProject('rocALUTION', 'CodeCov') 16 | 17 | // customize for project 18 | prj.paths.build_command = './install.sh -cg --codecoverage' 19 | prj.compiler.compiler_name = 'c++' 20 | prj.compiler.compiler_path = 'c++' 21 | prj.libraryDependencies = ['rocPRIM', 'hipBLAS-common', 'hipBLASLt', 'rocBLAS', 'rocSPARSE', 'rocRAND'] 22 | prj.defaults.ccache = false 23 | 24 | // Define test architectures, optional rocm version argument is available 25 | def nodes = new dockerNodes(nodeDetails, jobName, prj) 26 | 27 | def commonGroovy 28 | 29 | boolean formatCheck = false 30 | 31 | def compileCommand = 32 | { 33 | platform, project-> 34 | 35 | project.paths.construct_build_prefix() 36 | 37 | commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" 38 | commonGroovy.runCompileCommand(platform, project) 39 | } 40 | 41 | def testCommand = 42 | { 43 | platform, project-> 44 | 45 | def gfilter = "**" 46 | commonGroovy.runCoverageCommand(platform, project, gfilter, "debug") 47 | } 48 | 49 | buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, testCommand, null) 50 | } 51 | 52 | ci: { 53 | String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) 54 | 55 | def propertyList = ["compute-rocm-dkms-no-npi":[pipelineTriggers([cron('0 1 * * 6')])], 56 | "compute-rocm-dkms-no-npi-hipclang":[pipelineTriggers([cron('0 1 * * 6')])] ] 57 | propertyList = auxiliary.appendPropertyList(propertyList) 58 | 59 | def jobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['gfx900']]), 60 | "compute-rocm-dkms-no-npi-hipclang":([ubuntu18:['gfx900']])] 61 | jobNameList = auxiliary.appendJobNameList(jobNameList) 62 | 63 | propertyList.each 64 | { 65 | jobName, property-> 66 | if (urlJobName == jobName) 67 | properties(auxiliary.addCommonProperties(property)) 68 | } 69 | 70 | jobNameList.each 71 | { 72 | jobName, nodeDetails-> 73 | if (urlJobName == jobName) 74 | stage(jobName) { 75 | runCI(nodeDetails, jobName) 76 | } 77 | } 78 | 79 | // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 80 | if(!jobNameList.keySet().contains(urlJobName)) 81 | { 82 | properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) 83 | stage(urlJobName) { 84 | runCI([ubuntu18:['gfx900']], urlJobName) 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /.jenkins/debug.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | // This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/ 3 | @Library('rocJenkins@pong') _ 4 | 5 | // This is file for internal AMD use. 6 | // If you are interested in running your own Jenkins, please raise a github issue for assistance. 7 | 8 | import com.amd.project.* 9 | import com.amd.docker.* 10 | import java.nio.file.Path 11 | 12 | def runCI = 13 | { 14 | nodeDetails, jobName, buildCommand -> 15 | 16 | def prj = new rocProject('rocALUTION', 'Debug') 17 | // customize for project 18 | prj.paths.build_command = buildCommand 19 | prj.compiler.compiler_name = 'c++' 20 | prj.compiler.compiler_path = 'c++' 21 | prj.libraryDependencies = ['rocPRIM', 'hipBLAS-common', 'hipBLASLt', 'rocBLAS', 'rocSPARSE', 'rocRAND'] 22 | 23 | // Define test architectures, optional rocm version argument is available 24 | def nodes = new dockerNodes(nodeDetails, jobName, prj) 25 | 26 | def commonGroovy 27 | 28 | boolean formatCheck = false 29 | 30 | def compileCommand = 31 | { 32 | platform, project-> 33 | 34 | project.paths.construct_build_prefix() 35 | 36 | commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" 37 | commonGroovy.runCompileCommand(platform, project) 38 | } 39 | 40 | buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, null, null) 41 | } 42 | 43 | def setupCI(urlJobName, jobNameList, buildCommand, runCI, label) 44 | { 45 | jobNameList = auxiliary.appendJobNameList(jobNameList) 46 | 47 | jobNameList.each 48 | { 49 | jobName, nodeDetails-> 50 | if (urlJobName == jobName) 51 | stage(label + ' ' + jobName) { 52 | runCI(nodeDetails, jobName, buildCommand) 53 | } 54 | } 55 | 56 | // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 57 | if(!jobNameList.keySet().contains(urlJobName)) 58 | { 59 | properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) 60 | stage(label + ' ' + urlJobName) { 61 | runCI([ubuntu18:['any']], urlJobName, buildCommand) 62 | } 63 | } 64 | } 65 | 66 | ci: { 67 | String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) 68 | 69 | def propertyList = ["compute-rocm-dkms-no-npi":[pipelineTriggers([cron('0 1 * * 0')])], 70 | "rocm-docker":[]] 71 | 72 | propertyList = auxiliary.appendPropertyList(propertyList) 73 | 74 | propertyList.each 75 | { 76 | jobName, property-> 77 | if (urlJobName == jobName) 78 | properties(auxiliary.addCommonProperties(property)) 79 | } 80 | 81 | def defaultJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['any']]), 82 | "rocm-docker":([ubuntu18:['any']])] 83 | 84 | def hostJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['any']]), 85 | "rocm-docker":([ubuntu18:['any']])] 86 | 87 | def mpiJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['any']]), 88 | "rocm-docker":([ubuntu18:['any']])] 89 | 90 | String defaultBuildCommand = './install.sh -c' 91 | String hostBuildCommand = './install.sh -c --host' 92 | String mpiBuildCommand = './install.sh -c --host --mpi=on --no-openmp' 93 | 94 | setupCI(urlJobName, defaultJobNameList, defaultBuildCommand, runCI, '') 95 | setupCI(urlJobName, hostJobNameList, hostBuildCommand, runCI, 'Host') 96 | setupCI(urlJobName, mpiJobNameList, mpiBuildCommand, runCI, 'MPI') 97 | } 98 | -------------------------------------------------------------------------------- /.jenkins/staticanalysis.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | // This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/ 3 | @Library('rocJenkins@pong') _ 4 | 5 | // This is file for internal AMD use. 6 | // If you are interested in running your own Jenkins, please raise a github issue for assistance. 7 | 8 | import com.amd.project.* 9 | import com.amd.docker.* 10 | import java.nio.file.Path 11 | 12 | def runCompileCommand(platform, project, jobName, boolean debug=false) 13 | { 14 | project.paths.construct_build_prefix() 15 | } 16 | 17 | def runCI = 18 | { 19 | nodeDetails, jobName-> 20 | 21 | def prj = new rocProject('rocALUTION-internal', 'StaticAnalysis') 22 | 23 | // Define test architectures, optional rocm version argument is available 24 | def nodes = new dockerNodes(nodeDetails, jobName, prj) 25 | 26 | boolean formatCheck = true 27 | boolean staticAnalysis = true 28 | 29 | def compileCommand = 30 | { 31 | platform, project-> 32 | 33 | runCompileCommand(platform, project, jobName, false) 34 | } 35 | 36 | buildProject(prj , formatCheck, nodes.dockerArray, compileCommand, null, null, staticAnalysis) 37 | } 38 | 39 | ci: { 40 | String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) 41 | 42 | def propertyList = ["compute-rocm-dkms-no-npi-hipclang":[pipelineTriggers([cron('0 1 * * 0')])], 43 | "rocm-docker":[]] 44 | propertyList = auxiliary.appendPropertyList(propertyList) 45 | 46 | def jobNameList = ["compute-rocm-dkms-no-npi-hipclang":[]] 47 | jobNameList = auxiliary.appendJobNameList(jobNameList) 48 | 49 | propertyList.each 50 | { 51 | jobName, property-> 52 | if (urlJobName == jobName) 53 | properties(auxiliary.addCommonProperties(property)) 54 | } 55 | 56 | jobNameList.each 57 | { 58 | jobName, nodeDetails-> 59 | if (urlJobName == jobName) 60 | stage(jobName) { 61 | runCI(nodeDetails, jobName) 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | version: 2 5 | 6 | sphinx: 7 | configuration: docs/conf.py 8 | 9 | formats: [htmlzip, epub] 10 | 11 | python: 12 | install: 13 | - requirements: docs/sphinx/requirements.txt 14 | 15 | build: 16 | os: ubuntu-22.04 17 | tools: 18 | python: "3.10" 19 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /clients/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ######################################################################## 2 | # Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | # 22 | # ######################################################################## 23 | 24 | # The ROCm platform requires Ubuntu 16.04 or Fedora 24, which has cmake 3.5 25 | cmake_minimum_required(VERSION 3.5 FATAL_ERROR) 26 | 27 | # Consider removing this in the future 28 | # This should appear before the project command, because it does not use FORCE 29 | if(WIN32) 30 | set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories") 31 | else() 32 | set(CMAKE_INSTALL_PREFIX ${ROCM_PATH} CACHE PATH "Install path prefix, prepended onto install directories") 33 | endif() 34 | 35 | # This has to be initialized before the project() command appears 36 | # Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE 37 | if(NOT DEFINED CMAKE_CONFIGURATION_TYPES AND NOT DEFINED CMAKE_BUILD_TYPE) 38 | set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel.") 39 | endif() 40 | 41 | # This option only works for make/nmake and the ninja generators, but no reason it shouldn't be on all the time 42 | # This tells cmake to create a compile_commands.json file that can be used with clang tooling or vim 43 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 44 | 45 | # Build flags 46 | set(CMAKE_CXX_STANDARD 14) 47 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 48 | set(CMAKE_CXX_EXTENSIONS OFF) 49 | 50 | if(NOT TARGET rocalution) 51 | # This project may compile dependencies for clients 52 | project(rocalution-clients LANGUAGES CXX) 53 | 54 | find_package(rocalution REQUIRED CONFIG PATHS ${ROCM_PATH}/rocalution) 55 | get_target_property(depends roc::rocalution INTERFACE_LINK_LIBRARIES) 56 | 57 | # Check for MPI build 58 | foreach(i ${depends}) 59 | if("MPI::MPI_CXX" STREQUAL ${i}) 60 | set(SUPPORT_MPI ON) 61 | find_package(MPI REQUIRED) 62 | endif() 63 | endforeach() 64 | 65 | option(BUILD_CLIENTS_SAMPLES "Build examples." ON) 66 | option(BUILD_CLIENTS_BENCHMARKS "Build benchmarks." OFF) 67 | option(BUILD_CLIENTS_TESTS "Build tests." OFF) 68 | endif() 69 | 70 | if(BUILD_CLIENTS_SAMPLES) 71 | add_subdirectory(samples) 72 | endif() 73 | 74 | if(BUILD_CLIENTS_BENCHMARKS) 75 | add_subdirectory(benchmarks) 76 | endif() 77 | 78 | if(BUILD_CLIENTS_TESTS) 79 | enable_testing() 80 | add_subdirectory(tests) 81 | endif() 82 | -------------------------------------------------------------------------------- /clients/benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ######################################################################## 2 | # Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | # 22 | # ######################################################################## 23 | 24 | set(ROCALUTION_BENCHMARK_SOURCES 25 | client.cpp 26 | rocalution_arguments_config.cpp 27 | rocalution_bench.cpp 28 | rocalution_bench_solver_parameters.cpp 29 | rocalution_bench_solver_results.cpp 30 | rocalution_enum_coarsening_strategy.cpp 31 | rocalution_enum_directsolver.cpp 32 | rocalution_enum_itilu0_alg.cpp 33 | rocalution_enum_itsolver.cpp 34 | rocalution_enum_matrix_init.cpp 35 | rocalution_enum_preconditioner.cpp 36 | rocalution_enum_smoother.cpp 37 | rocalution_bench_cmdlines.cpp 38 | rocalution_bench_app.cpp 39 | ) 40 | 41 | add_executable(rocalution-bench ${ROCALUTION_BENCHMARK_SOURCES} ${ROCALUTION_CLIENTS_COMMON}) 42 | 43 | # Target compile options 44 | target_compile_options(rocalution-bench PRIVATE -Wall) 45 | 46 | # Internal common header 47 | target_include_directories(rocalution-bench PRIVATE $) 48 | 49 | # Target link libraries 50 | target_link_libraries(rocalution-bench PRIVATE roc::rocalution) 51 | 52 | if(NOT TARGET rocalution) 53 | set_target_properties(rocalution-bench PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging") 54 | else() 55 | set_target_properties(rocalution-bench PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/clients/staging") 56 | endif() 57 | 58 | rocm_install(TARGETS rocalution-bench COMPONENT benchmarks) 59 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_arguments_config.hpp: -------------------------------------------------------------------------------- 1 | /*! \file */ 2 | /* ************************************************************************ 3 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | * 23 | * ************************************************************************ */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | 29 | #include "program_options.hpp" 30 | #include "utility.hpp" 31 | 32 | #include "rocalution_bench_solver_parameters.hpp" 33 | 34 | // 35 | // @brief Class as an extension of Arguments to deal with the rocalution_bench. 36 | // 37 | struct rocalution_arguments_config : rocalution_bench_solver_parameters 38 | { 39 | 40 | char precision; 41 | char indextype; 42 | std::string function; 43 | int device_id; 44 | 45 | // 46 | // @brief Default constructor. 47 | // 48 | rocalution_arguments_config(); 49 | 50 | // 51 | // @brief Set the description. 52 | // 53 | void set_description(options_description& desc); 54 | 55 | // 56 | // @brief Parse command line arguments. 57 | // 58 | int parse(int& argc, char**& argv, options_description& desc); 59 | 60 | // 61 | // @brief Parse command line arguments with no default value. 62 | // 63 | int parse_no_default(int& argc, char**& argv, options_description& desc); 64 | }; 65 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_bench.hpp: -------------------------------------------------------------------------------- 1 | /*! \file */ 2 | /* ************************************************************************ 3 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | * 23 | * ************************************************************************ */ 24 | #pragma once 25 | 26 | #include "rocalution_arguments_config.hpp" 27 | #include "rocalution_enum_itsolver.hpp" 28 | 29 | // 30 | // @brief Class responsible of configuring the benchmark from parsing command line arguments 31 | // and execute it. 32 | // 33 | class rocalution_bench 34 | { 35 | public: 36 | // 37 | // @brief Default contructor. 38 | // 39 | rocalution_bench(); 40 | 41 | // 42 | // @brief Contructor with command line arguments. 43 | // 44 | rocalution_bench(int& argc, char**& argv); 45 | 46 | // 47 | // @brief Parenthesis operator equivalent to the contructor. 48 | // 49 | rocalution_bench& operator()(int& argc, char**& argv); 50 | 51 | // 52 | // @brief Run the benchmark. 53 | // 54 | bool run(); 55 | 56 | // 57 | // @brief Execute the benchmark. 58 | // 59 | bool execute(); 60 | 61 | // 62 | // @brief Get device id. 63 | // 64 | int get_device_id() const; 65 | 66 | // 67 | // @brief Get info devices. 68 | // 69 | void info_devices(std::ostream& out_) const; 70 | 71 | private: 72 | // 73 | // @brief Convert the command line arguments to rocalution_arguments_config. 74 | // 75 | void parse(int& argc, char**& argv, rocalution_arguments_config& config); 76 | 77 | // 78 | // @brief Description of the command line options. 79 | // 80 | options_description desc; 81 | 82 | // 83 | // @brief Configuration of the benchmark. 84 | // 85 | rocalution_arguments_config config; 86 | }; 87 | 88 | // 89 | // @brief Get rocalution version. 90 | // 91 | std::string rocalution_get_version(); 92 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_bench_cmdlines.cpp: -------------------------------------------------------------------------------- 1 | #include "rocalution_bench_cmdlines.hpp" 2 | 3 | // 4 | // @brief Get the output filename. 5 | // 6 | const char* rocalution_bench_cmdlines::get_ofilename() const 7 | { 8 | return this->m_cmd.get_ofilename(); 9 | } 10 | 11 | // 12 | // @brief Get the number of samples.. 13 | // 14 | int rocalution_bench_cmdlines::get_nsamples() const 15 | { 16 | return this->m_cmd.get_nsamples(); 17 | }; 18 | int rocalution_bench_cmdlines::get_option_index_x() const 19 | { 20 | return this->m_cmd.get_option_index_x(); 21 | }; 22 | 23 | int rocalution_bench_cmdlines::get_option_nargs(int i) 24 | { 25 | return this->m_cmd.get_option_nargs(i); 26 | } 27 | const char* rocalution_bench_cmdlines::get_option_arg(int i, int j) 28 | { 29 | return this->m_cmd.get_option_arg(i, j); 30 | } 31 | const char* rocalution_bench_cmdlines::get_option_name(int i) 32 | { 33 | return this->m_cmd.get_option_name(i); 34 | } 35 | int rocalution_bench_cmdlines::get_noptions_x() const 36 | { 37 | return this->m_cmd.get_noptions_x(); 38 | }; 39 | int rocalution_bench_cmdlines::get_noptions() const 40 | { 41 | return this->m_cmd.get_noptions(); 42 | }; 43 | bool rocalution_bench_cmdlines::is_stdout_disabled() const 44 | { 45 | return this->m_cmd.is_stdout_disabled(); 46 | }; 47 | 48 | // 49 | // @brief Get the number of runs per sample. 50 | // 51 | int rocalution_bench_cmdlines::get_nruns() const 52 | { 53 | return this->m_cmd.get_nruns(); 54 | }; 55 | 56 | // 57 | // @brief Copy the command line arguments corresponding to a given sample. 58 | // 59 | void rocalution_bench_cmdlines::get(int isample, int& argc, char** argv) const 60 | { 61 | const auto& cmdsample = this->m_cmdset[isample]; 62 | for(int j = 0; j < cmdsample.argc; ++j) 63 | { 64 | argv[j] = cmdsample.argv[j]; 65 | } 66 | argc = cmdsample.argc; 67 | } 68 | 69 | void rocalution_bench_cmdlines::get_argc(int isample, int& argc_) const 70 | { 71 | argc_ = this->m_cmdset[isample].argc; 72 | } 73 | 74 | // 75 | // @brief Constructor. 76 | // 77 | rocalution_bench_cmdlines::rocalution_bench_cmdlines(int argc, char** argv) 78 | : m_cmd(argc, argv) 79 | { 80 | // 81 | // Expand the command line . 82 | // 83 | this->m_cmdset = new val[this->m_cmd.get_nsamples()]; 84 | this->m_cmd.expand(this->m_cmdset); 85 | } 86 | 87 | bool rocalution_bench_cmdlines::applies(int argc, char** argv) 88 | { 89 | for(int i = 1; i < argc; ++i) 90 | { 91 | if(!strcmp(argv[i], "--bench-x") || !strcmp(argv[i], "--bench-o") 92 | || !strcmp(argv[i], "--bench-n") || !strcmp(argv[i], "--bench-std")) 93 | { 94 | return true; 95 | } 96 | } 97 | return false; 98 | } 99 | 100 | void rocalution_bench_cmdlines::info() const 101 | { 102 | int nsamples = this->m_cmd.get_nsamples(); 103 | for(int isample = 0; isample < nsamples; ++isample) 104 | { 105 | const auto& cmdsample = this->m_cmdset[isample]; 106 | const auto argc = cmdsample.argc; 107 | const auto argv = cmdsample.argv; 108 | std::cout << "sample[" << isample << "/" << nsamples << "], argc = " << argc << std::endl; 109 | 110 | for(int jarg = 0; jarg < argc; ++jarg) 111 | { 112 | std::cout << " " << argv[jarg]; 113 | } 114 | std::cout << std::endl; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_bench_template.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #pragma once 25 | 26 | #include "rocalution_bench_solver.hpp" 27 | 28 | // 29 | // @brief One function to call the bench execution. 30 | // 31 | template 32 | bool rocalution_bench_template(const rocalution_arguments_config& config) 33 | { 34 | try 35 | { 36 | rocalution_bench_solver bench_solver(&config); 37 | bool success = bench_solver.Run(); 38 | return success; 39 | } 40 | catch(bool) 41 | { 42 | rocalution_bench_errmsg << "rocalution_bench_template failure" << std::endl; 43 | ; 44 | return false; 45 | } 46 | catch(std::exception&) 47 | { 48 | rocalution_bench_errmsg << "rocalution_bench_template unknown failure" << std::endl; 49 | ; 50 | return false; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_driver_itsolver_fgmres.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #pragma once 25 | #include "rocalution_driver_itsolver.hpp" 26 | 27 | template 28 | struct rocalution_driver_itsolver 29 | : rocalution_driver_itsolver_default 30 | { 31 | 32 | static constexpr auto ITSOLVER = rocalution_enum_itsolver::fgmres; 33 | using traits_t = rocalution_driver_itsolver_traits; 34 | using solver_t = typename traits_t::solver_t; 35 | using params_t = rocalution_bench_solver_parameters; 36 | 37 | virtual bool PreprocessSolverBuild(LocalMatrix& A, 38 | LocalVector& B, 39 | LocalVector& X, 40 | solver_t& solver, 41 | const params_t& parameters) override 42 | { 43 | const auto krylov_basis = parameters.Get(params_t::krylov_basis); 44 | solver.SetBasisSize(krylov_basis); 45 | return true; 46 | }; 47 | }; 48 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_driver_itsolver_gmres.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | #pragma once 24 | 25 | #include "rocalution_driver_itsolver.hpp" 26 | 27 | template 28 | struct rocalution_driver_itsolver 29 | : rocalution_driver_itsolver_default 30 | { 31 | static constexpr auto ITSOLVER = rocalution_enum_itsolver::gmres; 32 | using traits_t = rocalution_driver_itsolver_traits; 33 | using solver_t = typename traits_t::solver_t; 34 | using params_t = rocalution_bench_solver_parameters; 35 | 36 | virtual bool PreprocessSolverBuild(LocalMatrix& A, 37 | LocalVector& B, 38 | LocalVector& X, 39 | solver_t& solver, 40 | const params_t& parameters) override 41 | { 42 | const auto krylov_basis = parameters.Get(params_t::krylov_basis); 43 | solver.SetBasisSize(krylov_basis); 44 | return true; 45 | }; 46 | }; 47 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_coarsening_strategy.cpp: -------------------------------------------------------------------------------- 1 | /*! \file */ 2 | /* ************************************************************************ 3 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | * 23 | * ************************************************************************ */ 24 | #include "rocalution_enum_coarsening_strategy.hpp" 25 | 26 | constexpr const char* 27 | rocalution_enum_coarsening_strategy::names[rocalution_enum_coarsening_strategy::size]; 28 | constexpr rocalution_enum_coarsening_strategy::value_type 29 | rocalution_enum_coarsening_strategy::all[rocalution_enum_coarsening_strategy::size]; 30 | 31 | #include 32 | bool rocalution_enum_coarsening_strategy::is_invalid() const 33 | { 34 | for(auto v : all) 35 | { 36 | if(this->value == v) 37 | { 38 | return false; 39 | } 40 | } 41 | return true; 42 | } 43 | 44 | rocalution_enum_coarsening_strategy::rocalution_enum_coarsening_strategy(const char* name_) 45 | { 46 | for(auto v : all) 47 | { 48 | if(!strcmp(name_, names[v])) 49 | { 50 | this->value = v; 51 | return; 52 | } 53 | } 54 | 55 | rocalution_bench_errmsg << "coarsening_strategy '" << name_ 56 | << "' is invalid, the list of valid coarsening_strategys is" 57 | << std::endl; 58 | for(auto v : all) 59 | { 60 | rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; 61 | } 62 | throw false; 63 | }; 64 | 65 | // 66 | // Default contructor. 67 | // 68 | rocalution_enum_coarsening_strategy::rocalution_enum_coarsening_strategy() 69 | : value((value_type)-1){}; 70 | 71 | // 72 | // 73 | // 74 | rocalution_enum_coarsening_strategy& 75 | rocalution_enum_coarsening_strategy::operator()(const char* name_) 76 | { 77 | this->value = (value_type)-1; 78 | for(auto v : all) 79 | { 80 | if(!strcmp(name_, names[v])) 81 | { 82 | this->value = v; 83 | return *this; 84 | } 85 | } 86 | 87 | rocalution_bench_errmsg << "coarsening_strategy '" << name_ 88 | << "' is invalid, the list of valid coarsening_strategys is" 89 | << std::endl; 90 | for(auto v : all) 91 | { 92 | rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; 93 | } 94 | 95 | throw false; 96 | } 97 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_coarsening_strategy.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #pragma once 25 | #include "rocalution/rocalution.hpp" 26 | #include "utility.hpp" 27 | 28 | #include 29 | 30 | struct rocalution_enum_coarsening_strategy 31 | { 32 | 33 | #define LIST_ROCALUTION_ENUM_COARSENING_STRATEGY \ 34 | ENUM_COARSENING_STRATEGY(Greedy) \ 35 | ENUM_COARSENING_STRATEGY(PMIS) 36 | 37 | // 38 | // 39 | // 40 | #define ENUM_COARSENING_STRATEGY(x_) x_, 41 | 42 | typedef enum rocalution_enum_coarsening_strategy__ : int 43 | { 44 | LIST_ROCALUTION_ENUM_COARSENING_STRATEGY 45 | } value_type; 46 | 47 | static constexpr value_type all[]{LIST_ROCALUTION_ENUM_COARSENING_STRATEGY}; 48 | static constexpr std::size_t size = countof(all); 49 | 50 | #undef ENUM_COARSENING_STRATEGY 51 | 52 | // 53 | // 54 | // 55 | #define ENUM_COARSENING_STRATEGY(x_) #x_, 56 | 57 | static constexpr const char* names[size]{LIST_ROCALUTION_ENUM_COARSENING_STRATEGY}; 58 | 59 | #undef ENUM_COARSENING_STRATEGY 60 | 61 | bool is_invalid() const; 62 | rocalution_enum_coarsening_strategy(); 63 | rocalution_enum_coarsening_strategy& operator()(const char* name_); 64 | rocalution_enum_coarsening_strategy(const char* name_); 65 | 66 | value_type value{}; 67 | }; 68 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_directsolver.cpp: -------------------------------------------------------------------------------- 1 | /*! \file */ 2 | /* ************************************************************************ 3 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | * 23 | * ************************************************************************ */ 24 | #include "rocalution_enum_directsolver.hpp" 25 | #include 26 | constexpr const char* rocalution_enum_directsolver::names[rocalution_enum_directsolver::size]; 27 | constexpr rocalution_enum_directsolver::value_type rocalution_enum_directsolver::all[]; 28 | 29 | const char* rocalution_enum_directsolver::to_string() const 30 | { 31 | return rocalution_enum_directsolver::to_string(this->value); 32 | } 33 | 34 | bool rocalution_enum_directsolver::is_invalid() const 35 | { 36 | for(auto v : all) 37 | { 38 | if(this->value == v) 39 | { 40 | return false; 41 | } 42 | } 43 | return true; 44 | } 45 | 46 | rocalution_enum_directsolver::rocalution_enum_directsolver(const char* name) 47 | { 48 | this->value = (value_type)-1; 49 | for(auto v : all) 50 | { 51 | const char* str = names[v]; 52 | if(!strcmp(name, str)) 53 | { 54 | this->value = v; 55 | break; 56 | } 57 | } 58 | 59 | rocalution_bench_errmsg << "direct solver '" << name 60 | << "' is invalid, the list of valid direct solvers is" << std::endl; 61 | for(auto v : all) 62 | { 63 | const char* str = names[v]; 64 | rocalution_bench_errmsg << " - '" << str << "'" << std::endl; 65 | } 66 | throw false; 67 | } 68 | 69 | // 70 | // Default contructor. 71 | // 72 | rocalution_enum_directsolver::rocalution_enum_directsolver() 73 | : value((value_type)-1){}; 74 | 75 | // 76 | // 77 | // 78 | rocalution_enum_directsolver& rocalution_enum_directsolver::operator()(const char* function) 79 | { 80 | this->value = (value_type)-1; 81 | for(auto v : all) 82 | { 83 | const char* str = names[v]; 84 | if(!strcmp(function, str)) 85 | { 86 | this->value = v; 87 | break; 88 | } 89 | } 90 | return *this; 91 | } 92 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_directsolver.hpp: -------------------------------------------------------------------------------- 1 | /*! \file */ 2 | /* ************************************************************************ 3 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | * 23 | * ************************************************************************ */ 24 | #pragma once 25 | #include "utility.hpp" 26 | #include 27 | // 28 | // List the enumeration values. 29 | // 30 | 31 | // clang-format off 32 | #define ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM_EACH \ 33 | ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(inversion) \ 34 | ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(lu) \ 35 | ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(qr) 36 | // clang-format on 37 | 38 | struct rocalution_enum_directsolver 39 | { 40 | private: 41 | public: 42 | #define ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(x_) x_, 43 | typedef enum rocalution_enum_directsolver__ : int 44 | { 45 | ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM_EACH 46 | } value_type; 47 | static constexpr value_type all[] = {ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM_EACH}; 48 | #undef ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM 49 | static constexpr std::size_t size = countof(all); 50 | value_type value{}; 51 | 52 | private: 53 | #define ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(x_) #x_, 54 | static constexpr const char* names[size]{ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM_EACH}; 55 | #undef ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM 56 | public: 57 | operator value_type() const 58 | { 59 | return this->value; 60 | }; 61 | rocalution_enum_directsolver(); 62 | rocalution_enum_directsolver& operator()(const char* function); 63 | rocalution_enum_directsolver(const char* function); 64 | const char* to_string() const; 65 | bool is_invalid() const; 66 | static inline const char* to_string(rocalution_enum_directsolver::value_type value) 67 | { 68 | // 69 | // switch for checking inconsistency. 70 | // 71 | switch(value) 72 | { 73 | /// 74 | #define ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM(x_) \ 75 | case x_: \ 76 | { \ 77 | if(strcmp(#x_, names[value])) \ 78 | return nullptr; \ 79 | break; \ 80 | } 81 | 82 | ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM_EACH; 83 | 84 | #undef ROCALUTION_ENUM_DIRECTSOLVER_TRANSFORM 85 | /// 86 | } 87 | 88 | return names[value]; 89 | } 90 | }; 91 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_directsolver_traits.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #pragma once 25 | 26 | #include "rocalution_bench_solver_template_base.hpp" 27 | #include "rocalution_enum_directsolver.hpp" 28 | 29 | using namespace rocalution; 30 | 31 | template 32 | struct rocalution_enum_directsolver_traits; 33 | 34 | template 35 | struct rocalution_enum_directsolver_traits 36 | { 37 | using solver_t = LU, LocalVector, T>; 38 | }; 39 | 40 | template 41 | struct rocalution_enum_directsolver_traits 42 | { 43 | using solver_t = QR, LocalVector, T>; 44 | }; 45 | 46 | template 47 | struct rocalution_enum_directsolver_traits 48 | { 49 | using solver_t = Inversion, LocalVector, T>; 50 | }; 51 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_itsolver.cpp: -------------------------------------------------------------------------------- 1 | /*! \file */ 2 | /* ************************************************************************ 3 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | * 23 | * ************************************************************************ */ 24 | #include "rocalution_enum_itsolver.hpp" 25 | #include 26 | constexpr const char* rocalution_enum_itsolver::names[rocalution_enum_itsolver::size]; 27 | constexpr rocalution_enum_itsolver::value_type rocalution_enum_itsolver::all[]; 28 | 29 | const char* rocalution_enum_itsolver::to_string() const 30 | { 31 | return rocalution_enum_itsolver::to_string(this->value); 32 | } 33 | 34 | bool rocalution_enum_itsolver::is_invalid() const 35 | { 36 | for(auto v : all) 37 | { 38 | if(this->value == v) 39 | { 40 | return false; 41 | } 42 | } 43 | return true; 44 | } 45 | 46 | rocalution_enum_itsolver::rocalution_enum_itsolver(const char* itsolver_name) 47 | { 48 | this->value = (value_type)-1; 49 | for(auto v : all) 50 | { 51 | const char* str = names[v]; 52 | if(!strcmp(itsolver_name, str)) 53 | { 54 | this->value = v; 55 | return; 56 | } 57 | } 58 | 59 | rocalution_bench_errmsg << "iterative solver '" << itsolver_name 60 | << "' is invalid, the list of valid iterative solvers is" << std::endl; 61 | for(auto v : all) 62 | { 63 | const char* str = names[v]; 64 | rocalution_bench_errmsg << " - '" << str << "'" << std::endl; 65 | } 66 | throw false; 67 | } 68 | 69 | // 70 | // Default contructor. 71 | // 72 | rocalution_enum_itsolver::rocalution_enum_itsolver() 73 | : value((value_type)-1){}; 74 | 75 | // 76 | // 77 | // 78 | rocalution_enum_itsolver& rocalution_enum_itsolver::operator()(const char* itsolver_name) 79 | { 80 | this->value = (value_type)-1; 81 | for(auto v : all) 82 | { 83 | const char* str = names[v]; 84 | if(!strcmp(itsolver_name, str)) 85 | { 86 | this->value = v; 87 | return *this; 88 | } 89 | } 90 | 91 | rocalution_bench_errmsg << "iterative solver '" << itsolver_name 92 | << "' is invalid, the list of valid iterative solvers is" << std::endl; 93 | for(auto v : all) 94 | { 95 | const char* str = names[v]; 96 | rocalution_bench_errmsg << " - '" << str << "'" << std::endl; 97 | } 98 | throw false; 99 | } 100 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_matrix_init.cpp: -------------------------------------------------------------------------------- 1 | /*! \file */ 2 | /* ************************************************************************ 3 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | * 23 | * ************************************************************************ */ 24 | #include "rocalution_enum_matrix_init.hpp" 25 | 26 | constexpr const char* rocalution_enum_matrix_init::names[rocalution_enum_matrix_init::size]; 27 | constexpr rocalution_enum_matrix_init::value_type 28 | rocalution_enum_matrix_init::all[rocalution_enum_matrix_init::size]; 29 | 30 | #include 31 | bool rocalution_enum_matrix_init::is_invalid() const 32 | { 33 | for(auto v : all) 34 | { 35 | if(this->value == v) 36 | { 37 | return false; 38 | } 39 | } 40 | return true; 41 | } 42 | 43 | rocalution_enum_matrix_init::rocalution_enum_matrix_init(const char* name_) 44 | { 45 | for(auto v : all) 46 | { 47 | if(!strcmp(name_, names[v])) 48 | { 49 | this->value = v; 50 | return; 51 | } 52 | } 53 | rocalution_bench_errmsg << "matrix initialization '" << name_ 54 | << "' is invalid, the list of valid matrix initialization is" 55 | << std::endl; 56 | for(auto v : all) 57 | { 58 | rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; 59 | } 60 | throw false; 61 | }; 62 | 63 | // 64 | // Default contructor. 65 | // 66 | rocalution_enum_matrix_init::rocalution_enum_matrix_init() 67 | : value((value_type)-1){}; 68 | 69 | // 70 | // 71 | // 72 | rocalution_enum_matrix_init& rocalution_enum_matrix_init::operator()(const char* name_) 73 | { 74 | this->value = (value_type)-1; 75 | for(auto v : all) 76 | { 77 | if(!strcmp(name_, names[v])) 78 | { 79 | this->value = v; 80 | return *this; 81 | } 82 | } 83 | 84 | rocalution_bench_errmsg << "matrix initialization '" << name_ 85 | << "' is invalid, the list of valid matrix initialization is" 86 | << std::endl; 87 | for(auto v : all) 88 | { 89 | rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; 90 | } 91 | 92 | throw false; 93 | } 94 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_matrix_init.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #pragma once 25 | #include "rocalution/rocalution.hpp" 26 | #include "utility.hpp" 27 | 28 | #include 29 | 30 | struct rocalution_enum_matrix_init 31 | { 32 | 33 | #define LIST_ROCALUTION_ENUM_MATRIX_INIT \ 34 | ENUM_MATRIX_INIT(laplacian) \ 35 | ENUM_MATRIX_INIT(permuted_identity) \ 36 | ENUM_MATRIX_INIT(file) 37 | 38 | // 39 | // 40 | // 41 | #define ENUM_MATRIX_INIT(x_) x_, 42 | 43 | typedef enum rocalution_enum_matrix_init__ : int 44 | { 45 | LIST_ROCALUTION_ENUM_MATRIX_INIT 46 | } value_type; 47 | 48 | static constexpr value_type all[]{LIST_ROCALUTION_ENUM_MATRIX_INIT}; 49 | static constexpr std::size_t size = countof(all); 50 | 51 | #undef ENUM_MATRIX_INIT 52 | 53 | // 54 | // 55 | // 56 | #define ENUM_MATRIX_INIT(x_) #x_, 57 | 58 | static constexpr const char* names[size]{LIST_ROCALUTION_ENUM_MATRIX_INIT}; 59 | 60 | #undef ENUM_MATRIX_INIT 61 | 62 | bool is_invalid() const; 63 | rocalution_enum_matrix_init(); 64 | rocalution_enum_matrix_init& operator()(const char* name_); 65 | rocalution_enum_matrix_init(const char* name_); 66 | 67 | value_type value{}; 68 | }; 69 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_preconditioner.cpp: -------------------------------------------------------------------------------- 1 | /*! \file */ 2 | /* ************************************************************************ 3 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | * 23 | * ************************************************************************ */ 24 | #include "rocalution_enum_preconditioner.hpp" 25 | 26 | constexpr const char* rocalution_enum_preconditioner::names[rocalution_enum_preconditioner::size]; 27 | constexpr rocalution_enum_preconditioner::value_type 28 | rocalution_enum_preconditioner::all[rocalution_enum_preconditioner::size]; 29 | 30 | #include 31 | bool rocalution_enum_preconditioner::is_invalid() const 32 | { 33 | for(auto v : all) 34 | { 35 | if(this->value == v) 36 | { 37 | return false; 38 | } 39 | } 40 | return true; 41 | } 42 | 43 | rocalution_enum_preconditioner::rocalution_enum_preconditioner(const char* name_) 44 | { 45 | for(auto v : all) 46 | { 47 | if(!strcmp(name_, names[v])) 48 | { 49 | this->value = v; 50 | return; 51 | } 52 | } 53 | 54 | rocalution_bench_errmsg << "preconditioner '" << name_ 55 | << "' is invalid, the list of valid preconditioners is" << std::endl; 56 | for(auto v : all) 57 | { 58 | rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; 59 | } 60 | throw false; 61 | }; 62 | 63 | // 64 | // Default contructor. 65 | // 66 | rocalution_enum_preconditioner::rocalution_enum_preconditioner() 67 | : value((value_type)-1){}; 68 | 69 | // 70 | // 71 | // 72 | rocalution_enum_preconditioner& rocalution_enum_preconditioner::operator()(const char* name_) 73 | { 74 | this->value = (value_type)-1; 75 | for(auto v : all) 76 | { 77 | if(!strcmp(name_, names[v])) 78 | { 79 | this->value = v; 80 | return *this; 81 | } 82 | } 83 | 84 | rocalution_bench_errmsg << "preconditioner '" << name_ 85 | << "' is invalid, the list of valid preconditioners is" << std::endl; 86 | for(auto v : all) 87 | { 88 | rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; 89 | } 90 | 91 | throw false; 92 | } 93 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_preconditioner.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #pragma once 25 | #include "rocalution/rocalution.hpp" 26 | #include "utility.hpp" 27 | 28 | #include 29 | 30 | struct rocalution_enum_preconditioner 31 | { 32 | 33 | #define LIST_ROCALUTION_ENUM_PRECONDITIONER \ 34 | ENUM_PRECONDITIONER(none) \ 35 | ENUM_PRECONDITIONER(chebyshev) \ 36 | ENUM_PRECONDITIONER(FSAI) \ 37 | ENUM_PRECONDITIONER(SPAI) \ 38 | ENUM_PRECONDITIONER(TNS) \ 39 | ENUM_PRECONDITIONER(Jacobi) \ 40 | ENUM_PRECONDITIONER(GS) \ 41 | ENUM_PRECONDITIONER(SGS) \ 42 | ENUM_PRECONDITIONER(ILU) \ 43 | ENUM_PRECONDITIONER(ItILU0) \ 44 | ENUM_PRECONDITIONER(ILUT) \ 45 | ENUM_PRECONDITIONER(IC) \ 46 | ENUM_PRECONDITIONER(MCGS) \ 47 | ENUM_PRECONDITIONER(MCSGS) \ 48 | ENUM_PRECONDITIONER(MCILU) 49 | 50 | // 51 | // 52 | // 53 | #define ENUM_PRECONDITIONER(x_) x_, 54 | 55 | typedef enum rocalution_enum_preconditioner__ : int 56 | { 57 | LIST_ROCALUTION_ENUM_PRECONDITIONER 58 | } value_type; 59 | 60 | static constexpr value_type all[]{LIST_ROCALUTION_ENUM_PRECONDITIONER}; 61 | static constexpr std::size_t size = countof(all); 62 | 63 | #undef ENUM_PRECONDITIONER 64 | 65 | // 66 | // 67 | // 68 | #define ENUM_PRECONDITIONER(x_) #x_, 69 | 70 | static constexpr const char* names[size]{LIST_ROCALUTION_ENUM_PRECONDITIONER}; 71 | 72 | #undef ENUM_PRECONDITIONER 73 | 74 | bool is_invalid() const; 75 | rocalution_enum_preconditioner(); 76 | rocalution_enum_preconditioner& operator()(const char* name_); 77 | rocalution_enum_preconditioner(const char* name_); 78 | 79 | value_type value{}; 80 | }; 81 | 82 | // constexpr const char * rocalution_enum_preconditioner::names[rocalution_enum_preconditioner::size]; 83 | // constexpr rocalution_enum_preconditioner::value_type rocalution_enum_preconditioner::all[rocalution_enum_preconditioner::size]; 84 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_smoother.cpp: -------------------------------------------------------------------------------- 1 | /*! \file */ 2 | /* ************************************************************************ 3 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | * 23 | * ************************************************************************ */ 24 | #include "rocalution_enum_smoother.hpp" 25 | 26 | constexpr const char* rocalution_enum_smoother::names[rocalution_enum_smoother::size]; 27 | constexpr rocalution_enum_smoother::value_type 28 | rocalution_enum_smoother::all[rocalution_enum_smoother::size]; 29 | 30 | #include 31 | bool rocalution_enum_smoother::is_invalid() const 32 | { 33 | for(auto v : all) 34 | { 35 | if(this->value == v) 36 | { 37 | return false; 38 | } 39 | } 40 | return true; 41 | } 42 | 43 | rocalution_enum_smoother::rocalution_enum_smoother(const char* name_) 44 | { 45 | for(auto v : all) 46 | { 47 | if(!strcmp(name_, names[v])) 48 | { 49 | this->value = v; 50 | return; 51 | } 52 | } 53 | 54 | rocalution_bench_errmsg << "smoother '" << name_ 55 | << "' is invalid, the list of valid smoothers is" << std::endl; 56 | for(auto v : all) 57 | { 58 | rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; 59 | } 60 | throw false; 61 | }; 62 | 63 | // 64 | // Default contructor. 65 | // 66 | rocalution_enum_smoother::rocalution_enum_smoother() 67 | : value((value_type)-1){}; 68 | 69 | // 70 | // 71 | // 72 | rocalution_enum_smoother& rocalution_enum_smoother::operator()(const char* name_) 73 | { 74 | this->value = (value_type)-1; 75 | for(auto v : all) 76 | { 77 | if(!strcmp(name_, names[v])) 78 | { 79 | this->value = v; 80 | return *this; 81 | } 82 | } 83 | 84 | rocalution_bench_errmsg << "smoother '" << name_ 85 | << "' is invalid, the list of valid smoothers is" << std::endl; 86 | for(auto v : all) 87 | { 88 | rocalution_bench_errmsg << " - '" << names[v] << "'" << std::endl; 89 | } 90 | 91 | throw false; 92 | } 93 | -------------------------------------------------------------------------------- /clients/benchmarks/rocalution_enum_smoother.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #pragma once 25 | #include "rocalution/rocalution.hpp" 26 | #include "utility.hpp" 27 | 28 | #include 29 | 30 | struct rocalution_enum_smoother 31 | { 32 | 33 | #define LIST_ROCALUTION_ENUM_SMOOTHER \ 34 | ENUM_SMOOTHER(FSAI) \ 35 | ENUM_SMOOTHER(ILU) 36 | 37 | // 38 | // 39 | // 40 | #define ENUM_SMOOTHER(x_) x_, 41 | 42 | typedef enum rocalution_enum_smoother__ : int 43 | { 44 | LIST_ROCALUTION_ENUM_SMOOTHER 45 | } value_type; 46 | 47 | static constexpr value_type all[]{LIST_ROCALUTION_ENUM_SMOOTHER}; 48 | static constexpr std::size_t size = countof(all); 49 | 50 | #undef ENUM_SMOOTHER 51 | 52 | // 53 | // 54 | // 55 | #define ENUM_SMOOTHER(x_) #x_, 56 | 57 | static constexpr const char* names[size]{LIST_ROCALUTION_ENUM_SMOOTHER}; 58 | 59 | #undef ENUM_SMOOTHER 60 | 61 | bool is_invalid() const; 62 | rocalution_enum_smoother(); 63 | rocalution_enum_smoother& operator()(const char* name_); 64 | rocalution_enum_smoother(const char* name_); 65 | 66 | value_type value{}; 67 | }; 68 | -------------------------------------------------------------------------------- /clients/include/random.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #include "random.hpp" 25 | 26 | // Random number generator 27 | // Note: We do not use random_device to initialize the RNG, because we want 28 | // repeatability in case of test failure. TODO: Add seed as an optional CLI 29 | // argument, and print the seed on output, to ensure repeatability. 30 | rocalution_rng_t rocalution_rng(69069); 31 | rocalution_rng_t rocalution_seed(rocalution_rng); 32 | 33 | void rocalution_rng_set(rocalution_rng_t a) 34 | { 35 | rocalution_rng = a; 36 | } 37 | 38 | void rocalution_seed_set(rocalution_rng_t a) 39 | { 40 | rocalution_seed = a; 41 | } 42 | 43 | rocalution_rng_t& rocalution_rng_get() 44 | { 45 | return rocalution_rng; 46 | } 47 | 48 | rocalution_rng_t& rocalution_seed_get() 49 | { 50 | return rocalution_seed; 51 | } 52 | -------------------------------------------------------------------------------- /clients/include/testing_global_vector.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #pragma once 25 | #ifndef TESTING_GLOBAL_VECTOR_HPP 26 | #define TESTING_GLOBAL_VECTOR_HPP 27 | 28 | #include "utility.hpp" 29 | 30 | #include 31 | #include 32 | 33 | using namespace rocalution; 34 | 35 | template 36 | void testing_global_vector_bad_args(void) 37 | { 38 | int safe_size = 100; 39 | 40 | // Initialize rocALUTION 41 | set_device_rocalution(device); 42 | init_rocalution(); 43 | 44 | GlobalVector vec; 45 | 46 | // SetDataPtr 47 | { 48 | T* null_data = nullptr; 49 | ASSERT_DEATH(vec.SetDataPtr(nullptr, "", safe_size), ".*Assertion.*ptr != (NULL|__null)*"); 50 | ASSERT_DEATH(vec.SetDataPtr(&null_data, "", safe_size), 51 | ".*Assertion.*ptr != (NULL|__null)*"); 52 | } 53 | 54 | // LeaveDataPtr 55 | { 56 | T* data = nullptr; 57 | allocate_host(safe_size, &data); 58 | ASSERT_DEATH(vec.LeaveDataPtr(&data), ".*Assertion.*ptr == (NULL|__null)*"); 59 | free_host(&data); 60 | } 61 | 62 | // Stop rocALUTION 63 | stop_rocalution(); 64 | } 65 | 66 | #endif // TESTING_GLOBAL_VECTOR_HPP 67 | -------------------------------------------------------------------------------- /clients/include/testing_local_stencil.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #pragma once 25 | #ifndef TESTING_LOCAL_STENCIL_HPP 26 | #define TESTING_LOCAL_STENCIL_HPP 27 | 28 | #include "utility.hpp" 29 | 30 | #include 31 | #include 32 | 33 | using namespace rocalution; 34 | 35 | template 36 | void testing_local_stencil_bad_args(void) 37 | { 38 | // Initialize rocALUTION 39 | set_device_rocalution(device); 40 | init_rocalution(); 41 | 42 | LocalStencil stn(Laplace2D); 43 | LocalVector vec; 44 | 45 | // Apply 46 | { 47 | LocalVector* null_vec = nullptr; 48 | ASSERT_DEATH(stn.Apply(vec, null_vec), ".*Assertion.*out != (NULL|__null)*"); 49 | } 50 | 51 | // ApplyAdd 52 | { 53 | LocalVector* null_vec = nullptr; 54 | ASSERT_DEATH(stn.ApplyAdd(vec, 1.0, null_vec), ".*Assertion.*out != (NULL|__null)*"); 55 | } 56 | 57 | // Stop rocALUTION 58 | stop_rocalution(); 59 | } 60 | 61 | #endif // TESTING_LOCAL_STENCIL_HPP 62 | -------------------------------------------------------------------------------- /clients/include/testing_parallel_manager.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #pragma once 25 | #ifndef TESTING_PARALLEL_MANAGER_HPP 26 | #define TESTING_PARALLEL_MANAGER_HPP 27 | 28 | #include "utility.hpp" 29 | 30 | #include 31 | #include 32 | 33 | using namespace rocalution; 34 | 35 | template 36 | void testing_parallel_manager_bad_args(void) 37 | { 38 | int safe_size = 100; 39 | 40 | // Initialize rocALUTION 41 | set_device_rocalution(device); 42 | init_rocalution(); 43 | 44 | ParallelManager pm; 45 | 46 | int* idata = nullptr; 47 | allocate_host(safe_size, &idata); 48 | 49 | // SetMPICommunicator 50 | { 51 | void* null_ptr = nullptr; 52 | ASSERT_DEATH(pm.SetMPICommunicator(null_ptr), ".*Assertion.*comm != (NULL|__null)*"); 53 | } 54 | 55 | // SetBoundaryIndex 56 | { 57 | int* null_int = nullptr; 58 | ASSERT_DEATH(pm.SetBoundaryIndex(safe_size, null_int), 59 | ".*Assertion.*index != (NULL|__null)*"); 60 | } 61 | 62 | // SetReceivers 63 | { 64 | int* null_int = nullptr; 65 | ASSERT_DEATH(pm.SetReceivers(safe_size, null_int, idata), 66 | ".*Assertion.*recvs != (NULL|__null)*"); 67 | ASSERT_DEATH(pm.SetReceivers(safe_size, idata, null_int), 68 | ".*Assertion.*recv_offset != (NULL|__null)*"); 69 | } 70 | 71 | // SetSenders 72 | { 73 | int* null_int = nullptr; 74 | ASSERT_DEATH(pm.SetSenders(safe_size, null_int, idata), 75 | ".*Assertion.*sends != (NULL|__null)*"); 76 | ASSERT_DEATH(pm.SetSenders(safe_size, idata, null_int), 77 | ".*Assertion.*send_offset != (NULL|__null)*"); 78 | } 79 | 80 | free_host(&idata); 81 | 82 | // Stop rocALUTION 83 | stop_rocalution(); 84 | } 85 | 86 | #endif // TESTING_PARALLEL_MANAGER_HPP 87 | -------------------------------------------------------------------------------- /clients/samples/direct.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | using namespace rocalution; 29 | 30 | int main(int argc, char* argv[]) 31 | { 32 | // Check command line parameters 33 | if(argc == 1) 34 | { 35 | std::cerr << argv[0] << " " << std::endl; 36 | exit(1); 37 | } 38 | 39 | // Initialize rocALUTION 40 | init_rocalution(); 41 | 42 | // Print rocALUTION info 43 | info_rocalution(); 44 | 45 | // rocALUTION objects 46 | LocalVector x; 47 | LocalVector rhs; 48 | LocalVector e; 49 | LocalMatrix mat; 50 | 51 | // Read matrix from MTX file 52 | mat.ReadFileMTX(std::string(argv[1])); 53 | 54 | // Move objects to accelerator 55 | // mat.MoveToAccelerator(); 56 | // x.MoveToAccelerator(); 57 | // rhs.MoveToAccelerator(); 58 | // e.MoveToAccelerator(); 59 | 60 | // Allocate vectors 61 | x.Allocate("x", mat.GetN()); 62 | rhs.Allocate("rhs", mat.GetM()); 63 | e.Allocate("e", mat.GetN()); 64 | 65 | // Direct solver 66 | Inversion, LocalVector, double> ds; 67 | 68 | // Initialize rhs such that A 1 = rhs 69 | e.Ones(); 70 | mat.Apply(e, &rhs); 71 | 72 | // Set solver operator 73 | ds.SetOperator(mat); 74 | 75 | // Build solver 76 | ds.Build(); 77 | 78 | // Print matrix info 79 | mat.Info(); 80 | 81 | // Start time measurement 82 | double tick, tack; 83 | tick = rocalution_time(); 84 | 85 | // Solve A x = rhs 86 | ds.Solve(rhs, &x); 87 | 88 | // Stop time measurement 89 | tack = rocalution_time(); 90 | std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; 91 | 92 | // Clear solver 93 | ds.Clear(); 94 | 95 | // Compute error L2 norm 96 | e.ScaleAdd(-1.0, x); 97 | double error = e.Norm(); 98 | std::cout << "||e - x||_2 = " << error << std::endl; 99 | 100 | // Stop rocALUTION platform 101 | stop_rocalution(); 102 | 103 | return 0; 104 | } 105 | -------------------------------------------------------------------------------- /clients/samples/key.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #include 25 | #include 26 | 27 | using namespace rocalution; 28 | 29 | int main(int argc, char* argv[]) 30 | { 31 | // Check command line parameters 32 | if(argc == 1) 33 | { 34 | std::cerr << argv[0] << " " << std::endl; 35 | exit(1); 36 | } 37 | 38 | // Initialize rocALUTION 39 | init_rocalution(); 40 | 41 | // rocALUTION objects 42 | LocalMatrix mat; 43 | 44 | // Read matrix from MTX file 45 | mat.ReadFileMTX(std::string(argv[1])); 46 | 47 | // Print matrix info 48 | mat.Info(); 49 | 50 | long int row_key; 51 | long int col_key; 52 | long int val_key; 53 | 54 | // Compute keys 55 | mat.Key(row_key, col_key, val_key); 56 | 57 | // Print keys 58 | std::cout << "Row key = " << row_key << std::endl 59 | << "Col key = " << col_key << std::endl 60 | << "Val key = " << val_key << std::endl; 61 | 62 | // Stop rocALUTION platform 63 | stop_rocalution(); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /clients/samples/simple-spmv.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | using namespace rocalution; 29 | 30 | int main(int argc, char* argv[]) 31 | { 32 | // Check command line parameters 33 | if(argc == 1) 34 | { 35 | std::cerr << argv[0] << " [Num threads]" << std::endl; 36 | exit(1); 37 | } 38 | 39 | // Initialize rocALUTION 40 | init_rocalution(); 41 | 42 | // Check command line parameters for number of OMP threads 43 | if(argc > 2) 44 | { 45 | set_omp_threads_rocalution(atoi(argv[2])); 46 | } 47 | 48 | // Print rocALUTION info 49 | info_rocalution(); 50 | 51 | // rocALUTION objects 52 | LocalVector x; 53 | LocalVector rhs; 54 | 55 | LocalMatrix mat; 56 | 57 | // Read matrix from MTX file 58 | mat.ReadFileMTX(std::string(argv[1])); 59 | 60 | // Print matrix info 61 | mat.Info(); 62 | 63 | // Allocate vectors 64 | x.Allocate("x", mat.GetN()); 65 | rhs.Allocate("rhs", mat.GetM()); 66 | 67 | // Print vector info 68 | x.Info(); 69 | rhs.Info(); 70 | 71 | // Set rhs to 1 72 | rhs.Ones(); 73 | 74 | // x = mat * rhs 75 | mat.Apply(rhs, &x); 76 | 77 | // Print dot product 78 | std::cout << "dot=" << x.Dot(rhs) << std::endl; 79 | 80 | // Convert matrix to ELL format 81 | mat.ConvertToELL(); 82 | 83 | // Print matrix info 84 | mat.Info(); 85 | 86 | // Move objects to accelerator 87 | mat.MoveToAccelerator(); 88 | x.MoveToAccelerator(); 89 | rhs.MoveToAccelerator(); 90 | 91 | // Print matrix info 92 | mat.Info(); 93 | 94 | // Set rhs to 1 95 | rhs.Ones(); 96 | 97 | // x = mat * rhs 98 | mat.Apply(rhs, &x); 99 | 100 | // Print dot product 101 | std::cout << "dot=" << x.Dot(rhs) << std::endl; 102 | 103 | // Stop rocALUTION platform 104 | stop_rocalution(); 105 | 106 | return 0; 107 | } 108 | -------------------------------------------------------------------------------- /clients/samples/stencil.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | using namespace rocalution; 29 | 30 | int main(int argc, char* argv[]) 31 | { 32 | 33 | // Initialize rocALUTION 34 | init_rocalution(); 35 | 36 | // Print rocALUTION info 37 | info_rocalution(); 38 | 39 | // rocALUTION objects 40 | LocalVector x; 41 | LocalVector rhs; 42 | LocalVector e; 43 | LocalStencil stencil(Laplace2D); 44 | 45 | // Set up stencil grid 46 | stencil.SetGrid(100); // 100x100 47 | 48 | // Allocate vectors 49 | x.Allocate("x", stencil.GetN()); 50 | rhs.Allocate("rhs", stencil.GetM()); 51 | e.Allocate("e", stencil.GetN()); 52 | 53 | // Linear Solver 54 | CG, LocalVector, double> ls; 55 | 56 | // Initialize rhs such that A 1 = rhs 57 | e.Ones(); 58 | stencil.Apply(e, &rhs); 59 | 60 | // Initial zero guess 61 | x.Zeros(); 62 | 63 | // Set solver operator 64 | ls.SetOperator(stencil); 65 | 66 | // Build solver 67 | ls.Build(); 68 | 69 | // Print stencil info 70 | stencil.Info(); 71 | 72 | // Start time measurement 73 | double tick, tack; 74 | tick = rocalution_time(); 75 | 76 | // Solve A x = rhs 77 | ls.Solve(rhs, &x); 78 | 79 | // Stop time measurement 80 | tack = rocalution_time(); 81 | std::cout << "Solver execution:" << (tack - tick) / 1e6 << " sec" << std::endl; 82 | 83 | // Clear solver 84 | ls.Clear(); 85 | 86 | // Compute error L2 norm 87 | e.ScaleAdd(-1.0, x); 88 | double error = e.Norm(); 89 | std::cout << "||e - x||_2 = " << error << std::endl; 90 | 91 | // Stop rocALUTION platform 92 | stop_rocalution(); 93 | 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /clients/tests/rocalution_host_gtest_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #include "utility.hpp" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #define VAL(str) #str 31 | #define TOSTRING(str) VAL(str) 32 | 33 | int device; 34 | 35 | /* ===================================================================== 36 | Main function: 37 | =================================================================== */ 38 | 39 | int main(int argc, char** argv) 40 | { 41 | // Get device id from command line 42 | device = 0; 43 | 44 | for(int i = 1; i < argc; ++i) 45 | { 46 | if(strcmp(argv[i], "--device") == 0 && argc > i + 1) 47 | { 48 | device = atoi(argv[i + 1]); 49 | } 50 | 51 | if(strcmp(argv[i], "--version") == 0) 52 | { 53 | // Print version and exit, if requested 54 | std::cout << "rocALUTION version: " << __ROCALUTION_VER_MAJOR << "." 55 | << __ROCALUTION_VER_MINOR << "." << __ROCALUTION_VER_PATCH << "-" 56 | << TOSTRING(__ROCALUTION_VER_TWEAK) << std::endl; 57 | 58 | return 0; 59 | } 60 | } 61 | 62 | rocalution::set_device_rocalution(device); 63 | rocalution::init_rocalution(); 64 | rocalution::info_rocalution(); 65 | rocalution::stop_rocalution(); 66 | 67 | ::testing::InitGoogleTest(&argc, argv); 68 | ::testing::FLAGS_gtest_death_test_style = "threadsafe"; 69 | 70 | return RUN_ALL_TESTS(); 71 | } 72 | -------------------------------------------------------------------------------- /clients/tests/test_local_matrix_multicoloring.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #include "testing_local_matrix_multicoloring.hpp" 25 | #include "utility.hpp" 26 | 27 | #include 28 | 29 | typedef std::tuple local_matrix_multicoloring_tuple; 30 | 31 | int local_matrix_multicoloring_size[] = {10, 17, 21}; 32 | std::string local_matrix_multicoloring_type[] = {"Laplacian2D", "PermutedIdentity", "Random"}; 33 | unsigned int local_matrix_multicoloring_format[] = {1}; 34 | 35 | class parameterized_local_matrix_multicoloring 36 | : public testing::TestWithParam 37 | { 38 | protected: 39 | parameterized_local_matrix_multicoloring() {} 40 | virtual ~parameterized_local_matrix_multicoloring() {} 41 | virtual void SetUp() override 42 | { 43 | if(is_any_env_var_set({"ROCALUTION_EMULATION_SMOKE", 44 | "ROCALUTION_EMULATION_REGRESSION", 45 | "ROCALUTION_EMULATION_EXTENDED"})) 46 | { 47 | GTEST_SKIP(); 48 | } 49 | } 50 | 51 | virtual void TearDown() {} 52 | }; 53 | 54 | Arguments setup_local_matrix_multicoloring_arguments(local_matrix_multicoloring_tuple tup) 55 | { 56 | Arguments arg; 57 | arg.size = std::get<0>(tup); 58 | arg.matrix_type = std::get<1>(tup); 59 | arg.format = std::get<2>(tup); 60 | return arg; 61 | } 62 | 63 | TEST_P(parameterized_local_matrix_multicoloring, local_matrix_multicoloring_float) 64 | { 65 | Arguments arg = setup_local_matrix_multicoloring_arguments(GetParam()); 66 | ASSERT_EQ(testing_local_matrix_multicoloring(arg), true); 67 | } 68 | 69 | TEST_P(parameterized_local_matrix_multicoloring, local_matrix_multicoloring_double) 70 | { 71 | Arguments arg = setup_local_matrix_multicoloring_arguments(GetParam()); 72 | ASSERT_EQ(testing_local_matrix_multicoloring(arg), true); 73 | } 74 | 75 | INSTANTIATE_TEST_CASE_P(local_matrix_multicoloring, 76 | parameterized_local_matrix_multicoloring, 77 | testing::Combine(testing::ValuesIn(local_matrix_multicoloring_size), 78 | testing::ValuesIn(local_matrix_multicoloring_type), 79 | testing::ValuesIn(local_matrix_multicoloring_format))); 80 | -------------------------------------------------------------------------------- /cmake/Packaging.cmake: -------------------------------------------------------------------------------- 1 | # ######################################################################## 2 | # Copyright (C) 2019-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | # 22 | # ######################################################################## 23 | 24 | # Client packaging 25 | include(CMakeParseArguments) 26 | 27 | function(rocm_create_package_clients) 28 | set(options) 29 | set(oneValueArgs LIB_NAME DESCRIPTION SECTION MAINTAINER VERSION) 30 | set(multiValueArgs DEPENDS) 31 | 32 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 33 | 34 | string(CONCAT PACKAGE_NAME ${PARSE_LIB_NAME} "-clients-" ${PARSE_VERSION} "-Linux.deb") 35 | string(CONCAT DEB_CONTROL_FILE_CONTENT "Package: " ${PARSE_LIB_NAME} "-clients" 36 | "\nVersion: " ${PARSE_VERSION} 37 | "\nSection: " ${PARSE_SECTION} 38 | "\nPriority: optional" 39 | "\nArchitecture: amd64" 40 | "\nMaintainer: " ${PARSE_MAINTAINER} 41 | "\nDescription: " ${PARSE_DESCRIPTION} 42 | "\nDepends: " ${PARSE_LIB_NAME} "(>=" ${PARSE_VERSION} ")\n\n") 43 | 44 | if(EXISTS "${PROJECT_BINARY_DIR}/package") 45 | file(REMOVE_RECURSE "${PROJECT_BINARY_DIR}/package") 46 | endif() 47 | file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/package/${ROCM_PATH}/${PARSE_LIB_NAME}/bin") 48 | file(WRITE "${PROJECT_BINARY_DIR}/package/DEBIAN/control" ${DEB_CONTROL_FILE_CONTENT}) 49 | 50 | add_custom_target(package_clients 51 | COMMAND ${CMAKE_COMMAND} -E remove -f "${PROJECT_BINARY_DIR}/package/${ROCM_PATH}/${PARSE_LIB_NAME}/bin/*" 52 | COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_BINARY_DIR}/staging/*" "${PROJECT_BINARY_DIR}/package/${ROCM_PATH}/${PARSE_LIB_NAME}/bin" 53 | COMMAND dpkg -b "${PROJECT_BINARY_DIR}/package/" ${PACKAGE_NAME}) 54 | endfunction(rocm_create_package_clients) 55 | -------------------------------------------------------------------------------- /cmake/get-cli-arguments.cmake: -------------------------------------------------------------------------------- 1 | # Attempt (best effort) to return a list of user specified parameters cmake was invoked with 2 | # NOTE: Even if the user specifies CMAKE_INSTALL_PREFIX on the command line, the parameter is 3 | # not returned because it does not have the matching helpstring 4 | 5 | function( append_cmake_cli_arguments initial_cli_args return_cli_args ) 6 | 7 | # Retrieves the contents of CMakeCache.txt 8 | get_cmake_property( cmake_properties CACHE_VARIABLES ) 9 | 10 | foreach( property ${cmake_properties} ) 11 | get_property(help_string CACHE ${property} PROPERTY HELPSTRING ) 12 | 13 | # Properties specified on the command line have boilerplate text 14 | if( help_string MATCHES "variable specified on the command line" ) 15 | # message( STATUS "property: ${property}") 16 | # message( STATUS "value: ${${property}}") 17 | 18 | list( APPEND cli_args "-D${property}=${${property}}") 19 | endif( ) 20 | endforeach( ) 21 | 22 | # message( STATUS "get_command_line_arguments: ${cli_args}") 23 | set( ${return_cli_args} ${${initial_cli_args}} ${cli_args} PARENT_SCOPE ) 24 | 25 | endfunction( ) 26 | -------------------------------------------------------------------------------- /custom.properties: -------------------------------------------------------------------------------- 1 | booktitle=rocALUTION API Guide 2 | spreadsheet.xml=docs/classification-map.xml 3 | document.locale=enus -------------------------------------------------------------------------------- /deps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ######################################################################## 2 | # Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | # 22 | # ######################################################################## 23 | 24 | # Helper cmake script to automate building dependencies for rocsparse 25 | # This script can be invoked manually by the user with 'cmake -P' 26 | 27 | # The ROCm platform requires Ubuntu 16.04 or Fedora 24, which has cmake 3.5 28 | cmake_minimum_required( VERSION 3.5 ) 29 | 30 | list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake ) 31 | 32 | # Consider removing this in the future 33 | # It can be annoying for visual studio developers to build a project that tries to install into 'program files' 34 | if( WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) 35 | set( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories" FORCE ) 36 | endif( ) 37 | 38 | # This has to be initialized before the project() command appears 39 | # Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE 40 | if( NOT DEFINED CMAKE_CONFIGURATION_TYPES AND NOT DEFINED CMAKE_BUILD_TYPE ) 41 | set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." ) 42 | endif() 43 | 44 | # The superbuild does not build anything itself; all compiling is done in external projects 45 | project( rocsparse-dependencies NONE ) 46 | 47 | option( BUILD_GTEST "Download and build googletest library" OFF ) 48 | # option( BUILD_VERBOSE "Print helpful build debug information" OFF ) 49 | 50 | # This module scrapes the CMakeCache.txt file and attempts to get all the cli options the user specified to cmake invocation 51 | include( get-cli-arguments ) 52 | 53 | # The following is a series of super-build projects; this cmake project will download and build 54 | if( BUILD_GTEST ) 55 | include( external-gtest ) 56 | 57 | list( APPEND rocsparse_dependencies googletest ) 58 | set( gtest_custom_target COMMAND cd ${GTEST_BINARY_ROOT}$ ${CMAKE_COMMAND} --build . --target install ) 59 | endif( ) 60 | 61 | # POLICY CMP0037 - "Target names should not be reserved and should match a validity pattern" 62 | # Familiar target names like 'install' should be OK at the super-build level 63 | if( POLICY CMP0037 ) 64 | cmake_policy( SET CMP0037 OLD ) 65 | endif( ) 66 | 67 | add_custom_target( install 68 | ${gtest_custom_target} 69 | DEPENDS ${rocsparse_dependencies} 70 | ) 71 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build/ 2 | _doxygen/ 3 | doxygen/html/ 4 | doxygen/xml/ 5 | /sphinx/_toc.yml 6 | -------------------------------------------------------------------------------- /docs/conceptual/rocALUTION-design.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: rocALUTION design and philosophy 3 | :keywords: rocALUTION, ROCm, library, API, design, philosophy 4 | 5 | .. _design-philosophy: 6 | 7 | ********************************** 8 | rocALUTION design and philosophy 9 | ********************************** 10 | 11 | rocALUTION is written in C++ and HIP. 12 | 13 | The rocALUTION objects are designed to be separate from the actual hardware specification. 14 | Once you declare a matrix, a vector, or a solver, these rocALUTION objects are initially allocated on the host (CPU). 15 | Then, every object can be moved to a selected accelerator using a simple function call. 16 | The whole execution mechanism is based on the Run-Time Type Information (RTTI), which allows you to select the location and method for performing the operations at run-time. 17 | This is in contrast to the template-based libraries that require this information at compile-time. 18 | 19 | The philosophy of the library is to abstract the hardware-specific functions and routines from the actual program that describes the algorithm. 20 | It is difficult and almost impossible for most of the large simulation softwares based on sparse computation to adapt and port their implementation to suit every new technology. 21 | On the other hand, the new high performance accelerators and devices can decrease the computational time significantly in many critical parts. 22 | 23 | This abstraction layer of the hardware-specific routines is the core of the rocALUTION design. 24 | It is built to explore fine-grained level of parallelism suited for multi/many-core devices. 25 | This is in contrast to most of the parallel sparse libraries that are based mainly on domain decomposition techniques. 26 | That's why the design of the iterative solvers and preconditioners is very different. 27 | Another cornerstone of rocALUTION is the native support for accelerators where the memory allocation, transfers, and specific hardware functions are handled internally in the library. 28 | 29 | rocALUTION doesn't make the use of accelerator technologies mandatory. 30 | Even if you offload your algorithms and solvers on the accelerator device, the same source code can be compiled and executed on a system without an accelerator. 31 | 32 | Naturally, not all routines and algorithms can be performed efficiently on many-core systems (i.e. on accelerators). 33 | To provide full functionality, the library has internal mechanisms to check if a particular routine is implemented on the accelerator. 34 | If not, the object is moved to the host and the routine is computed there. 35 | This ensures that your code runs on any accelerator, regardless of the available functionality for it. 36 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | import re 8 | 9 | from rocm_docs import ROCmDocs 10 | 11 | with open('../CMakeLists.txt', encoding='utf-8') as f: 12 | match = re.search(r'.*\brocm_setup_version\(VERSION\s+\"?([0-9.]+)[^0-9.]+', f.read()) 13 | if not match: 14 | raise ValueError("VERSION not found!") 15 | version_number = match[1] 16 | left_nav_title = f"rocALUTION {version_number} Documentation" 17 | 18 | # for PDF output on Read the Docs 19 | project = "rocALUTION Documentation" 20 | author = "Advanced Micro Devices, Inc." 21 | copyright = "Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved." 22 | version = version_number 23 | release = version_number 24 | 25 | external_toc_path = "./sphinx/_toc.yml" 26 | 27 | docs_core = ROCmDocs(left_nav_title) 28 | docs_core.run_doxygen(doxygen_root="doxygen", doxygen_path="doxygen/xml") 29 | docs_core.setup() 30 | 31 | external_projects_current_project = "rocalution" 32 | 33 | for sphinx_var in ROCmDocs.SPHINX_VARS: 34 | globals()[sphinx_var] = getattr(docs_core, sphinx_var) 35 | -------------------------------------------------------------------------------- /docs/data/4x4_mpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/4x4_mpi.png -------------------------------------------------------------------------------- /docs/data/4x4_mpi_rank0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/4x4_mpi_rank0.png -------------------------------------------------------------------------------- /docs/data/AS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/AS.png -------------------------------------------------------------------------------- /docs/data/BJ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/BJ.png -------------------------------------------------------------------------------- /docs/data/domain1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/domain1.png -------------------------------------------------------------------------------- /docs/data/global_objects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/global_objects.png -------------------------------------------------------------------------------- /docs/data/multi-node1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/multi-node1.png -------------------------------------------------------------------------------- /docs/data/multi-node2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/multi-node2.png -------------------------------------------------------------------------------- /docs/data/operators.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/operators.png -------------------------------------------------------------------------------- /docs/data/receiving.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/receiving.png -------------------------------------------------------------------------------- /docs/data/sending.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/sending.png -------------------------------------------------------------------------------- /docs/data/single-node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/single-node.png -------------------------------------------------------------------------------- /docs/data/solvers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/rocALUTION/3554cfdce2ecfc743fd49344a0ce16811731ce50/docs/data/solvers.png -------------------------------------------------------------------------------- /docs/doxygen/modules.dox: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | /** \defgroup solver_module Solver Module 25 | * This module contains all solvers. 26 | */ 27 | 28 | /** \defgroup precond_module Preconditioner Module 29 | * This module contains all preconditioners. 30 | */ 31 | 32 | /** \defgroup op_vec_module Operators and Vectors Module 33 | * This module contains all operators and vectors. 34 | */ 35 | 36 | /** \defgroup backend_module Backend Module 37 | * This module contains al backend related functions. 38 | */ 39 | -------------------------------------------------------------------------------- /docs/how-to/include-rocALUTION.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: Building and installing rocALUTION on Windows 3 | :keywords: rocALUTION, ROCm, library, API, tool, Windows, installation, building, HIP SDK 4 | 5 | ***************************************** 6 | Using rocALUTION as a prebuilt packages 7 | ***************************************** 8 | 9 | rocALUTION can be installed on Windows 11 or Windows 10 using the AMD HIP SDK installer. 10 | 11 | The simplest way to use rocALUTION in your code is to use ``CMake`` that requires you to add the SDK installation location to your 12 | `DCMAKE_PREFIX_PATH`. Note that you need to use quotes as the path contains a space, e.g., 13 | 14 | .. code:: shell 15 | 16 | -DCMAKE_PREFIX_PATH="C:\Program Files\AMD\ROCm\5.5" 17 | 18 | 19 | After CMake configuration, in your ``CMakeLists.txt`` use: 20 | 21 | .. code:: shell 22 | 23 | find_package(rocalution) 24 | 25 | target_link_libraries( your_exe PRIVATE roc::rocalution ) 26 | 27 | Once rocALUTION is installed, you can find ``rocalution.hpp`` in the HIP SDK ``\\include\\rocalution`` 28 | directory. Use only the installed file in the user application if needed. 29 | You must include ``rocalution.hpp`` header file in the user code to make calls 30 | into rocALUTION, so that the rocALUTION import library and dynamic link library become the respective link-time and run-time 31 | dependencies for the user application. 32 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: A sparse linear algebra library with focus on exploring fine-grained parallelism on top of the AMD ROCm runtime and toolchains 3 | :keywords: rocALUTION, ROCm, library, API, tool 4 | 5 | .. _index: 6 | 7 | =========================== 8 | rocALUTION documentation 9 | =========================== 10 | 11 | rocALUTION is a sparse linear algebra library with focus on exploring fine-grained parallelism on top of the AMD ROCm runtime and toolchains. To learn more, see :ref:`what-is-rocalution` 12 | 13 | The rocALUTION public repository is located at `https://github.com/ROCm/rocALUTION `_. 14 | 15 | 16 | .. grid:: 2 17 | :gutter: 3 18 | 19 | .. grid-item-card:: Install 20 | 21 | * :doc:`rocALUTION prerequisites ` 22 | * :doc:`rocALUTION installation ` 23 | 24 | * :doc:`Installing rocALUTION on Linux ` 25 | * :doc:`Installing rocALUTION on Windows ` 26 | 27 | .. grid:: 2 28 | :gutter: 3 29 | 30 | .. grid-item-card:: Conceptual 31 | 32 | * :ref:`design-philosophy` 33 | * :ref:`source-code-organization` 34 | 35 | .. grid-item-card:: How to 36 | 37 | * :doc:`Extend rocALUTION ` 38 | * :doc:`Include rocALUTION in your source code ` 39 | 40 | .. grid-item-card:: Samples 41 | 42 | * :ref:`clients` 43 | 44 | .. grid-item-card:: Reference 45 | 46 | * :ref:`basics` 47 | * :ref:`single-node` 48 | * :ref:`multi-node` 49 | * :ref:`solver-class` 50 | * :ref:`preconditioners` 51 | * :ref:`backends` 52 | * :ref:`api` 53 | * :ref:`remarks` 54 | * :ref:`functionality-table` 55 | 56 | 57 | 58 | To contribute to the documentation, refer to 59 | `Contributing to ROCm `_. 60 | 61 | You can find licensing information on the `Licensing `_ page. 62 | -------------------------------------------------------------------------------- /docs/install/rocALUTION-general-install.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: Installing rocALUTION 3 | :keywords: rocALUTION, ROCm, library, API, install, windows, linux, HIP SDK 4 | 5 | 6 | ************************** 7 | Installing rocALUTION 8 | ************************** 9 | 10 | rocALUTION is installed with HIP SDK for Windows or ROCm as a single-node, accelerator-enabled library. 11 | 12 | To use a different configuration, such as a multi-node configuration, rocALUTION can be built from source code. 13 | 14 | To build rocALUTION from source, use the branch of rocALUTION in the `rocALUTION GitHub repository `_ that corresponds to the version of HIP SDK for Windows or ROCm that is installed, and follow the :doc:`instructions for Windows <./rocALUTION-windows-build-and-install>` or the :doc:`instructions for Linux <./rocALUTION-linux-build-and-install>`. -------------------------------------------------------------------------------- /docs/install/rocALUTION-linux-build-and-install.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: Building and installing rocALUTION on Linux 3 | :keywords: rocALUTION, ROCm, library, API, tool, Linux, building, installing 4 | 5 | .. _linux-installation: 6 | 7 | ************************************ 8 | Installing rocALUTION on Linux 9 | ************************************ 10 | 11 | rocALUTION can be installed along with ROCm as a single-node, accelerator-enabled library. To configure rocALUTION to use a different configuration such as a multi-node configuration, it must be be built from source code. 12 | 13 | ROCm must be installed before building rocALUTION. Use the version of rocALUTION that corresponds to the installed version of ROCm. 14 | 15 | The rocALUTION source code is available from `https://github.com/ROCm/rocALUTION `_. 16 | 17 | rocALUTION depends on the following ROCm components: 18 | 19 | * `rocBLAS `_ 20 | * `rocSPARSE `_ 21 | * `rocRAND `_ 22 | * `rocPRIM `_ 23 | 24 | Ensure that these components are installed before installing rocALUTION. See their respective documentation for installation instructions. 25 | 26 | For multi-node configurations, download and install `OpenMP `_ and `MPI `_. 27 | 28 | Create a ``build`` directory in the ``rocALUTION`` root directory. Change directory to the ``build`` directory: 29 | 30 | .. code:: shell 31 | 32 | mkdir build 33 | cd build 34 | 35 | Use CMake to generate a makefile. The ``ROCM_PATH`` directive is required. Set it to point to the ROCm installation location. 36 | 37 | The following optional directives can also be set: 38 | 39 | * ``SUPPORT_HIP``: Build rocALUTION with HIP support. ``ON`` by default. 40 | * ``SUPPORT_OMP``: Build rocALUTION with OpenMP support. ``ON`` by default. 41 | * ``SUPPORT_MPI``: Build rocALUTION with MPI. Set this to ``ON`` for multi-node support. ``OFF`` by default. 42 | * ``BUILD_SHARED_LIBS``: Build rocALUTION as shared library. ``ON`` by default. ``ON`` is the recommended configuration. 43 | * ``BUILD_EXAMPLES``: Build rocALUTION examples. ``ON`` by default. 44 | 45 | For example, to build rocALUTION with MPI support, run this command: 46 | 47 | .. code:: shell 48 | 49 | cmake .. -DSUPPORT_MPI=ON -DROCM_PATH=/opt/rocm/ 50 | 51 | Use ``make`` to build rocALUTION and ``make install`` to install the rocALUTION library under the ROCm installation directory. 52 | 53 | .. code:: shell 54 | 55 | make 56 | make install 57 | 58 | 59 | -------------------------------------------------------------------------------- /docs/install/rocALUTION-prerequisites.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: rocALUTION prerequisites 3 | :keywords: rocALUTION, ROCm, library, API, tool, Windows, Linux, installation, building, HIP SDK, prerequisites 4 | 5 | 6 | ************************** 7 | rocALUTION prerequisites 8 | ************************** 9 | 10 | rocALUTION can be installed along with `ROCm `_ or `HIP SDK for Windows `_, or it can be built from source code. 11 | 12 | HIP SDK for Windows must be installed before building rocALUTION on Microsoft Windows, and ROCm must be installed before building rocALUTION on Linux. 13 | 14 | 15 | Building rocALUTION from source requires the following prerequisites on both Linux and Windows: 16 | 17 | * `CMake `_ 18 | * `rocBLAS `_ 19 | * `rocSPARSE `_ 20 | * `rocRAND `_ 21 | * `rocPRIM `_ 22 | 23 | On Windows, the following prerequisites are also required: 24 | 25 | * `Python 3 `_ 26 | * `Ninja `_ 27 | * `Strawberry Perl `_ 28 | -------------------------------------------------------------------------------- /docs/install/rocALUTION-windows-build-and-install.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: Building and installing rocALUTION on Windows 3 | :keywords: rocALUTION, ROCm, library, API, tool, Windows, installation, building, HIP SDK 4 | 5 | .. _windows-installation: 6 | 7 | ********************************* 8 | Installing rocALUTION on Windows 9 | ********************************* 10 | 11 | rocALUTION can be installed along with HIP SDK for Windows as a single-node, accelerator-enabled library. To configure rocALUTION to use a different configuration such as a multi-node configuration, it must be built from source code. 12 | 13 | HIP SDK for Windows, as well as the following components, must be installed before building rocALUTION: 14 | 15 | * `rocBLAS `_ 16 | * `rocSPARSE `_ 17 | * `rocRAND `_ 18 | * `rocPRIM `_ 19 | 20 | See :doc:`rocALUTION prerequisites <./rocALUTION-prerequisites>` for the full list of requirements. 21 | 22 | The rocALUTION source code is available from `https://github.com/ROCmSoftwarePlatform/rocALUTION `_. Use the version of the source code that corresponds to the installed version of HIP SDK for Windows. 23 | 24 | To determine which version of HIP SDK for Windows is installed, run: 25 | 26 | .. code:: shell 27 | 28 | hipcc --version 29 | 30 | .. note:: 31 | 32 | If ``hipcc`` can't be found on your system, add ``%HIP_PATH%/bin`` to your ``PATH`` variable. 33 | 34 | 35 | Use the ``rmake.py`` script to build and install rocALUTION. 36 | 37 | To build the library without installing it, run ``rmake.py`` without any arguments: 38 | 39 | .. code:: shell 40 | 41 | python3 rmake.py 42 | 43 | The rocALUTION library files will be saved to ``build\release\include\rocalution``. 44 | 45 | To build the library and install it, use the ``-i`` argument: 46 | 47 | .. code:: shell 48 | 49 | python3 rmake.py -i 50 | 51 | The library files will be built and installed in ``%HIP_PATH%\include\rocalution``. 52 | 53 | To build the library and its clients, and install the library files, use the ``-ci`` argument: 54 | 55 | .. code:: shell 56 | 57 | python3 rmake.py -ci 58 | 59 | You can also omit the ``i`` argument and build the clients and the library without installing the library. 60 | -------------------------------------------------------------------------------- /docs/license.rst: -------------------------------------------------------------------------------- 1 | License 2 | ======= 3 | 4 | .. include:: ../LICENSE.md 5 | -------------------------------------------------------------------------------- /docs/sphinx/_toc.yml.in: -------------------------------------------------------------------------------- 1 | # Anywhere {branch} is used, the branch name will be substituted. 2 | # These comments will also be removed. 3 | root: index 4 | subtrees: 5 | - numbered: False 6 | entries: 7 | - file: what-is-rocalution 8 | 9 | - caption: Install 10 | entries: 11 | - file: install/rocALUTION-prerequisites.rst 12 | - file: install/rocALUTION-general-install.rst 13 | - file: install/rocALUTION-linux-build-and-install.rst 14 | - file: install/rocALUTION-windows-build-and-install.rst 15 | 16 | - caption: Conceptual 17 | entries: 18 | - file: conceptual/rocALUTION-design.rst 19 | - file: conceptual/rocALUTION-organization.rst 20 | 21 | - caption: How to 22 | entries: 23 | - file: how-to/extending-rocALUTION.rst 24 | title: Extend rocALUTION 25 | - file: how-to/include-rocALUTION.rst 26 | title: Include rocALUTION 27 | 28 | - caption: Samples 29 | entries: 30 | - file: tutorials/rocALUTION-client-examples 31 | 32 | - caption: Reference 33 | entries: 34 | - file: reference/rocALUTION-api-basics.rst 35 | - file: reference/rocALUTION-single-node-comp.rst 36 | - file: reference/rocALUTION-multi-node-comp.rst 37 | - file: reference/rocALUTION-solvers.rst 38 | - file: reference/rocALUTION-preconditioners.rst 39 | - file: reference/rocALUTION-accelerators.rst 40 | - file: reference/rocALUTION-api.rst 41 | - file: reference/rocALUTION-functionality-table.rst 42 | - file: reference/rocALUTION-library-notes.rst 43 | 44 | 45 | - caption: About 46 | entries: 47 | - file: license 48 | 49 | -------------------------------------------------------------------------------- /docs/sphinx/requirements.in: -------------------------------------------------------------------------------- 1 | rocm-docs-core==1.20.0 2 | -------------------------------------------------------------------------------- /rtest.xml: -------------------------------------------------------------------------------- 1 | 2 | 0.1 3 | 4 | 5 | 6 | {COMMAND}:output_psdb.xml --gtest_filter=*checkin* 7 | 8 | 9 | {COMMAND}:output_osdb.xml --gtest_filter=*nightly* 10 | 11 | 12 | {COMMAND}:output_custom.xml --gtest_filter={GTEST_FILTER} 13 | 14 | 15 | ROCALUTION_EMULATION_SMOKE=1 GTEST_LISTENER=NO_PASS_LINE_IN_LOG {COMMAND}:output_smoke.xml 16 | 17 | 18 | ROCALUTION_EMULATION_REGRESSION=1 GTEST_LISTENER=NO_PASS_LINE_IN_LOG {COMMAND}:output_regression.xml 19 | 20 | 21 | ROCALUTION_EMULATION_EXTENDED=1 GTEST_LISTENER=NO_PASS_LINE_IN_LOG {COMMAND}:output_extended.xml 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ######################################################################## 2 | # Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | # 22 | # ######################################################################## 23 | 24 | set(BASE_SOURCES 25 | base/base_rocalution.cpp 26 | base/operator.cpp 27 | base/vector.cpp 28 | base/local_matrix.cpp 29 | base/global_matrix.cpp 30 | base/local_vector.cpp 31 | base/global_vector.cpp 32 | base/base_matrix.cpp 33 | base/base_vector.cpp 34 | base/backend_manager.cpp 35 | base/parallel_manager.cpp 36 | base/local_stencil.cpp 37 | base/base_stencil.cpp 38 | ) 39 | 40 | set(BASE_PUBLIC_HEADERS 41 | base/matrix_formats.hpp 42 | base/matrix_formats_ind.hpp 43 | base/base_rocalution.hpp 44 | base/operator.hpp 45 | base/vector.hpp 46 | base/local_matrix.hpp 47 | base/global_matrix.hpp 48 | base/local_vector.hpp 49 | base/global_vector.hpp 50 | base/backend_manager.hpp 51 | base/parallel_manager.hpp 52 | base/local_stencil.hpp 53 | base/stencil_types.hpp 54 | ) 55 | -------------------------------------------------------------------------------- /src/base/hip/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ######################################################################## 2 | # Copyright (C) 2018-2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | # 22 | # ######################################################################## 23 | 24 | set(HIP_SOURCES 25 | base/hip/hip_conversion.cpp 26 | base/hip/hip_blas.cpp 27 | base/hip/hip_sparse.cpp 28 | base/hip/backend_hip.cpp 29 | base/hip/hip_allocate_free.cpp 30 | base/hip/hip_vector.cpp 31 | base/hip/hip_matrix_csr.cpp 32 | base/hip/hip_matrix_coo.cpp 33 | base/hip/hip_matrix_dense.cpp 34 | base/hip/hip_matrix_mcsr.cpp 35 | base/hip/hip_matrix_bcsr.cpp 36 | base/hip/hip_matrix_ell.cpp 37 | base/hip/hip_matrix_dia.cpp 38 | base/hip/hip_matrix_hyb.cpp 39 | base/hip/hip_rsamg_csr.cpp 40 | ) 41 | -------------------------------------------------------------------------------- /src/base/hip/backend_hip.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_BACKEND_HIP_HPP_ 25 | #define ROCALUTION_BACKEND_HIP_HPP_ 26 | 27 | #include "../backend_manager.hpp" 28 | 29 | namespace rocalution 30 | { 31 | 32 | template 33 | class AcceleratorVector; 34 | template 35 | class AcceleratorMatrix; 36 | template 37 | class HostMatrix; 38 | 39 | /** \brief Initialize HIP (rocBLAS, rocSPARSE) */ 40 | bool rocalution_init_hip(); 41 | /** \brief Release HIP resources (rocBLAS, rocSPARSE) */ 42 | void rocalution_stop_hip(); 43 | 44 | /** \brief Print information about the HIPs in the systems */ 45 | void rocalution_info_hip(const struct Rocalution_Backend_Descriptor& backend_descriptor); 46 | 47 | /** \brief Sync the device (for async transfers) */ 48 | void rocalution_hip_sync(void); 49 | 50 | /** \brief Sync the default stream */ 51 | void rocalution_hip_sync_default(void); 52 | 53 | /** \brief Sync the interior stream */ 54 | void rocalution_hip_sync_interior(void); 55 | 56 | /** \brief Sync the ghost stream */ 57 | void rocalution_hip_sync_ghost(void); 58 | 59 | /** \brief Returns name of device architecture */ 60 | std::string rocalution_get_arch_hip(void); 61 | 62 | /** \brief Set the rocsparse stream to 'interior' */ 63 | void rocalution_hip_compute_interior(void); 64 | 65 | /** \brief Set the rocsparse stream to 'ghost' */ 66 | void rocalution_hip_compute_ghost(void); 67 | 68 | /** \brief Set the rocsparse stream to default */ 69 | void rocalution_hip_compute_default(void); 70 | 71 | /** \brief Build (and return) a vector on HIP */ 72 | template 73 | AcceleratorVector* _rocalution_init_base_hip_vector( 74 | const struct Rocalution_Backend_Descriptor& backend_descriptor); 75 | 76 | /** \brief Build (and return) a matrix on HIP */ 77 | template 78 | AcceleratorMatrix* _rocalution_init_base_hip_matrix( 79 | const struct Rocalution_Backend_Descriptor& backend_descriptor, 80 | unsigned int matrix_format, 81 | int blockdim = 1); 82 | 83 | } // namespace rocalution 84 | 85 | #endif // ROCALUTION_BACKEND_HIP_HPP_ 86 | -------------------------------------------------------------------------------- /src/base/hip/hip_allocate_free.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_HIP_ALLOCATE_FREE_HPP_ 25 | #define ROCALUTION_HIP_ALLOCATE_FREE_HPP_ 26 | 27 | #include 28 | #include 29 | 30 | namespace rocalution 31 | { 32 | template 33 | void allocate_hip(int64_t n, DataType** ptr); 34 | 35 | template 36 | void free_hip(DataType** ptr); 37 | 38 | template 39 | void set_to_zero_hip( 40 | int blocksize, int64_t n, DataType* ptr, bool async = false, hipStream_t stream = 0); 41 | 42 | template 43 | void set_to_one_hip( 44 | int blocksize, int64_t n, DataType* ptr, bool async = false, hipStream_t stream = 0); 45 | 46 | template 47 | void set_to_value_hip(int blocksize, 48 | int64_t n, 49 | DataType* ptr, 50 | DataType value, 51 | bool async = false, 52 | hipStream_t stream = 0); 53 | 54 | template 55 | void copy_d2h( 56 | int64_t n, const DataType* src, DataType* dst, bool async = false, hipStream_t stream = 0); 57 | 58 | template 59 | void copy_h2d( 60 | int64_t n, const DataType* src, DataType* dst, bool async = false, hipStream_t stream = 0); 61 | 62 | template 63 | void copy_d2d( 64 | int64_t n, const DataType* src, DataType* dst, bool async = false, hipStream_t stream = 0); 65 | } // namespace rocalution 66 | 67 | #endif // ROCALUTION_HIP_ALLOCATE_FREE_HPP_ 68 | -------------------------------------------------------------------------------- /src/base/hip/hip_kernels_coo.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_HIP_HIP_KERNELS_COO_HPP_ 25 | #define ROCALUTION_HIP_HIP_KERNELS_COO_HPP_ 26 | 27 | #include 28 | 29 | namespace rocalution 30 | { 31 | 32 | template 33 | __global__ void kernel_coo_permute(IndexType nnz, 34 | const IndexType* __restrict__ in_row, 35 | const IndexType* __restrict__ in_col, 36 | const IndexType* __restrict__ perm, 37 | IndexType* __restrict__ out_row, 38 | IndexType* __restrict__ out_col) 39 | { 40 | IndexType ind = hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x; 41 | 42 | for(int i = ind; i < nnz; i += hipGridDim_x) 43 | { 44 | out_row[i] = perm[in_row[i]]; 45 | out_col[i] = perm[in_col[i]]; 46 | } 47 | } 48 | 49 | } // namespace rocalution 50 | 51 | #endif // ROCALUTION_HIP_HIP_KERNELS_COO_HPP_ 52 | -------------------------------------------------------------------------------- /src/base/hip/hip_kernels_general.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_HIP_HIP_KERNELS_GENERAL_HPP_ 25 | #define ROCALUTION_HIP_HIP_KERNELS_GENERAL_HPP_ 26 | 27 | #include 28 | 29 | namespace rocalution 30 | { 31 | 32 | template 33 | __global__ void kernel_set_to_value(IndexType n, ValueType* __restrict__ data, ValueType val) 34 | { 35 | IndexType ind = hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x; 36 | 37 | if(ind >= n) 38 | { 39 | return; 40 | } 41 | 42 | data[ind] = val; 43 | } 44 | 45 | template 46 | __global__ void kernel_reverse_index(IndexType n, 47 | const IndexType* __restrict__ perm, 48 | IndexType* __restrict__ out) 49 | { 50 | IndexType ind = hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x; 51 | 52 | if(ind >= n) 53 | { 54 | return; 55 | } 56 | 57 | out[perm[ind]] = ind; 58 | } 59 | 60 | template 61 | __global__ void 62 | kernel_buffer_addscalar(IndexType n, ValueType scalar, ValueType* __restrict__ buff) 63 | { 64 | IndexType ind = hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x; 65 | 66 | if(ind >= n) 67 | { 68 | return; 69 | } 70 | 71 | buff[ind] = buff[ind] + scalar; 72 | } 73 | 74 | } // namespace rocalution 75 | 76 | #endif // ROCALUTION_HIP_HIP_KERNELS_GENERAL_HPP_ 77 | -------------------------------------------------------------------------------- /src/base/hip/hip_rand.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2020-2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_HIP_RAND_HPP_ 25 | #define ROCALUTION_HIP_RAND_HPP_ 26 | 27 | namespace rocalution 28 | { 29 | template 30 | struct CRTP_HIPRand_Traits; 31 | 32 | // 33 | // Base class of the random number functionality. 34 | // 35 | template 36 | class CRTP_HIPRand 37 | { 38 | 39 | protected: 40 | inline CRTP_HIPRand(){}; 41 | using traits_t = CRTP_HIPRand_Traits; 42 | 43 | public: 44 | inline CRTP_HIPRand(const CRTP_HIPRand& that) = delete; 45 | using data_t = typename traits_t::data_t; 46 | 47 | inline void Generate(data_t* data, size_t size) 48 | { 49 | static_cast(*this).Generate(data, size); 50 | }; 51 | }; 52 | 53 | } // namespace rocalution 54 | 55 | #endif // ROCALUTION_BASE_VECTOR_HPP_ 56 | -------------------------------------------------------------------------------- /src/base/hip/hip_rand_normal.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2020-2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_HIP_RAND_NORMAL_HPP_ 25 | #define ROCALUTION_HIP_RAND_NORMAL_HPP_ 26 | 27 | #include "hip_rand.hpp" 28 | #include "hip_utils.hpp" 29 | #include 30 | 31 | namespace rocalution 32 | { 33 | // 34 | // Implementation of a normal distribution using rocRAND. 35 | // 36 | template 37 | class HIPRandNormal_rocRAND; 38 | 39 | template 40 | struct CRTP_HIPRand_Traits> 41 | { 42 | using data_t = T; 43 | }; 44 | 45 | template 46 | class HIPRandNormal_rocRAND : public CRTP_HIPRand> 47 | { 48 | protected: 49 | using value_type = typename numeric_traits::value_type; 50 | rocrand_cpp::mtgp32_engine<0UL> m_engine; 51 | rocrand_cpp::normal_distribution m_distribution; 52 | 53 | public: 54 | inline HIPRandNormal_rocRAND(unsigned long long seed, value_type mean, value_type var) 55 | : m_engine(seed) 56 | , m_distribution(mean, var){}; 57 | 58 | inline void Generate(T* data, size_t size) 59 | { 60 | if(size > 0) 61 | { 62 | assert(0 == sizeof(T) % sizeof(value_type)); 63 | this->m_distribution( 64 | this->m_engine, ((value_type*)data), size * (sizeof(T) / sizeof(value_type))); 65 | } 66 | }; 67 | }; 68 | 69 | } // namespace rocalution 70 | 71 | #endif // ROCALUTION_BASE_VECTOR_HPP_ 72 | -------------------------------------------------------------------------------- /src/base/host/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ######################################################################## 2 | # Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights Reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | # 22 | # ######################################################################## 23 | 24 | set(HOST_SOURCES 25 | base/host/host_matrix_csr.cpp 26 | base/host/host_matrix_mcsr.cpp 27 | base/host/host_matrix_bcsr.cpp 28 | base/host/host_matrix_coo.cpp 29 | base/host/host_matrix_dia.cpp 30 | base/host/host_matrix_ell.cpp 31 | base/host/host_matrix_hyb.cpp 32 | base/host/host_matrix_dense.cpp 33 | base/host/host_vector.cpp 34 | base/host/host_conversion.cpp 35 | base/host/host_affinity.cpp 36 | base/host/host_io.cpp 37 | base/host/host_stencil_laplace2d.cpp 38 | base/host/host_sparse.cpp 39 | base/host/host_ilut_driver_csr.cpp 40 | ) 41 | -------------------------------------------------------------------------------- /src/base/host/host_affinity.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_HOST_HOST_AFFINITY_HPP_ 25 | #define ROCALUTION_HOST_HOST_AFFINITY_HPP_ 26 | 27 | namespace rocalution 28 | { 29 | 30 | void rocalution_set_omp_affinity(bool aff); 31 | 32 | } // namespace rocalution 33 | 34 | #endif // ROCALUTION_HOST_HOST_AFFINITY_HPP_ 35 | -------------------------------------------------------------------------------- /src/base/host/host_stencil_laplace2d.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_HOST_STENCIL_LAPLACE2D_HPP_ 25 | #define ROCALUTION_HOST_STENCIL_LAPLACE2D_HPP_ 26 | 27 | #include "../base_stencil.hpp" 28 | #include "../base_vector.hpp" 29 | #include "../stencil_types.hpp" 30 | 31 | namespace rocalution 32 | { 33 | 34 | template 35 | class HostStencilLaplace2D : public HostStencil 36 | { 37 | public: 38 | HostStencilLaplace2D(); 39 | explicit HostStencilLaplace2D(const Rocalution_Backend_Descriptor& local_backend); 40 | virtual ~HostStencilLaplace2D(); 41 | 42 | virtual int64_t GetNnz(void) const; 43 | virtual void Info(void) const; 44 | virtual unsigned int GetStencilId(void) const 45 | { 46 | return Laplace2D; 47 | } 48 | 49 | virtual void Apply(const BaseVector& in, BaseVector* out) const; 50 | virtual void ApplyAdd(const BaseVector& in, 51 | ValueType scalar, 52 | BaseVector* out) const; 53 | 54 | private: 55 | friend class BaseVector; 56 | friend class HostVector; 57 | 58 | // friend class HIPAcceleratorStencilLaplace2D; 59 | }; 60 | 61 | } // namespace rocalution 62 | 63 | #endif // ROCALUTION_HOST_STENCIL_LAPLACE2D_HPP_ 64 | -------------------------------------------------------------------------------- /src/base/matrix_formats_ind.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_MATRIX_FORMATS_IND_HPP_ 25 | #define ROCALUTION_MATRIX_FORMATS_IND_HPP_ 26 | 27 | // Matrix indexing 28 | 29 | // DENSE indexing 30 | #define DENSE_IND(ai, aj, nrow, ncol) (ai) + (aj) * (nrow) 31 | //#define DENSE_IND(ai, aj, nrow, ncol) (aj) + (ai) * (ncol) 32 | 33 | // DENSE_IND_BASE == 0 - column-major 34 | // DENSE_IND_BASE == 1 - row-major 35 | #define DENSE_IND_BASE (DENSE_IND(2, 2, 10, 0) == 22 ? 0 : 1) 36 | 37 | // ELL indexing 38 | #define ELL_IND_ROW(row, el, nrow, max_row) (el) * (nrow) + (row) 39 | #define ELL_IND_EL(row, el, nrow, max_row) (el) + (max_row) * (row) 40 | #define ELL_IND(row, el, nrow, max_row) ELL_IND_ROW(row, el, nrow, max_row) 41 | 42 | // DIA indexing 43 | #define DIA_IND_ROW(row, el, nrow, ndiag) (el) * (nrow) + (row) 44 | #define DIA_IND_EL(row, el, nrow, ndiag) (el) + (ndiag) * (row) 45 | #define DIA_IND(row, el, nrow, ndiag) DIA_IND_ROW(row, el, nrow, ndiag) 46 | 47 | // BCSR indexing 48 | #define BCSR_IND(j, bi, bj, dim) (((j) * (dim) * (dim)) + (bi) + (bj) * (dim)) 49 | //#define BCSR_IND(j, bi, bj, dim) (((j)*(dim)*(dim)) + (bj) + (bi) * (dim)) 50 | 51 | // BCSR_IND_BASE == 0 - column-major 52 | // BCSR_IND_BASE == 1 - row-major 53 | #define BCSR_IND_BASE (BCSR_IND(0, 1, 2, 10) == 21 ? 0 : 1) 54 | 55 | #endif // ROCALUTION_MATRIX_FORMATS_IND_HPP_ 56 | -------------------------------------------------------------------------------- /src/base/stencil_types.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_STENCIL_TYPES_HPP_ 25 | #define ROCALUTION_STENCIL_TYPES_HPP_ 26 | 27 | #include 28 | 29 | namespace rocalution 30 | { 31 | 32 | // Stencil Names 33 | const std::string _stencil_type_names[1] = {"Laplace2D"}; 34 | 35 | // Stencil Enumeration 36 | enum _stencil_type 37 | { 38 | Laplace2D = 0 39 | }; 40 | 41 | } // namespace rocalution 42 | 43 | #endif // ROCALUTION_STENCIL_TYPES_HPP_ 44 | -------------------------------------------------------------------------------- /src/base/version.hpp.in: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * ************************************************************************ */ 5 | 6 | #ifndef ROCALUTION_VERSION_HPP_ 7 | #define ROCALUTION_VERSION_HPP_ 8 | 9 | // clang-format off 10 | #define __ROCALUTION_VER_MAJOR @rocalution_VERSION_MAJOR@ 11 | #define __ROCALUTION_VER_MINOR @rocalution_VERSION_MINOR@ 12 | #define __ROCALUTION_VER_PATCH @rocalution_VERSION_PATCH@ 13 | #define __ROCALUTION_VER_TWEAK @rocalution_VERSION_TWEAK@ 14 | // clang-format on 15 | 16 | // BETA or ALPHA 17 | #define __ROCALUTION_VER_PRE "" 18 | //#define __ROCALUTION_VER_PRE "ALPHA" 19 | //#define __ROCALUTION_VER_PRE "BETA" 20 | 21 | #define __ROCALUTION_VER \ 22 | 10000 * __ROCALUTION_VER_MAJOR + 100 * __ROCALUTION_VER_MINOR + __ROCALUTION_VER_PATCH 23 | 24 | #endif // ROCALUTION_VERSION_HPP_ 25 | -------------------------------------------------------------------------------- /src/solvers/chebyshev.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_KRYLOV_CHEBYSHEV_HPP_ 25 | #define ROCALUTION_KRYLOV_CHEBYSHEV_HPP_ 26 | 27 | #include "rocalution/export.hpp" 28 | #include "solver.hpp" 29 | 30 | #include 31 | 32 | namespace rocalution 33 | { 34 | 35 | /** \ingroup solver_module 36 | * \class Chebyshev 37 | * \brief Chebyshev Iteration Scheme 38 | * \details 39 | * The Chebyshev Iteration scheme (also known as acceleration scheme) is similar to the 40 | * CG method but requires minimum and maximum eigenvalues of the operator. 41 | * \cite templates 42 | * 43 | * \tparam OperatorType - can be LocalMatrix, GlobalMatrix or LocalStencil 44 | * \tparam VectorType - can be LocalVector or GlobalVector 45 | * \tparam ValueType - can be float, double, std::complex or std::complex 46 | */ 47 | template 48 | class Chebyshev : public IterativeLinearSolver 49 | { 50 | public: 51 | ROCALUTION_EXPORT 52 | Chebyshev(); 53 | ROCALUTION_EXPORT 54 | virtual ~Chebyshev(); 55 | 56 | ROCALUTION_EXPORT 57 | virtual void Print(void) const; 58 | 59 | /** \brief Set the minimum and maximum eigenvalues of the operator */ 60 | ROCALUTION_EXPORT 61 | void Set(ValueType lambda_min, ValueType lambda_max); 62 | 63 | ROCALUTION_EXPORT 64 | virtual void Build(void); 65 | ROCALUTION_EXPORT 66 | virtual void ReBuildNumeric(void); 67 | ROCALUTION_EXPORT 68 | virtual void Clear(void); 69 | 70 | protected: 71 | virtual void SolveNonPrecond_(const VectorType& rhs, VectorType* x); 72 | virtual void SolvePrecond_(const VectorType& rhs, VectorType* x); 73 | 74 | virtual void PrintStart_(void) const; 75 | virtual void PrintEnd_(void) const; 76 | 77 | virtual void MoveToHostLocalData_(void); 78 | virtual void MoveToAcceleratorLocalData_(void); 79 | 80 | private: 81 | bool init_lambda_; 82 | ValueType lambda_min_, lambda_max_; 83 | 84 | VectorType r_, z_; 85 | VectorType p_; 86 | }; 87 | 88 | } // namespace rocalution 89 | 90 | #endif // ROCALUTION_KRYLOV_CHEBYSHEV_HPP_ 91 | -------------------------------------------------------------------------------- /src/solvers/direct/inversion.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_DIRECT_INVERSION_HPP_ 25 | #define ROCALUTION_DIRECT_INVERSION_HPP_ 26 | 27 | #include "../solver.hpp" 28 | #include "rocalution/export.hpp" 29 | 30 | namespace rocalution 31 | { 32 | 33 | /** \ingroup solver_module 34 | * \class Inversion 35 | * \brief Matrix Inversion 36 | * \details 37 | * Full matrix inversion based on QR decomposition. 38 | * 39 | * \tparam OperatorType - can be LocalMatrix 40 | * \tparam VectorType - can be LocalVector 41 | * \tparam ValueType - can be float, double, std::complex or std::complex 42 | */ 43 | template 44 | class Inversion : public DirectLinearSolver 45 | { 46 | public: 47 | ROCALUTION_EXPORT 48 | Inversion(); 49 | ROCALUTION_EXPORT 50 | virtual ~Inversion(); 51 | 52 | ROCALUTION_EXPORT 53 | virtual void Print(void) const; 54 | 55 | ROCALUTION_EXPORT 56 | virtual void Build(void); 57 | ROCALUTION_EXPORT 58 | virtual void Clear(void); 59 | 60 | protected: 61 | virtual void Solve_(const VectorType& rhs, VectorType* x); 62 | 63 | virtual void PrintStart_(void) const; 64 | virtual void PrintEnd_(void) const; 65 | 66 | virtual void MoveToHostLocalData_(void); 67 | virtual void MoveToAcceleratorLocalData_(void); 68 | 69 | private: 70 | OperatorType inverse_; 71 | }; 72 | 73 | } // namespace rocalution 74 | 75 | #endif // ROCALUTION_DIRECT_INVERSION_HPP_ 76 | -------------------------------------------------------------------------------- /src/solvers/direct/lu.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_DIRECT_LU_HPP_ 25 | #define ROCALUTION_DIRECT_LU_HPP_ 26 | 27 | #include "../solver.hpp" 28 | #include "rocalution/export.hpp" 29 | 30 | namespace rocalution 31 | { 32 | 33 | /** \ingroup solver_module 34 | * \class LU 35 | * \brief LU Decomposition 36 | * \details 37 | * Lower-Upper Decomposition factors a given square matrix into lower and upper 38 | * triangular matrix, such that \f$A = LU\f$. 39 | * 40 | * \tparam OperatorType - can be LocalMatrix 41 | * \tparam VectorType - can be LocalVector 42 | * \tparam ValueType - can be float, double, std::complex or std::complex 43 | */ 44 | template 45 | class LU : public DirectLinearSolver 46 | { 47 | public: 48 | ROCALUTION_EXPORT 49 | LU(); 50 | ROCALUTION_EXPORT 51 | virtual ~LU(); 52 | 53 | ROCALUTION_EXPORT 54 | virtual void Print(void) const; 55 | 56 | ROCALUTION_EXPORT 57 | virtual void Build(void); 58 | ROCALUTION_EXPORT 59 | virtual void Clear(void); 60 | 61 | protected: 62 | virtual void Solve_(const VectorType& rhs, VectorType* x); 63 | 64 | virtual void PrintStart_(void) const; 65 | virtual void PrintEnd_(void) const; 66 | 67 | virtual void MoveToHostLocalData_(void); 68 | virtual void MoveToAcceleratorLocalData_(void); 69 | 70 | private: 71 | OperatorType lu_; 72 | }; 73 | 74 | } // namespace rocalution 75 | 76 | #endif // ROCALUTION_DIRECT_LU_HPP_ 77 | -------------------------------------------------------------------------------- /src/solvers/direct/qr.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_DIRECT_QR_HPP_ 25 | #define ROCALUTION_DIRECT_QR_HPP_ 26 | 27 | #include "../solver.hpp" 28 | #include "rocalution/export.hpp" 29 | 30 | namespace rocalution 31 | { 32 | 33 | /** \ingroup solver_module 34 | * \class QR 35 | * \brief QR Decomposition 36 | * \details 37 | * The QR Decomposition decomposes a given matrix into \f$A = QR\f$, such that \f$Q\f$ 38 | * is an orthogonal matrix and \f$R\f$ an upper triangular matrix. 39 | * 40 | * \tparam OperatorType - can be LocalMatrix 41 | * \tparam VectorType - can be LocalVector 42 | * \tparam ValueType - can be float, double, std::complex or std::complex 43 | */ 44 | template 45 | class QR : public DirectLinearSolver 46 | { 47 | public: 48 | ROCALUTION_EXPORT 49 | QR(); 50 | ROCALUTION_EXPORT 51 | virtual ~QR(); 52 | 53 | ROCALUTION_EXPORT 54 | virtual void Print(void) const; 55 | 56 | ROCALUTION_EXPORT 57 | virtual void Build(void); 58 | ROCALUTION_EXPORT 59 | virtual void Clear(void); 60 | 61 | protected: 62 | virtual void Solve_(const VectorType& rhs, VectorType* x); 63 | 64 | virtual void PrintStart_(void) const; 65 | virtual void PrintEnd_(void) const; 66 | 67 | virtual void MoveToHostLocalData_(void); 68 | virtual void MoveToAcceleratorLocalData_(void); 69 | 70 | private: 71 | OperatorType qr_; 72 | }; 73 | 74 | } // namespace rocalution 75 | 76 | #endif // ROCALUTION_DIRECT_QR_HPP_ 77 | -------------------------------------------------------------------------------- /src/solvers/krylov/bicgstab.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_KRYLOV_BICGSTAB_HPP_ 25 | #define ROCALUTION_KRYLOV_BICGSTAB_HPP_ 26 | 27 | #include "../solver.hpp" 28 | #include "rocalution/export.hpp" 29 | 30 | namespace rocalution 31 | { 32 | 33 | /** \ingroup solver_module 34 | * \class BiCGStab 35 | * \brief Bi-Conjugate Gradient Stabilized Method 36 | * \details 37 | * The Bi-Conjugate Gradient Stabilized method is a variation of CGS and solves sparse 38 | * (non) symmetric linear systems \f$Ax=b\f$. 39 | * \cite SAAD 40 | * 41 | * \tparam OperatorType - can be LocalMatrix, GlobalMatrix or LocalStencil 42 | * \tparam VectorType - can be LocalVector or GlobalVector 43 | * \tparam ValueType - can be float, double, std::complex or std::complex 44 | */ 45 | template 46 | class BiCGStab : public IterativeLinearSolver 47 | { 48 | public: 49 | ROCALUTION_EXPORT 50 | BiCGStab(); 51 | ROCALUTION_EXPORT 52 | virtual ~BiCGStab(); 53 | 54 | ROCALUTION_EXPORT 55 | virtual void Print(void) const; 56 | 57 | ROCALUTION_EXPORT 58 | virtual void Build(void); 59 | ROCALUTION_EXPORT 60 | virtual void ReBuildNumeric(void); 61 | ROCALUTION_EXPORT 62 | virtual void Clear(void); 63 | 64 | protected: 65 | virtual void SolveNonPrecond_(const VectorType& rhs, VectorType* x); 66 | virtual void SolvePrecond_(const VectorType& rhs, VectorType* x); 67 | 68 | virtual void PrintStart_(void) const; 69 | virtual void PrintEnd_(void) const; 70 | 71 | virtual void MoveToHostLocalData_(void); 72 | virtual void MoveToAcceleratorLocalData_(void); 73 | 74 | private: 75 | VectorType r_; 76 | VectorType r0_; 77 | VectorType p_; 78 | VectorType q_; 79 | VectorType t_; 80 | VectorType v_; 81 | VectorType z_; 82 | }; 83 | 84 | } // namespace rocalution 85 | 86 | #endif // ROCALUTION_KRYLOV_BICGSTAB_HPP_ 87 | -------------------------------------------------------------------------------- /src/solvers/krylov/cg.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_KRYLOV_CG_HPP_ 25 | #define ROCALUTION_KRYLOV_CG_HPP_ 26 | 27 | #include "../solver.hpp" 28 | #include "rocalution/export.hpp" 29 | 30 | #include 31 | 32 | namespace rocalution 33 | { 34 | 35 | /** \ingroup solver_module 36 | * \class CG 37 | * \brief Conjugate Gradient Method 38 | * \details 39 | * The Conjugate Gradient method is the best known iterative method for solving sparse 40 | * symmetric positive definite (SPD) linear systems \f$Ax=b\f$. It is based on 41 | * orthogonal projection onto the Krylov subspace \f$\mathcal{K}_{m}(r_{0}, A)\f$, 42 | * where \f$r_{0}\f$ is the initial residual. The method can be preconditioned, where 43 | * the approximation should also be SPD. 44 | * \cite SAAD 45 | * 46 | * \tparam OperatorType - can be LocalMatrix, GlobalMatrix or LocalStencil 47 | * \tparam VectorType - can be LocalVector or GlobalVector 48 | * \tparam ValueType - can be float, double, std::complex or std::complex 49 | */ 50 | template 51 | class CG : public IterativeLinearSolver 52 | { 53 | public: 54 | ROCALUTION_EXPORT 55 | CG(); 56 | ROCALUTION_EXPORT 57 | virtual ~CG(); 58 | 59 | ROCALUTION_EXPORT 60 | virtual void Print(void) const; 61 | 62 | ROCALUTION_EXPORT 63 | virtual void Build(void); 64 | 65 | ROCALUTION_EXPORT 66 | virtual void BuildMoveToAcceleratorAsync(void); 67 | ROCALUTION_EXPORT 68 | virtual void Sync(void); 69 | 70 | ROCALUTION_EXPORT 71 | virtual void ReBuildNumeric(void); 72 | ROCALUTION_EXPORT 73 | virtual void Clear(void); 74 | 75 | protected: 76 | virtual void SolveNonPrecond_(const VectorType& rhs, VectorType* x); 77 | virtual void SolvePrecond_(const VectorType& rhs, VectorType* x); 78 | 79 | virtual void PrintStart_(void) const; 80 | virtual void PrintEnd_(void) const; 81 | 82 | virtual void MoveToHostLocalData_(void); 83 | virtual void MoveToAcceleratorLocalData_(void); 84 | 85 | private: 86 | VectorType r_, z_; 87 | VectorType p_, q_; 88 | }; 89 | 90 | } // namespace rocalution 91 | 92 | #endif // ROCALUTION_KRYLOV_CG_HPP_ 93 | -------------------------------------------------------------------------------- /src/solvers/krylov/cr.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_KRYLOV_CR_HPP_ 25 | #define ROCALUTION_KRYLOV_CR_HPP_ 26 | 27 | #include "../solver.hpp" 28 | #include "rocalution/export.hpp" 29 | 30 | #include 31 | 32 | namespace rocalution 33 | { 34 | 35 | /** \ingroup solver_module 36 | * \class CR 37 | * \brief Conjugate Residual Method 38 | * \details 39 | * The Conjugate Residual method is an iterative method for solving sparse symmetric 40 | * semi-positive definite linear systems \f$Ax=b\f$. It is a Krylov subspace method and 41 | * differs from the much more popular Conjugate Gradient method that the system matrix 42 | * is not required to be positive definite. The method can be preconditioned where the 43 | * approximation should also be SPD or semi-positive definite. 44 | * \cite SAAD 45 | * 46 | * \tparam OperatorType - can be LocalMatrix, GlobalMatrix or LocalStencil 47 | * \tparam VectorType - can be LocalVector or GlobalVector 48 | * \tparam ValueType - can be float, double, std::complex or std::complex 49 | */ 50 | template 51 | class CR : public IterativeLinearSolver 52 | { 53 | public: 54 | ROCALUTION_EXPORT 55 | CR(); 56 | ROCALUTION_EXPORT 57 | virtual ~CR(); 58 | 59 | ROCALUTION_EXPORT 60 | virtual void Print(void) const; 61 | 62 | ROCALUTION_EXPORT 63 | virtual void Build(void); 64 | ROCALUTION_EXPORT 65 | virtual void ReBuildNumeric(void); 66 | ROCALUTION_EXPORT 67 | virtual void Clear(void); 68 | 69 | protected: 70 | virtual void SolveNonPrecond_(const VectorType& rhs, VectorType* x); 71 | virtual void SolvePrecond_(const VectorType& rhs, VectorType* x); 72 | 73 | virtual void PrintStart_(void) const; 74 | virtual void PrintEnd_(void) const; 75 | 76 | virtual void MoveToHostLocalData_(void); 77 | virtual void MoveToAcceleratorLocalData_(void); 78 | 79 | private: 80 | VectorType r_, z_, t_; 81 | VectorType p_, q_, v_; 82 | }; 83 | 84 | } // namespace rocalution 85 | 86 | #endif // ROCALUTION_KRYLOV_CR_HPP_ 87 | -------------------------------------------------------------------------------- /src/solvers/krylov/fcg.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_KRYLOV_FCG_HPP_ 25 | #define ROCALUTION_KRYLOV_FCG_HPP_ 26 | 27 | #include "../solver.hpp" 28 | #include "rocalution/export.hpp" 29 | 30 | #include 31 | 32 | namespace rocalution 33 | { 34 | 35 | /** \ingroup solver_module 36 | * \class FCG 37 | * \brief Flexible Conjugate Gradient Method 38 | * \details 39 | * The Flexible Conjugate Gradient method is an iterative method for solving sparse 40 | * symmetric positive definite linear systems \f$Ax=b\f$. It is similar to the Conjugate 41 | * Gradient method with the only difference, that it allows the preconditioner 42 | * \f$M^{-1}\f$ to be not a constant operator. This can be especially helpful if the 43 | * operation \f$M^{-1}x\f$ is the result of another iterative process and not a constant 44 | * operator. 45 | * \cite fcg 46 | * 47 | * \tparam OperatorType - can be LocalMatrix or GlobalMatrix 48 | * \tparam VectorType - can be LocalVector or GlobalVector 49 | * \tparam ValueType - can be float, double, std::complex or std::complex 50 | */ 51 | template 52 | class FCG : public IterativeLinearSolver 53 | { 54 | public: 55 | ROCALUTION_EXPORT 56 | FCG(); 57 | ROCALUTION_EXPORT 58 | virtual ~FCG(); 59 | 60 | ROCALUTION_EXPORT 61 | virtual void Print(void) const; 62 | 63 | ROCALUTION_EXPORT 64 | virtual void Build(void); 65 | ROCALUTION_EXPORT 66 | virtual void ReBuildNumeric(void); 67 | ROCALUTION_EXPORT 68 | virtual void Clear(void); 69 | 70 | protected: 71 | virtual void SolveNonPrecond_(const VectorType& rhs, VectorType* x); 72 | virtual void SolvePrecond_(const VectorType& rhs, VectorType* x); 73 | 74 | virtual void PrintStart_(void) const; 75 | virtual void PrintEnd_(void) const; 76 | 77 | virtual void MoveToHostLocalData_(void); 78 | virtual void MoveToAcceleratorLocalData_(void); 79 | 80 | private: 81 | VectorType r_, w_, z_; 82 | VectorType p_, q_; 83 | }; 84 | 85 | } // namespace rocalution 86 | 87 | #endif // ROCALUTION_KRYLOV_FCG_HPP_ 88 | -------------------------------------------------------------------------------- /src/solvers/krylov/qmrcgstab.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_KRYLOV_QMRCGSTAB_HPP_ 25 | #define ROCALUTION_KRYLOV_QMRCGSTAB_HPP_ 26 | 27 | #include "../solver.hpp" 28 | #include "rocalution/export.hpp" 29 | 30 | #include 31 | 32 | namespace rocalution 33 | { 34 | 35 | /** \ingroup solver_module 36 | * \class QMRCGStab 37 | * \brief Quasi-Minimal Residual Conjugate Gradient Stabilized Method 38 | * \details 39 | * The Quasi-Minimal Residual Conjugate Gradient Stabilized method is a variant of the 40 | * Krylov subspace BiCGStab method for solving sparse (non) symmetric linear systems 41 | * \f$Ax=b\f$. 42 | * \cite qmrcgstab 43 | * 44 | * \tparam OperatorType - can be LocalMatrix or GlobalMatrix 45 | * \tparam VectorType - can be LocalVector or GlobalVector 46 | * \tparam ValueType - can be float, double, std::complex or std::complex 47 | */ 48 | template 49 | class QMRCGStab : public IterativeLinearSolver 50 | { 51 | public: 52 | ROCALUTION_EXPORT 53 | QMRCGStab(); 54 | ROCALUTION_EXPORT 55 | virtual ~QMRCGStab(); 56 | 57 | ROCALUTION_EXPORT 58 | virtual void Print(void) const; 59 | 60 | ROCALUTION_EXPORT 61 | virtual void Build(void); 62 | ROCALUTION_EXPORT 63 | virtual void ReBuildNumeric(void); 64 | ROCALUTION_EXPORT 65 | virtual void Clear(void); 66 | 67 | protected: 68 | virtual void SolveNonPrecond_(const VectorType& rhs, VectorType* x); 69 | virtual void SolvePrecond_(const VectorType& rhs, VectorType* x); 70 | 71 | virtual void PrintStart_(void) const; 72 | virtual void PrintEnd_(void) const; 73 | 74 | virtual void MoveToHostLocalData_(void); 75 | virtual void MoveToAcceleratorLocalData_(void); 76 | 77 | private: 78 | VectorType r0_, r_; 79 | VectorType t_, p_; 80 | VectorType v_, d_; 81 | VectorType z_; 82 | }; 83 | 84 | } // namespace rocalution 85 | 86 | #endif // ROCALUTION_KRYLOV_QMRCGSTAB_HPP_ 87 | -------------------------------------------------------------------------------- /src/solvers/preconditioners/preconditioner_blockjacobi.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_PRECONDITIONER_BLOCKJACOBI_HPP_ 25 | #define ROCALUTION_PRECONDITIONER_BLOCKJACOBI_HPP_ 26 | 27 | #include "preconditioner.hpp" 28 | #include "rocalution/export.hpp" 29 | 30 | namespace rocalution 31 | { 32 | 33 | /** \ingroup precond_module 34 | * \class BlockJacobi 35 | * \brief Block-Jacobi Preconditioner 36 | * \details 37 | * The Block-Jacobi preconditioner is designed to wrap any local preconditioner and 38 | * apply it in a global block fashion locally on each interior matrix. 39 | * 40 | * \tparam OperatorType - can be GlobalMatrix 41 | * \tparam VectorType - can be GlobalVector 42 | * \tparam ValueType - can be float, double, std::complex or std::complex 43 | */ 44 | template 45 | class BlockJacobi : public Preconditioner 46 | { 47 | public: 48 | ROCALUTION_EXPORT 49 | BlockJacobi(); 50 | ROCALUTION_EXPORT 51 | virtual ~BlockJacobi(); 52 | 53 | ROCALUTION_EXPORT 54 | virtual void Print(void) const; 55 | 56 | /** \brief Set local preconditioner */ 57 | ROCALUTION_EXPORT 58 | void Set(Solver, LocalVector, ValueType>& precond); 59 | 60 | ROCALUTION_EXPORT 61 | virtual void Solve(const VectorType& rhs, VectorType* x); 62 | 63 | ROCALUTION_EXPORT 64 | virtual void SolveZeroSol(const VectorType& rhs, VectorType* x); 65 | 66 | ROCALUTION_EXPORT 67 | virtual void Build(void); 68 | ROCALUTION_EXPORT 69 | virtual void ReBuildNumeric(void); 70 | ROCALUTION_EXPORT 71 | virtual void Clear(void); 72 | 73 | protected: 74 | virtual void MoveToHostLocalData_(void); 75 | virtual void MoveToAcceleratorLocalData_(void); 76 | 77 | private: 78 | Solver, LocalVector, ValueType>* local_precond_; 79 | }; 80 | 81 | } // namespace rocalution 82 | 83 | #endif // ROCALUTION_PRECONDITIONER_BLOCKJACOBI_HPP_ 84 | -------------------------------------------------------------------------------- /src/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ######################################################################## 2 | # Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights Reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | # 22 | # ######################################################################## 23 | 24 | set(UTILS_SOURCES 25 | utils/log.cpp 26 | utils/allocate_free.cpp 27 | utils/math_functions.cpp 28 | utils/time_functions.cpp 29 | utils/rocsparseio.cpp 30 | ) 31 | 32 | set(UTILS_PUBLIC_HEADERS 33 | utils/def.hpp 34 | utils/allocate_free.hpp 35 | utils/time_functions.hpp 36 | ) 37 | 38 | set(UTILS_MPI_SOURCES 39 | utils/communicator.cpp 40 | ) 41 | -------------------------------------------------------------------------------- /src/utils/def.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_UTILS_DEF_HPP_ 25 | #define ROCALUTION_UTILS_DEF_HPP_ 26 | 27 | // Uncomment to define verbose level 28 | #define VERBOSE_LEVEL 2 29 | 30 | // Uncomment for debug mode 31 | // #define DEBUG_MODE 32 | 33 | // Uncomment to disable the assert()s 34 | // #define ASSERT_OFF 35 | 36 | // Uncomment to log only on specific MPI rank 37 | // When logging into a file, this will be unset 38 | #define LOG_MPI_RANK 0 39 | 40 | // Comment to enable automatic object tracking 41 | #define OBJ_TRACKING_OFF 42 | 43 | // ****************** 44 | // ****************** 45 | // Do not edit below! 46 | // ****************** 47 | // ****************** 48 | 49 | #ifdef ASSERT_OFF 50 | #define assert(a) ; 51 | #else 52 | #ifdef NDEBUG 53 | #undef NDEBUG 54 | #include 55 | #define NDEBUG 56 | #else 57 | #include 58 | #endif 59 | #endif 60 | 61 | #ifdef DEBUG_MODE 62 | #define assert_dbg(a) assert(a) 63 | #else 64 | #define assert_dbg(a) ; 65 | #endif 66 | 67 | #define SUPPORT_COMPLEX 68 | 69 | #endif // ROCALUTION_UTILS_DEF_HPP_ 70 | -------------------------------------------------------------------------------- /src/utils/log.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #include "log.hpp" 25 | #include "../base/backend_manager.hpp" 26 | #include "def.hpp" 27 | #include "time_functions.hpp" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | namespace rocalution 36 | { 37 | 38 | void _rocalution_open_log_file(void) 39 | { 40 | char* str_layer_mode; 41 | if((str_layer_mode = getenv("ROCALUTION_LAYER")) != NULL) 42 | { 43 | if(atoi(str_layer_mode) == 1) 44 | { 45 | if(_get_backend_descriptor()->log_file != NULL) 46 | { 47 | _rocalution_close_log_file(); 48 | } 49 | 50 | assert(_get_backend_descriptor()->log_file == NULL); 51 | 52 | _get_backend_descriptor()->log_file = new std::ofstream; 53 | 54 | std::ostringstream str_double; 55 | str_double.precision(20); 56 | str_double << rocalution_time(); 57 | std::string mid_name = str_double.str(); 58 | 59 | std::ostringstream rank; 60 | rank << _get_backend_descriptor()->rank; 61 | std::string rank_name = rank.str(); 62 | 63 | std::string str_name; 64 | str_name = "rocalution-rank-" + rank_name + "-" + mid_name + ".log"; 65 | 66 | _get_backend_descriptor()->log_file->open(str_name.c_str(), 67 | std::ios::out | std::ios::trunc); 68 | } 69 | } 70 | } 71 | 72 | void _rocalution_close_log_file(void) 73 | { 74 | if(_get_backend_descriptor()->log_file != NULL) 75 | { 76 | if(_get_backend_descriptor()->log_file->is_open()) 77 | { 78 | _get_backend_descriptor()->log_file->close(); 79 | delete _get_backend_descriptor()->log_file; 80 | _get_backend_descriptor()->log_file = NULL; 81 | } 82 | } 83 | } 84 | 85 | } // namespace rocalution 86 | -------------------------------------------------------------------------------- /src/utils/log_mpi.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_UTILS_LOG_MPI_HPP_ 25 | #define ROCALUTION_UTILS_LOG_MPI_HPP_ 26 | 27 | #include "log.hpp" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #define CHECK_MPI_ERROR(err_t, file, line) \ 34 | { \ 35 | if(err_t != MPI_SUCCESS) \ 36 | { \ 37 | LOG_INFO("MPI ERROR: " << err_t); \ 38 | LOG_INFO("File: " << file << "; line: " << line); \ 39 | exit(1); \ 40 | } \ 41 | } 42 | 43 | #endif // ROCALUTION_UTILS_LOG_MPI_HPP_ 44 | -------------------------------------------------------------------------------- /src/utils/rocalution.ptk.in: -------------------------------------------------------------------------------- 1 | 2 | prefix=${CMAKE_BINARY_DIR} 3 | exec_prefix=${CMAKE_BINARY_DIR} 4 | libdir=${LIB_BUILD_DIR} 5 | includedir=${INC_BUILD_DIR} 6 | 7 | Name: librocalution 8 | Description: rocALUTION 9 | Version: ${rocALUTION_VERSION} 10 | Requires: 11 | Libs: -L${LIB_BUILD_DIR} -lrocalution 12 | Libs.private: 13 | Cflags: -I${INC_BUILD_DIR} 14 | 15 | -------------------------------------------------------------------------------- /src/utils/time_functions.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2020 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #include "def.hpp" 25 | #include 26 | 27 | #include "../base/backend_manager.hpp" 28 | #include "time_functions.hpp" 29 | 30 | // the default OS is Linux 31 | 32 | #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) \ 33 | || defined(__WIN64) && !defined(__CYGWIN__) 34 | // Windows 35 | #include 36 | 37 | #else 38 | // Linux 39 | #include 40 | 41 | #endif 42 | 43 | namespace rocalution 44 | { 45 | 46 | double rocalution_time(void) 47 | { 48 | double the_time_now = 0.0; 49 | 50 | _rocalution_sync(); 51 | #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) \ 52 | || defined(__WIN64) && !defined(__CYGWIN__) 53 | // Windows 54 | LARGE_INTEGER now; 55 | LARGE_INTEGER freq; 56 | 57 | QueryPerformanceCounter(&now); 58 | QueryPerformanceFrequency(&freq); 59 | 60 | the_time_now = (now.QuadPart * 1000000.0) / static_cast(freq.QuadPart); 61 | #else 62 | // Linux 63 | struct timeval now; 64 | 65 | gettimeofday(&now, NULL); 66 | the_time_now = now.tv_sec * 1000000.0 + (now.tv_usec); 67 | #endif 68 | return the_time_now; 69 | } 70 | 71 | } // namespace rocalution 72 | -------------------------------------------------------------------------------- /src/utils/time_functions.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2018-2021 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_UTILS_TIME_FUNCTIONS_HPP_ 25 | #define ROCALUTION_UTILS_TIME_FUNCTIONS_HPP_ 26 | 27 | #include "rocalution/export.hpp" 28 | 29 | namespace rocalution 30 | { 31 | 32 | /** \ingroup backend_module 33 | * \brief Return current time in microseconds 34 | */ 35 | ROCALUTION_EXPORT 36 | double rocalution_time(void); 37 | 38 | } // namespace rocalution 39 | 40 | #endif // ROCALUTION_UTILS_TIME_FUNCTIONS_HPP_ 41 | -------------------------------------------------------------------------------- /src/utils/type_traits.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_UTILS_TYPE_TRAITS_HPP_ 25 | #define ROCALUTION_UTILS_TYPE_TRAITS_HPP_ 26 | 27 | #include 28 | 29 | namespace rocalution 30 | { 31 | // 32 | // Convenience traits. 33 | // 34 | template 35 | struct numeric_traits 36 | { 37 | using value_type = T; 38 | }; 39 | 40 | template <> 41 | struct numeric_traits> 42 | { 43 | using value_type = float; 44 | }; 45 | 46 | template <> 47 | struct numeric_traits> 48 | { 49 | using value_type = double; 50 | }; 51 | 52 | template <> 53 | struct numeric_traits 54 | { 55 | using value_type = float; 56 | }; 57 | template <> 58 | struct numeric_traits 59 | { 60 | using value_type = double; 61 | }; 62 | 63 | template 64 | using numeric_traits_t = typename numeric_traits::value_type; 65 | } 66 | 67 | #endif // ROCALUTION_UTILS_TYPE_TRAITS_HPP_ 68 | -------------------------------------------------------------------------------- /src/utils/types.hpp.in: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ 2 | * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights Reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * ************************************************************************ */ 23 | 24 | #ifndef ROCALUTION_UTILS_TYPES_HPP_ 25 | #define ROCALUTION_UTILS_TYPES_HPP_ 26 | 27 | #include "def.hpp" 28 | 29 | // clang-format off 30 | #define GlobalType @rocalution_GLOBAL_TYPE@ 31 | #define LocalType @rocalution_LOCAL_TYPE@ 32 | #define PtrType @rocalution_PTR_TYPE@ 33 | // clang-format on 34 | 35 | namespace rocalution 36 | { 37 | struct mis_tuple 38 | { 39 | int s; 40 | unsigned int v; 41 | int i; 42 | }; 43 | } // namespace rocalution 44 | 45 | #endif // ROCALUTION_UTILS_TYPES_HPP_ 46 | -------------------------------------------------------------------------------- /suppr.txt: -------------------------------------------------------------------------------- 1 | leak:libhsa-runtime64 2 | leak:libamd_comgr 3 | leak:libamdhip64 4 | leak:libhsakmt 5 | -------------------------------------------------------------------------------- /toolchain-linux.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (DEFINED ENV{ROCM_PATH}) 3 | set(rocm_bin "$ENV{ROCM_PATH}/bin") 4 | else() 5 | set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to the ROCm installation.") 6 | set(rocm_bin "/opt/rocm/bin") 7 | endif() 8 | 9 | if (NOT DEFINED ENV{CXX}) 10 | set(CMAKE_CXX_COMPILER "${rocm_bin}/amdclang++") 11 | else() 12 | set(CMAKE_CXX_COMPILER "$ENV{CXX}") 13 | endif() 14 | 15 | if (NOT DEFINED ENV{CC}) 16 | set(CMAKE_C_COMPILER "${rocm_bin}/amdclang") 17 | else() 18 | set(CMAKE_C_COMPILER "$ENV{CC}") 19 | endif() 20 | --------------------------------------------------------------------------------