├── .azuredevops └── rocm-ci.yml ├── .clang-format ├── .githooks ├── install └── pre-commit ├── .github ├── CODEOWNERS ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── dependabot.yml ├── .gitignore ├── .jenkins ├── common.groovy ├── debug.groovy ├── multigpu.groovy ├── staticanalysis.groovy └── staticlibrary.groovy ├── .readthedocs.yaml ├── CHANGELOG.md ├── CMakeLists.txt ├── CppCheckSuppressions.txt ├── LICENSE.md ├── README.md ├── clients ├── CMakeLists.txt ├── bench │ ├── CMakeLists.txt │ ├── bench.cpp │ └── bench.h ├── cmake │ ├── FindFFTW.cmake │ └── build-options.cmake ├── hipfft_params.h ├── samples │ ├── CMakeLists.txt │ ├── hipfft_1d_d2z.cpp │ ├── hipfft_1d_z2z.cpp │ ├── hipfft_2d_d2z.cpp │ ├── hipfft_2d_z2z.cpp │ ├── hipfft_3d_d2z.cpp │ ├── hipfft_3d_z2z.cpp │ ├── hipfft_callback.cpp │ ├── hipfft_multigpu_2d_z2z.cpp │ ├── hipfft_planmany_2d_r2c.cpp │ ├── hipfft_planmany_2d_z2z.cpp │ └── hipfft_setworkarea.cpp └── tests │ ├── CMakeLists.txt │ ├── accuracy_test_1D.cpp │ ├── accuracy_test_2D.cpp │ ├── accuracy_test_3D.cpp │ ├── accuracy_test_callback.cpp │ ├── gtest_main.cpp │ ├── hipfft_accuracy_test.cpp │ ├── hipfft_accuracy_test.h │ ├── hipfft_mpi_worker.cpp │ ├── hipfft_test_params.h │ ├── multi_device_test.cpp │ └── simple_test.cpp ├── cmake ├── dependencies.cmake ├── get-cli-arguments.cmake ├── package-functions.cmake └── verbose.cmake ├── deps ├── CMakeLists.txt ├── external-boost.cmake └── external-gtest.cmake ├── docs ├── .gitignore ├── conceptual │ └── overview.rst ├── conf.py ├── doxygen │ └── Doxyfile ├── index.rst ├── install │ └── building-installing-hipfft.rst ├── license.md ├── reference │ └── fft-api-usage.rst └── sphinx │ ├── _toc.yml.in │ ├── requirements.in │ └── requirements.txt ├── library ├── CMakeLists.txt ├── include │ └── hipfft │ │ ├── hipfft-version.h.in │ │ ├── hipfft.h │ │ ├── hipfftMp.h │ │ ├── hipfftXt.h │ │ └── hiplibxt.h └── src │ ├── CMakeLists.txt │ ├── amd_detail │ └── hipfft.cpp │ ├── hipfft-config.cmake.in │ └── nvidia_detail │ └── hipfft.cpp ├── rmake.py ├── rtest.xml ├── shared ├── CLI11.hpp ├── accuracy_test.h ├── arithmetic.h ├── array_predicate.h ├── array_validator.cpp ├── array_validator.h ├── client_except.h ├── concurrency.h ├── data_gen_device.h ├── data_gen_host.h ├── device_properties.h ├── enum_to_string.h ├── environment.h ├── fft_hash.h ├── fft_params.h ├── fftw_transform.h ├── gpubuf.h ├── hip_object_wrapper.h ├── hipfft_brick.h ├── hostbuf.h ├── increment.h ├── index_partition_omp.h ├── mpi_worker.h ├── params_gen.h ├── precision_type.h ├── printbuffer.h ├── ptrdiff.h ├── rocfft_accuracy_test.h ├── rocfft_against_fftw.h ├── rocfft_complex.h ├── rocfft_hip.h ├── rocfft_params.h ├── subprocess.h ├── sys_mem.h ├── test_params.h └── work_queue.h ├── 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 }}/hipFFT.yml@pipelines_repo 45 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # Style file for MLSE Libraries based on the modified rocBLAS style 2 | 3 | # Common settings 4 | BasedOnStyle: WebKit 5 | TabWidth: 4 6 | IndentWidth: 4 7 | UseTab: Never 8 | ColumnLimit: 100 9 | 10 | # Other languages JavaScript, Proto 11 | 12 | --- 13 | Language: Cpp 14 | 15 | # http://releases.llvm.org/6.0.1/tools/clang/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code 16 | # int formatted_code; 17 | # // clang-format off 18 | # void unformatted_code ; 19 | # // clang-format on 20 | # void formatted_code_again; 21 | 22 | DisableFormat: false 23 | Standard: Cpp11 24 | 25 | AccessModifierOffset: -4 26 | AlignAfterOpenBracket: Align 27 | AlignConsecutiveAssignments: true 28 | AlignConsecutiveDeclarations: true 29 | AlignEscapedNewlines: Left 30 | AlignOperands: true 31 | AlignTrailingComments: false 32 | AllowAllArgumentsOnNextLine: true 33 | AllowAllConstructorInitializersOnNextLine: true 34 | AllowAllParametersOfDeclarationOnNextLine: true 35 | AllowShortBlocksOnASingleLine: false 36 | AllowShortCaseLabelsOnASingleLine: false 37 | AllowShortFunctionsOnASingleLine: Empty 38 | AllowShortIfStatementsOnASingleLine: false 39 | AllowShortLoopsOnASingleLine: false 40 | AlwaysBreakAfterDefinitionReturnType: false 41 | AlwaysBreakAfterReturnType: None 42 | AlwaysBreakBeforeMultilineStrings: false 43 | AlwaysBreakTemplateDeclarations: true 44 | BinPackArguments: false 45 | BinPackParameters: false 46 | 47 | # Configure each individual brace in BraceWrapping 48 | BreakBeforeBraces: Custom 49 | # Control of individual brace wrapping cases 50 | BraceWrapping: { 51 | AfterCaseLabel: 'true' 52 | AfterClass: 'true' 53 | AfterControlStatement: 'true' 54 | AfterEnum : 'true' 55 | AfterFunction : 'true' 56 | AfterNamespace : 'true' 57 | AfterStruct : 'true' 58 | AfterUnion : 'true' 59 | BeforeCatch : 'true' 60 | BeforeElse : 'true' 61 | IndentBraces : 'false' 62 | # AfterExternBlock : 'true' 63 | } 64 | 65 | #BreakAfterJavaFieldAnnotations: true 66 | #BreakBeforeInheritanceComma: false 67 | #BreakBeforeBinaryOperators: None 68 | #BreakBeforeTernaryOperators: true 69 | #BreakConstructorInitializersBeforeComma: true 70 | #BreakStringLiterals: true 71 | 72 | CommentPragmas: '^ IWYU pragma:' 73 | #CompactNamespaces: false 74 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 75 | ConstructorInitializerIndentWidth: 4 76 | ContinuationIndentWidth: 4 77 | Cpp11BracedListStyle: true 78 | SpaceBeforeCpp11BracedList: false 79 | DerivePointerAlignment: false 80 | ExperimentalAutoDetectBinPacking: false 81 | ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] 82 | IndentCaseLabels: false 83 | IndentPPDirectives: None 84 | #FixNamespaceComments: true 85 | IndentWrappedFunctionNames: true 86 | KeepEmptyLinesAtTheStartOfBlocks: true 87 | MacroBlockBegin: '' 88 | MacroBlockEnd: '' 89 | #JavaScriptQuotes: Double 90 | MaxEmptyLinesToKeep: 1 91 | NamespaceIndentation: All 92 | ObjCBlockIndentWidth: 4 93 | #ObjCSpaceAfterProperty: true 94 | #ObjCSpaceBeforeProtocolList: true 95 | PenaltyBreakBeforeFirstCallParameter: 19 96 | PenaltyBreakComment: 300 97 | PenaltyBreakFirstLessLess: 120 98 | PenaltyBreakString: 1000 99 | 100 | PenaltyExcessCharacter: 1000000 101 | PenaltyReturnTypeOnItsOwnLine: 60 102 | PointerAlignment: Left 103 | SpaceAfterCStyleCast: false 104 | SpaceBeforeAssignmentOperators: true 105 | SpaceBeforeParens: Never 106 | SpaceInEmptyBlock: false 107 | SpaceInEmptyParentheses: false 108 | SpacesBeforeTrailingComments: 1 109 | SpacesInAngles: false 110 | SpacesInContainerLiterals: true 111 | SpacesInCStyleCastParentheses: false 112 | SpacesInParentheses: false 113 | SpacesInSquareBrackets: false 114 | #SpaceAfterTemplateKeyword: true 115 | #SpaceBeforeInheritanceColon: true 116 | 117 | #SortUsingDeclarations: true 118 | SortIncludes: true 119 | 120 | # Comments are for developers, they should arrange them 121 | ReflowComments: false 122 | 123 | #IncludeBlocks: Preserve 124 | --- 125 | -------------------------------------------------------------------------------- /.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 -s ../../.githooks/pre-commit pre-commit 8 | echo "Done!" 9 | -------------------------------------------------------------------------------- /.githooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 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 | base=/opt/rocm/hcc/bin/clang-format 8 | format="" 9 | 10 | # Redirect output to stderr. 11 | exec 1>&2 12 | 13 | # check if clang-format is installed 14 | type "$base" >/dev/null 2>&1 && format="$base" 15 | 16 | # no versions of clang-format are installed 17 | if [ -z "$format" ] 18 | then 19 | echo "$base is not installed. Pre-commit hook will not be executed." 20 | exit 0 21 | fi 22 | 23 | # Do everything from top - level 24 | cd $(git rev-parse --show-toplevel) 25 | 26 | if git rev-parse --verify HEAD >/dev/null 2>&1 27 | then 28 | against=HEAD 29 | else 30 | # Initial commit: diff against an empty tree object 31 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 32 | fi 33 | 34 | # do the formatting 35 | for file in $(git diff-index --cached --name-only $against | grep -E '\.h$|\.hpp$|\.cpp$|\.cl$|\.h\.in$|\.hpp\.in$|\.cpp\.in$') 36 | do 37 | if [ -e "$file" ] 38 | then 39 | echo "$format $file" 40 | "$format" -i -style=file "$file" 41 | fi 42 | done 43 | 44 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @af-ayala @eng-flavio-teixeira @evetsso @malcolmroberts @regan-amd 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 | # Header directory for Doxygen documentation 8 | library/include/ @ROCm/rocm-documentation @af-ayala @eng-flavio-teixeira @evetsso @malcolmroberts @regan-amd 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### What is the expected behavior 2 | - 3 | 4 | ### What actually happens 5 | - 6 | 7 | ### How to reproduce 8 | - 9 | 10 | ### Environment 11 | | Hardware | description | 12 | |-----|-----| 13 | | GPU | device string | 14 | | CPU | device string | 15 | 16 | | Software | version | 17 | |-----|-----| 18 | | ROCK | v0.0 | 19 | | ROCR | v0.0 | 20 | | HCC | v0.0 | 21 | | Library | v0.0 | 22 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | resolves #___ 2 | 3 | Summary of proposed changes: 4 | - 5 | - 6 | - 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: "monthly" 13 | labels: 14 | - "documentation" 15 | - "dependencies" 16 | - "ci:docs-only" 17 | reviewers: 18 | - "samjwu" 19 | - "malcolmroberts" 20 | - "evetsso" 21 | -------------------------------------------------------------------------------- /.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 | # Visual Studio Code 36 | .vscode 37 | 38 | # documentation artifacts 39 | build/ 40 | _build/ 41 | _images/ 42 | _static/ 43 | _templates/ 44 | _toc.yml 45 | docBin/ 46 | 47 | # python bytecode 48 | __pycache__ 49 | -------------------------------------------------------------------------------- /.jenkins/common.groovy: -------------------------------------------------------------------------------- 1 | import static groovy.io.FileType.FILES 2 | 3 | def runCompileCommand(platform, project, jobName, boolean sameOrg = false) 4 | { 5 | project.paths.construct_build_prefix() 6 | 7 | def getDependenciesCommand = "" 8 | if (project.installLibraryDependenciesFromCI) 9 | { 10 | project.libraryDependencies.each 11 | { libraryName -> 12 | getDependenciesCommand += auxiliary.getLibrary(libraryName, platform.jenkinsLabel, null, sameOrg) 13 | } 14 | } 15 | 16 | String cmake = platform.jenkinsLabel.contains('centos') ? "cmake3" : "cmake" 17 | String warningArgs = platform.jenkinsLabel.contains('cuda') ? '':'-DWERROR=ON' 18 | String hipClang = platform.jenkinsLabel.contains('hipClang') ? "HIP_COMPILER=clang" : "" 19 | String path = platform.jenkinsLabel.contains('centos7') ? "export PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH" : ":" 20 | String dir = jobName.contains('Debug') ? "debug" : "release" 21 | 22 | // hipcc with CUDA backend needs HIP_PLATFORM set accordingly in the environment 23 | String hipPlatformCommand = platform.jenkinsLabel.contains("cuda") ? "export HIP_PLATFORM=nvidia" : "" 24 | 25 | def command = """#!/usr/bin/env bash 26 | set -x 27 | 28 | ls /fftw/lib 29 | export FFTW_ROOT=/fftw 30 | export FFTW_INCLUDE_PATH=\${FFTW_ROOT}/include 31 | export FFTW_LIB_PATH=\${FFTW_ROOT}/lib 32 | export LD_LIBRARY_PATH=\${FFTW_LIB_PATH}:/opt/rocm/lib:/opt/rocm/hip/lib 33 | export CPLUS_INCLUDE_PATH=\${FFTW_INCLUDE_PATH}:\${CPLUS_INCLUDE_PATH} 34 | export CMAKE_PREFIX_PATH=\${FFTW_LIB_PATH}/cmake/fftw3:\${CMAKE_PREFIX_PATH} 35 | export CMAKE_PREFIX_PATH=\${FFTW_LIB_PATH}/cmake/fftw3f:\${CMAKE_PREFIX_PATH} 36 | # default container flags cause problems for CUDA backend, and aren't useful for ROCm 37 | unset HIPCC_COMPILE_FLAGS_APPEND 38 | unset HIPCC_LINK_FLAGS_APPEND 39 | ${hipPlatformCommand} 40 | 41 | cd ${project.paths.project_build_prefix} 42 | mkdir -p build/${dir} && cd build/${dir} 43 | ${getDependenciesCommand} 44 | ${path} 45 | ${hipClang} ${cmake} ${warningArgs} ${project.paths.build_command} 46 | make -j\$(nproc) 47 | """ 48 | 49 | platform.runCommand(this, command) 50 | } 51 | 52 | def runTestCommand (platform, project, gfilter) 53 | { 54 | String cudaArgs = platform.jenkinsLabel.contains('cuda') ? '--double_epsilon=5e-11' 55 | : '--precompile=rocfft-test-precompile.db' 56 | 57 | def command = """#!/usr/bin/env bash 58 | set -x 59 | cd ${project.paths.project_build_prefix}/build/release/clients/staging 60 | GTEST_LISTENER=NO_PASS_LINE_IN_LOG ./hipfft-test ${cudaArgs} --gtest_output=xml --gtest_color=yes --gtest_filter=${gfilter} 61 | """ 62 | 63 | platform.runCommand(this, command) 64 | //junit "${project.paths.project_build_prefix}/build/release/clients/staging/*.xml" 65 | } 66 | 67 | def runPackageCommand(platform, project, jobName, label='') 68 | { 69 | def command 70 | 71 | label = label != '' ? '-' + label.toLowerCase() : '' 72 | String ext = platform.jenkinsLabel.contains('ubuntu') ? "deb" : "rpm" 73 | String dir = jobName.contains('Debug') ? "debug" : "release" 74 | 75 | command = """ 76 | set -x 77 | cd ${project.paths.project_build_prefix}/build/${dir} 78 | make package 79 | mkdir -p package 80 | for f in hipfft*.$ext 81 | do 82 | mv "\$f" "hipfft${label}-\${f#*-}" 83 | done 84 | mv *.${ext} package/ 85 | """ 86 | 87 | platform.runCommand(this, command) 88 | platform.archiveArtifacts(this, """${project.paths.project_build_prefix}/build/${dir}/package/*.${ext}""") 89 | } 90 | 91 | 92 | return this 93 | -------------------------------------------------------------------------------- /.jenkins/debug.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | @Library('rocJenkins@pong') _ 3 | 4 | import com.amd.project.* 5 | import com.amd.docker.* 6 | import java.nio.file.Path 7 | 8 | def runCI = 9 | { 10 | nodeDetails, jobName, buildCommand -> 11 | 12 | def prj = new rocProject('hipFFT', 'Debug') 13 | // customize for project 14 | prj.paths.build_command = buildCommand 15 | prj.libraryDependencies = ['rocRAND', 'rocFFT', 'hipRAND'] 16 | 17 | // Define test architectures, optional rocm version argument is available 18 | def nodes = new dockerNodes(nodeDetails, jobName, prj) 19 | 20 | def commonGroovy 21 | 22 | boolean formatCheck = false 23 | 24 | def compileCommand = 25 | { 26 | platform, project-> 27 | 28 | project.paths.construct_build_prefix() 29 | 30 | commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" 31 | commonGroovy.runCompileCommand(platform, project, jobName) 32 | } 33 | 34 | buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, null, null) 35 | } 36 | 37 | def setupCI(urlJobName, jobNameList, buildCommand, runCI, label) 38 | { 39 | jobNameList = auxiliary.appendJobNameList(jobNameList) 40 | 41 | jobNameList.each 42 | { 43 | jobName, nodeDetails-> 44 | if (urlJobName == jobName) 45 | stage(label + ' ' + jobName) { 46 | runCI(nodeDetails, jobName, buildCommand, label) 47 | } 48 | } 49 | 50 | // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 51 | if(!jobNameList.keySet().contains(urlJobName)) 52 | { 53 | properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) 54 | stage(label + ' ' + urlJobName) { 55 | runCI([ubuntu18:['gfx906']], urlJobName, buildCommand, label) 56 | } 57 | } 58 | } 59 | 60 | ci: { 61 | String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) 62 | 63 | def propertyList = ["compute-rocm-dkms-no-npi":[pipelineTriggers([cron('0 1 * * 0')])]] 64 | 65 | propertyList = auxiliary.appendPropertyList(propertyList) 66 | 67 | propertyList.each 68 | { 69 | jobName, property-> 70 | if (urlJobName == jobName) 71 | properties(auxiliary.addCommonProperties(property)) 72 | } 73 | 74 | def hostJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['gfx900'],centos7:['gfx906'],sles15sp1:['gfx906']])] 75 | 76 | def hipClangJobNameList = ["compute-rocm-dkms-no-npi":([ubuntu18:['gfx900'],centos7:['gfx906'],sles15sp1:['gfx906']])] 77 | 78 | String hostBuildCommand = '-DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Debug -L ../..' 79 | String hipClangBuildCommand = '-DCMAKE_CXX_COMPILER=/opt/rocm/bin/amdclang++ -DCMAKE_BUILD_TYPE=Debug -DBUILD_CLIENTS_TESTS=ON -DBUILD_CLIENTS_SAMPLES=ON -DBUILD_CLIENTS_SAMPLES=ON -L ../..' 80 | 81 | setupCI(urlJobName, hostJobNameList, hostBuildCommand, runCI, 'g++') 82 | setupCI(urlJobName, hipClangJobNameList, hipClangBuildCommand, runCI, 'hip-clang') 83 | } 84 | -------------------------------------------------------------------------------- /.jenkins/multigpu.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | @Library('rocJenkins@pong') _ 3 | 4 | import com.amd.project.* 5 | import com.amd.docker.* 6 | import java.nio.file.Path 7 | 8 | def runCI = 9 | { 10 | nodeDetails, jobName, buildCommand, label, runTest -> 11 | 12 | def prj = new rocProject('hipFFT', 'multigpu') 13 | // customize for project 14 | prj.paths.build_command = buildCommand 15 | prj.libraryDependencies = ['rocRAND', 'rocFFT', 'hipRAND'] 16 | prj.timeout.test = 360 17 | 18 | // Define test architectures, optional rocm version argument is available 19 | def nodes = new dockerNodes(nodeDetails, jobName, prj) 20 | 21 | def commonGroovy 22 | 23 | boolean formatCheck = false 24 | 25 | def compileCommand = 26 | { 27 | platform, project-> 28 | 29 | project.paths.construct_build_prefix() 30 | 31 | commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" 32 | commonGroovy.runCompileCommand(platform, project,jobName) 33 | } 34 | 35 | def testCommand = 36 | { 37 | platform, project-> 38 | 39 | def gfilter = "*multi_gpu*" 40 | commonGroovy.runTestCommand(platform, project, gfilter) 41 | } 42 | 43 | def packageCommand = 44 | { 45 | platform, project-> 46 | 47 | commonGroovy.runPackageCommand(platform, project, jobName, label) 48 | } 49 | 50 | buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, runTest ? testCommand : null, packageCommand) 51 | } 52 | 53 | def setupCI(urlJobName, jobNameList, buildCommand, runCI, label, runTest) 54 | { 55 | jobNameList = auxiliary.appendJobNameList(jobNameList) 56 | 57 | jobNameList.each 58 | { 59 | jobName, nodeDetails-> 60 | if (urlJobName == jobName) 61 | stage(label + ' ' + jobName) { 62 | runCI(nodeDetails, jobName, buildCommand, label, runTest) 63 | } 64 | } 65 | 66 | // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 67 | if(!jobNameList.keySet().contains(urlJobName)) 68 | { 69 | properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) 70 | stage(label + ' ' + urlJobName) { 71 | runCI([ubuntu18:['gfx906']], urlJobName, buildCommand, label) 72 | } 73 | } 74 | } 75 | 76 | ci: { 77 | String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) 78 | 79 | def propertyList = ["main":[pipelineTriggers([cron('0 6 * * 0')])]] 80 | 81 | propertyList = auxiliary.appendPropertyList(propertyList) 82 | 83 | def jobNameList = ["main":([ubuntu20:['8gfx90a']])] 84 | jobNameList = auxiliary.appendJobNameList(jobNameList) 85 | 86 | propertyList.each 87 | { 88 | jobName, property-> 89 | if (urlJobName == jobName) 90 | properties(auxiliary.addCommonProperties(property)) 91 | } 92 | 93 | String hipClangBuildCommand = '-DCMAKE_CXX_COMPILER=/opt/rocm/bin/amdclang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CLIENTS_TESTS=ON -DBUILD_CLIENTS_SAMPLES=ON -L ../..' 94 | 95 | setupCI(urlJobName, jobNameList, hipClangBuildCommand, runCI, 'hip-clang', true) 96 | } 97 | -------------------------------------------------------------------------------- /.jenkins/staticanalysis.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | @Library('rocJenkins@pong') _ 3 | 4 | import com.amd.project.* 5 | import com.amd.docker.* 6 | import java.nio.file.Path 7 | 8 | def runCI = 9 | { 10 | nodeDetails, jobName -> 11 | 12 | def prj = new rocProject('hipFFT-internal', 'PreCheckin') 13 | // customize for project 14 | prj.libraryDependencies = ['rocRAND','rocFFT'] 15 | 16 | // Define test architectures, optional rocm version argument is available 17 | def nodes = new dockerNodes(nodeDetails, jobName, prj) 18 | 19 | boolean formatCheck = true 20 | boolean staticAnalysis = true 21 | 22 | buildProject(prj, formatCheck, nodes.dockerArray, null, null, null, staticAnalysis) 23 | } 24 | 25 | ci: { 26 | String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) 27 | 28 | properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * 7')])])) 29 | stage(urlJobName) { 30 | runCI([ubuntu22:['any']], urlJobName) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.jenkins/staticlibrary.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | @Library('rocJenkins@pong') _ 3 | 4 | import com.amd.project.* 5 | import com.amd.docker.* 6 | import java.nio.file.Path 7 | 8 | def runCI = 9 | { 10 | nodeDetails, jobName, buildCommand, label -> 11 | 12 | def prj = new rocProject('hipFFT-internal', 'StaticLibrary') 13 | // customize for project 14 | prj.paths.build_command = buildCommand 15 | prj.libraryDependencies = ['rocRAND','rocFFT'] 16 | 17 | // Define test architectures, optional rocm version argument is available 18 | def nodes = new dockerNodes(nodeDetails, jobName, prj) 19 | 20 | def commonGroovy 21 | 22 | boolean formatCheck = false 23 | 24 | def compileCommand = 25 | { 26 | platform, project-> 27 | 28 | project.paths.construct_build_prefix() 29 | 30 | commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" 31 | commonGroovy.runCompileCommand(platform, project, jobName, true) 32 | } 33 | 34 | def testCommand = 35 | { 36 | platform, project-> 37 | 38 | def gfilter = "*" 39 | commonGroovy.runTestCommand(platform, project, gfilter) 40 | } 41 | 42 | def packageCommand = 43 | { 44 | platform, project-> 45 | 46 | commonGroovy.runPackageCommand(platform, project, jobName, label) 47 | } 48 | 49 | buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, testCommand, packageCommand) 50 | } 51 | 52 | def setupCI(urlJobName, jobNameList, buildCommand, runCI, label) 53 | { 54 | jobNameList = auxiliary.appendJobNameList(jobNameList) 55 | 56 | jobNameList.each 57 | { 58 | jobName, nodeDetails-> 59 | if (urlJobName == jobName) 60 | stage(label + ' ' + jobName) { 61 | runCI(nodeDetails, jobName, buildCommand, label) 62 | } 63 | } 64 | 65 | // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 66 | if(!jobNameList.keySet().contains(urlJobName)) 67 | { 68 | properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) 69 | stage(label + ' ' + urlJobName) { 70 | runCI([ubuntu16:['gfx906']], urlJobName, buildCommand, label) 71 | } 72 | } 73 | } 74 | 75 | ci: { 76 | String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) 77 | 78 | def propertyList = ["compute-rocm-dkms-no-npi":[pipelineTriggers([cron('0 1 * * 0')])]] 79 | 80 | propertyList = auxiliary.appendPropertyList(propertyList) 81 | 82 | propertyList.each 83 | { 84 | jobName, property-> 85 | if (urlJobName == jobName) 86 | properties(auxiliary.addCommonProperties(property)) 87 | } 88 | 89 | def hostJobNameList = ["compute-rocm-dkms-no-npi-hipclang":([ubuntu18:['gfx900']])] 90 | 91 | def hipClangJobNameList = ["compute-rocm-dkms-no-npi-hipclang":([ubuntu18:['gfx900']])] 92 | 93 | String hostBuildCommand = '-DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=OFF -L ../..' 94 | String hipClangBuildCommand = '-DCMAKE_CXX_COMPILER=/opt/rocm/bin/amdclang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CLIENTS_TESTS=ON -DBUILD_CLIENTS_SAMPLES=ON -DBUILD_SHARED_LIBS=OFF -L ../..' 95 | 96 | setupCI(urlJobName, hostJobNameList, hostBuildCommand, runCI, 'g++') 97 | setupCI(urlJobName, hipClangJobNameList, hipClangBuildCommand, runCI, 'hip-clang') 98 | } 99 | -------------------------------------------------------------------------------- /.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, pdf, 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 | -------------------------------------------------------------------------------- /CppCheckSuppressions.txt: -------------------------------------------------------------------------------- 1 | // has some false positives and isn't hard to run manually for periodic 2 | // dead code sweeps 3 | unusedFunction 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) 2016 - 2025 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 | 23 | This product includes software from copyright holders as shown below, and distributed under their license terms as specified. 24 | 25 | CLI11 2.2 Copyright (c) 2017-2024 University of Cincinnati, developed by Henry 26 | Schreiner under NSF AWARD 1414736. All rights reserved. 27 | 28 | Redistribution and use in source and binary forms of CLI11, with or without 29 | modification, are permitted provided that the following conditions are met: 30 | 31 | 1. Redistributions of source code must retain the above copyright notice, this 32 | list of conditions and the following disclaimer. 33 | 2. Redistributions in binary form must reproduce the above copyright notice, 34 | this list of conditions and the following disclaimer in the documentation 35 | and/or other materials provided with the distribution. 36 | 3. Neither the name of the copyright holder nor the names of its contributors 37 | may be used to endorse or promote products derived from this software without 38 | specific prior written permission. 39 | 40 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 41 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 43 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 44 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 45 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 47 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 48 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 49 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hipFFT 2 | 3 | hipFFT is an FFT marshalling library that supports 4 | [rocFFT](https://github.com/ROCmSoftwarePlatform/rocFFT) and 5 | [cuFFT](https://developer.nvidia.com/cufft) backends. 6 | 7 | hipFFT exports an interface that doesn't require the client to change, regardless of the chosen backend. 8 | It sits between your application and the backend FFT library, where it marshals inputs to the backend 9 | and marshals results back to your application. 10 | 11 | ## Documentation 12 | 13 | > [!NOTE] 14 | > The published hipFFT documentation is available at [hipFFT](https://rocm.docs.amd.com/projects/hipFFT/en/latest/index.html) in an organized, easy-to-read format, with search and a table of contents. The documentation source files reside in the hipFFT/docs folder of this repository. As with all ROCm projects, the documentation is open source. For more information, see [Contribute to ROCm documentation](https://rocm.docs.amd.com/en/latest/contribute/contributing.html). 15 | 16 | To build our documentation locally, run the following code: 17 | 18 | ```bash 19 | cd docs 20 | 21 | pip3 install -r sphinx/requirements.txt 22 | 23 | python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html 24 | ``` 25 | 26 | ## Build and install 27 | 28 | You can download pre-built packages from the 29 | [ROCm package servers](https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html). 30 | 31 | If you're using Ubuntu, you can run: `sudo apt update && sudo apt install hipfft`. 32 | 33 | ### Building from source 34 | 35 | To build hipFFT from source, follow these steps: 36 | 37 | 1. Install the library build dependencies: 38 | 39 | * On AMD platforms, you must install [rocFFT](https://github.com/ROCmSoftwarePlatform/rocFFT). 40 | * On NVIDIA platforms, you must install [cuFFT](https://developer.nvidia.com/cufft). 41 | 42 | 2. Install the client build dependencies: 43 | 44 | * The clients (samples, tests, etc) included with the hipFFT source depend on hipRAND, FFTW and GoogleTest. 45 | 46 | 3. Build hipFFT: 47 | 48 | To show all build options: 49 | 50 | ```bash 51 | mkdir build && cd build 52 | cmake -LH .. 53 | ``` 54 | 55 | Here are some CMake build examples: 56 | 57 | * AMD GPU 58 | * Case: Build a project using HIP language APIs + hipFFT with standard host compiler 59 | * Code: `cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -L ..` 60 | * Case: Build a project using HIP language APIs + hipFFT + device kernels with HIP-Clang 61 | * Code: `cmake -DCMAKE_CXX_COMPILER=amdclang++ -DCMAKE_BUILD_TYPE=Release -DBUILD_CLIENTS=ON -L ..` 62 | * NVIDIA GPU 63 | * Case: Build a project using HIP language APIs + hipFFT with standard host compiler 64 | * Code: `cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LIB=CUDA -L ..` 65 | * Case: Build a project using HIP language APIs + hipFFT + device kernels with HIP-NVCC 66 | * Code: `HIP_PLATFORM=nvidia cmake -DCMAKE_CXX_COMPILER=hipcc -DCMAKE_BUILD_TYPE=Release -DBUILD_CLIENTS=ON -L ..` 67 | 68 | ```note 69 | The `-DBUILD_CLIENTS=ON` option is only allowed with the amdclang++ or HIPCC compilers. 70 | ``` 71 | 72 | ## Code Coverage 73 | You can generate a test coverage report with the following: 74 | 75 | ```bash 76 | cmake -DCMAKE_CXX_COMPILER=amdclang++ -DBUILD_CLIENTS_SAMPLES=ON -DBUILD_CLIENTS_TESTS=ON -DBUILD_CODE_COVERAGE=ON .. 77 | make -j coverage 78 | ``` 79 | The commands above will output the coverage report to the terminal and save an html coverage report to `$PWD/coverage-report`. Note that hipFFT uses llvm for code coverage, which only works with clang compilers. 80 | 81 | ## Porting from CUDA 82 | 83 | If you have existing CUDA code and want to transition to HIP, follow these steps: 84 | 85 | 1. [HIPIFY](https://github.com/ROCm-Developer-Tools/HIPIFY) your code and fix all unsupported CUDA 86 | features and user-defined macros 87 | 2. Build with HIP-NVCC to run on an NVIDIA device 88 | 3. Build with HIP-Clang to run on an AMD device 89 | 90 | More information about porting to HIP is available in the 91 | [HIP porting guide](https://rocm.docs.amd.com/projects/HIP/en/develop/user_guide/hip_porting_guide.html). 92 | 93 | ## Support 94 | 95 | You can report bugs and feature requests through the GitHub 96 | [issue tracker](https://github.com/ROCm/hipFFT/issues). 97 | 98 | ## Contribute 99 | 100 | If you want to contribute to hipFFT, you must follow our [contribution guidelines](https://github.com/ROCm/hipFFT/blob/develop/.github/CONTRIBUTING.md). 101 | -------------------------------------------------------------------------------- /clients/CMakeLists.txt: -------------------------------------------------------------------------------- 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 | # CMake version according to latest ROCm platform requirements 24 | cmake_minimum_required( VERSION 3.16 ) 25 | 26 | # We use C++17 features, this will add compile option: -std=c++17 27 | set( CMAKE_CXX_STANDARD 17 ) 28 | set(CMAKE_CXX_EXTENSIONS OFF) 29 | 30 | # Consider removing this in the future 31 | # This should appear before the project command, because it does not use FORCE 32 | if( WIN32 ) 33 | set( CMAKE_INSTALL_PREFIX 34 | "${PROJECT_BINARY_DIR}/package" 35 | CACHE 36 | PATH 37 | "Install path prefix, prepended onto install directories" ) 38 | else( ) 39 | set( CMAKE_INSTALL_PREFIX 40 | "/opt/rocm" 41 | CACHE 42 | PATH 43 | "Install path prefix, prepended onto install directories" ) 44 | endif( ) 45 | 46 | # This has to be initialized before the project() command appears 47 | # Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D. MSVC_IDE does 48 | # not use CMAKE_BUILD_TYPE 49 | if( NOT DEFINED CMAKE_CONFIGURATION_TYPES AND NOT DEFINED CMAKE_BUILD_TYPE ) 50 | set( CMAKE_BUILD_TYPE Release CACHE STRING 51 | "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." ) 52 | endif() 53 | 54 | set( HIPFFT_CLIENTS_BUILD_SCOPE ON ) 55 | 56 | # This project may compile dependencies for clients 57 | project( hipfft-clients LANGUAGES CXX ) 58 | 59 | list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ) 60 | 61 | include( build-options ) 62 | 63 | if(NOT (CMAKE_CXX_COMPILER MATCHES ".*hipcc$" OR 64 | CMAKE_CXX_COMPILER MATCHES ".*clang\\+\\+" OR 65 | CMAKE_CXX_COMPILER MATCHES ".*nvcc" OR 66 | CMAKE_CXX_COMPILER MATCHES ".*nvc\\+\\+" 67 | ) 68 | ) 69 | if(BUILD_CLIENTS) 70 | message( FATAL_ERROR "Using BUILD_CLIENTS=ON requires a compiler capable of building device code (hipcc, clang, nvcc, nvc++)." ) 71 | endif() 72 | endif() 73 | 74 | 75 | # This option only works for make/nmake and the ninja generators, but no reason it shouldn't be on 76 | # all the time 77 | # This tells cmake to create a compile_commands.json file that can be used with clang tooling or vim 78 | set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) 79 | 80 | # if hipfft is not a target, then we know clients are built separately from the library and we must 81 | # search for the hipfft package 82 | if( NOT TARGET hipfft ) 83 | find_package( hipfft REQUIRED CONFIG PATHS ) 84 | endif( ) 85 | 86 | if( BUILD_CLIENTS_SAMPLES ) 87 | add_subdirectory( samples ) 88 | endif( ) 89 | 90 | if( BUILD_CLIENTS_TESTS ) 91 | find_package( GTest 1.11.0 ) 92 | include( ExternalProject ) 93 | if( NOT GTEST_FOUND ) 94 | set( GTEST_INCLUDE_DIRS 95 | ${CMAKE_CURRENT_BINARY_DIR}/src/gtest/googletest/include 96 | ) 97 | set( GTEST_LIBRARIES 98 | ${CMAKE_CURRENT_BINARY_DIR}/src/gtest-build/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} 99 | ${CMAKE_CURRENT_BINARY_DIR}/src/gtest-build/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} 100 | ) 101 | 102 | ExternalProject_Add( gtest 103 | URL https://github.com/google/googletest/archive/release-1.11.0.tar.gz 104 | URL_HASH SHA256=b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5 105 | PREFIX ${CMAKE_CURRENT_BINARY_DIR} 106 | CMAKE_ARGS -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} -DBUILD_SHARED_LIBS=OFF 107 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON 108 | INSTALL_COMMAND "" 109 | BUILD_BYPRODUCTS ${GTEST_LIBRARIES} 110 | ) 111 | ExternalProject_Get_Property( gtest source_dir binary_dir ) 112 | endif() 113 | add_subdirectory( tests ) 114 | endif( ) 115 | 116 | if( BUILD_CLIENTS_BENCH ) 117 | add_subdirectory( bench ) 118 | endif( ) 119 | -------------------------------------------------------------------------------- /clients/bench/CMakeLists.txt: -------------------------------------------------------------------------------- 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 | CMAKE_MINIMUM_REQUIRED(VERSION 3.16) 24 | 25 | project( hipfft-clients-bench LANGUAGES CXX ) 26 | 27 | set( hipfft_bench_source bench.cpp ../../shared/array_validator.cpp ) 28 | set( hipfft_bench_includes bench.h ../../shared/array_validator.h ) 29 | 30 | add_executable( hipfft-bench ${hipfft_bench_source} ${hipfft_bench_includes} ) 31 | 32 | target_compile_options( hipfft-bench PRIVATE ${WARNING_FLAGS} ) 33 | 34 | set_target_properties( hipfft-bench PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) 35 | 36 | target_include_directories( hipfft-bench 37 | PRIVATE 38 | $ 39 | $ 40 | $ 41 | $ 42 | ) 43 | 44 | if((NOT CMAKE_CXX_COMPILER MATCHES ".*/hipcc$") OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 45 | if( NOT BUILD_WITH_LIB STREQUAL "CUDA" ) 46 | if( WIN32 ) 47 | find_package( HIP CONFIG REQUIRED ) 48 | else() 49 | find_package( HIP MODULE REQUIRED ) 50 | endif() 51 | 52 | target_link_libraries( hipfft-bench PRIVATE hip::host hip::device ) 53 | else() 54 | target_compile_definitions( hipfft-bench PRIVATE __HIP_PLATFORM_NVIDIA__) 55 | target_include_directories( hipfft-bench PRIVATE ${HIP_INCLUDE_DIRS}) 56 | endif() 57 | endif() 58 | 59 | if ( BUILD_WITH_LIB STREQUAL "CUDA" ) 60 | if( CMAKE_CXX_COMPILER MATCHES ".*nvc\\+\\+$" ) 61 | target_compile_options( hipfft-bench PRIVATE -cuda -Xptxas=-w) 62 | target_link_options( hipfft-bench PRIVATE -cuda) 63 | else() 64 | target_compile_options( hipfft-bench PRIVATE -arch sm_53 -gencode=arch=compute_53,code=sm_53 -Xptxas=-w) 65 | endif() 66 | target_link_libraries( hipfft-bench PRIVATE ${CUDA_LIBRARIES} ) 67 | else() 68 | if( USE_HIPRAND AND NOT hiprand_FOUND ) 69 | find_package( hiprand REQUIRED ) 70 | endif() 71 | if( USE_HIPRAND ) 72 | target_link_libraries( hipfft-bench PRIVATE hip::hiprand ) 73 | endif() 74 | endif() 75 | 76 | target_link_libraries( hipfft-bench PRIVATE hip::hipfft ) 77 | 78 | set_target_properties( hipfft-bench PROPERTIES CXX_EXTENSIONS NO ) 79 | set_target_properties( hipfft-bench PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging" ) 80 | 81 | if( HIPFFT_BUILD_SCOPE ) 82 | set( BENCH_OUT_DIR "/../staging" ) 83 | elseif( HIPFFT_CLIENTS_BUILD_SCOPE ) 84 | set( BENCH_OUT_DIR "/../bin" ) 85 | else() 86 | set( BENCH_OUT_DIR "/bin") 87 | endif() 88 | string( CONCAT BENCH_OUT_DIR "${PROJECT_BINARY_DIR}" ${BENCH_OUT_DIR} ) 89 | 90 | set_target_properties( hipfft-bench 91 | PROPERTIES 92 | RUNTIME_OUTPUT_DIRECTORY 93 | ${BENCH_OUT_DIR} ) 94 | 95 | rocm_install(TARGETS hipfft-bench COMPONENT benchmarks) 96 | -------------------------------------------------------------------------------- /clients/bench/bench.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 - 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef HIPFFT_BENCH_H 22 | #define HIPFFT_BENCH_H 23 | 24 | #include "../hipfft_params.h" 25 | #include "hipfft/hipfft.h" 26 | 27 | #include 28 | 29 | // This is used to either wrap a HIP function call, or to explicitly check a variable 30 | // for an error condition. If an error occurs, we throw. 31 | // Note: std::runtime_error does not take unicode strings as input, so only strings 32 | // supported 33 | inline void 34 | hip_V_Throw(hipError_t res, const std::string& msg, size_t lineno, const std::string& fileName) 35 | { 36 | if(res != hipSuccess) 37 | { 38 | std::stringstream tmp; 39 | tmp << "HIP_V_THROWERROR< "; 40 | tmp << res; 41 | tmp << " > ("; 42 | tmp << fileName; 43 | tmp << " Line: "; 44 | tmp << lineno; 45 | tmp << "): "; 46 | tmp << msg; 47 | std::string errorm(tmp.str()); 48 | std::cout << errorm << std::endl; 49 | throw std::runtime_error(errorm); 50 | } 51 | } 52 | 53 | inline void lib_V_Throw(hipfftResult res, 54 | const std::string& msg, 55 | size_t lineno, 56 | const std::string& fileName) 57 | { 58 | if(res != HIPFFT_SUCCESS) 59 | { 60 | std::stringstream tmp; 61 | tmp << "LIB_V_THROWERROR< "; 62 | tmp << res; 63 | tmp << " > ("; 64 | tmp << fileName; 65 | tmp << " Line: "; 66 | tmp << lineno; 67 | tmp << "): "; 68 | tmp << msg; 69 | std::string errorm(tmp.str()); 70 | std::cout << errorm << std::endl; 71 | throw std::runtime_error(errorm); 72 | } 73 | } 74 | 75 | #define HIP_V_THROW(_status, _message) hip_V_Throw(_status, _message, __LINE__, __FILE__) 76 | #define LIB_V_THROW(_status, _message) lib_V_Throw(_status, _message, __LINE__, __FILE__) 77 | 78 | #endif // HIPFFT_BENCH_H 79 | -------------------------------------------------------------------------------- /clients/cmake/FindFFTW.cmake: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2016 - 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 | #if( FFTW_FIND_VERSION VERSION_LESS "3" ) 24 | # message( FFTW_FIND_VERION is ${FFTW_FIND_VERSION}) 25 | # message( FATAL_ERROR "FindFFTW can not configure versions less than FFTW 3.0.0" ) 26 | #endif( ) 27 | 28 | find_path(FFTW_INCLUDE_DIRS 29 | NAMES fftw3.h 30 | HINTS 31 | ${FFTW_ROOT}/include 32 | $ENV{FFTW_ROOT}/include 33 | PATHS 34 | /usr/include 35 | /usr/local/include 36 | ) 37 | mark_as_advanced( FFTW_INCLUDE_DIRS ) 38 | 39 | # message( STATUS "FFTW_FIND_COMPONENTS: ${FFTW_FIND_COMPONENTS}" ) 40 | # message( STATUS "FFTW_FIND_REQUIRED_FLOAT: ${FFTW_FIND_REQUIRED_FLOAT}" ) 41 | # message( STATUS "FFTW_FIND_REQUIRED_DOUBLE: ${FFTW_FIND_REQUIRED_DOUBLE}" ) 42 | 43 | set( FFTW_LIBRARIES "" ) 44 | if( FFTW_FIND_REQUIRED_FLOAT OR FFTW_FIND_REQUIRED_SINGLE ) 45 | find_library( FFTW_LIBRARIES_SINGLE 46 | NAMES fftw3f fftw3f-3 fftw3 fftw3-3 47 | HINTS 48 | ${FFTW_ROOT}/lib 49 | $ENV{FFTW_ROOT}/lib 50 | PATHS 51 | /usr/lib 52 | /usr/local/lib 53 | PATH_SUFFIXES 54 | x86_64-linux-gnu 55 | DOC "FFTW dynamic library single" 56 | ) 57 | mark_as_advanced( FFTW_LIBRARIES_SINGLE ) 58 | list( APPEND FFTW_LIBRARIES ${FFTW_LIBRARIES_SINGLE} ) 59 | 60 | # Look for omp (preferred) or thread libraries. These are not a 61 | # hard requirement, but are nice to have to make FFTW run faster. 62 | find_library( FFTWF_OMP_LIBRARY fftw3f_omp ) 63 | find_library( FFTWF_THREADS_LIBRARY fftw3f_threads ) 64 | if( FFTWF_OMP_LIBRARY ) 65 | list( APPEND FFTW_LIBRARIES ${FFTWF_OMP_LIBRARY} ) 66 | set( FFTW_MULTITHREAD TRUE ) 67 | elseif( FFTWF_THREADS_LIBRARY ) 68 | list( APPEND FFTW_LIBRARIES ${FFTWF_THREADS_LIBRARY} ) 69 | set( FFTW_MULTITHREAD TRUE ) 70 | endif() 71 | endif( ) 72 | 73 | if( FFTW_FIND_REQUIRED_DOUBLE ) 74 | find_library( FFTW_LIBRARIES_DOUBLE 75 | NAMES fftw3 76 | HINTS 77 | ${FFTW_ROOT}/lib 78 | $ENV{FFTW_ROOT}/lib 79 | PATHS 80 | /usr/lib 81 | /usr/local/lib 82 | PATH_SUFFIXES 83 | x86_64-linux-gnu 84 | DOC "FFTW dynamic library double" 85 | ) 86 | mark_as_advanced( FFTW_LIBRARIES_DOUBLE ) 87 | list( APPEND FFTW_LIBRARIES ${FFTW_LIBRARIES_DOUBLE} ) 88 | 89 | # Look for omp (preferred) or thread libraries. These are not a 90 | # hard requirement, but are nice to have to make FFTW run faster. 91 | find_library( FFTW_OMP_LIBRARY fftw3_omp ) 92 | find_library( FFTW_THREADS_LIBRARY fftw3_threads ) 93 | if( FFTW_OMP_LIBRARY ) 94 | list( APPEND FFTW_LIBRARIES ${FFTW_OMP_LIBRARY} ) 95 | set( FFTW_MULTITHREAD TRUE ) 96 | elseif( FFTW_THREADS_LIBRARY ) 97 | list( APPEND FFTW_LIBRARIES ${FFTW_THREADS_LIBRARY} ) 98 | set( FFTW_MULTITHREAD TRUE ) 99 | endif() 100 | endif( ) 101 | 102 | include( FindPackageHandleStandardArgs ) 103 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( FFTW 104 | REQUIRED_VARS FFTW_INCLUDE_DIRS FFTW_LIBRARIES ) 105 | 106 | # assume the threads feature is always enabled on Windows, since it's 107 | # not a separate library there 108 | if( FFTW_FOUND AND WIN32 ) 109 | set( FFTW_MULTITHREAD TRUE ) 110 | endif() 111 | 112 | if( NOT FFTW_FOUND ) 113 | message( STATUS "FindFFTW could not find all of the following fftw libraries" ) 114 | message( STATUS "${FFTW_FIND_COMPONENTS}" ) 115 | else( ) 116 | message(STATUS "FindFFTW configured variables:" ) 117 | message(STATUS "FFTW_INCLUDE_DIRS: ${FFTW_INCLUDE_DIRS}" ) 118 | message(STATUS "FFTW_LIBRARIES: ${FFTW_LIBRARIES}" ) 119 | endif() 120 | -------------------------------------------------------------------------------- /clients/cmake/build-options.cmake: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2016 - 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 | # This file is intended to be used in two ways; independently in a stand alone PROJECT 24 | # and as part of a superbuild. If the file is included in a stand alone project, the 25 | # variables are not expected to be preset, and this will produce options() in the GUI 26 | # for the user to examine. If this file is included in a superbuild, the options will be 27 | # presented in the superbuild GUI, but then passed into the ExternalProject as -D 28 | # parameters, which would already define them. 29 | 30 | if( NOT BUILD_CLIENTS_TESTS ) 31 | option( BUILD_CLIENTS_TESTS "Build hipFFT unit tests" OFF ) 32 | endif( ) 33 | 34 | if( NOT BUILD_CLIENTS_SAMPLES ) 35 | option( BUILD_CLIENTS_SAMPLES "Build hipFFT samples" OFF ) 36 | endif( ) 37 | 38 | -------------------------------------------------------------------------------- /clients/samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2016 - 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 | CMAKE_MINIMUM_REQUIRED( VERSION 3.16 ) 24 | 25 | project( hipfft-clients-samples-rocfft LANGUAGES CXX ) 26 | 27 | # We use C++17 features, this will add compile option: -std=c++17 28 | set( CMAKE_CXX_STANDARD 17 ) 29 | 30 | if( NOT TARGET hipfft ) 31 | find_package( hipfft REQUIRED CONFIG PATHS ) 32 | endif( ) 33 | 34 | set( sample_list 35 | hipfft_1d_z2z 36 | hipfft_1d_d2z 37 | hipfft_2d_z2z 38 | hipfft_2d_d2z 39 | hipfft_3d_z2z 40 | hipfft_3d_d2z 41 | hipfft_planmany_2d_z2z 42 | hipfft_planmany_2d_r2c 43 | hipfft_multigpu_2d_z2z 44 | hipfft_setworkarea 45 | ) 46 | 47 | # callback sample has its own HIP code, so it needs to be built with hipcc or clang++ 48 | if( CMAKE_CXX_COMPILER MATCHES ".*/hipcc$" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) 49 | # on cuFFT backend, use of callbacks requires linking against the 50 | # static cuFFT library 51 | if( NOT (BUILD_WITH_LIB STREQUAL "CUDA") OR NOT BUILD_SHARED_LIBS ) 52 | list( APPEND sample_list hipfft_callback ) 53 | else() 54 | message( STATUS "hipfft_callback sample disabled on non-static CUDA build" ) 55 | endif() 56 | else() 57 | message( STATUS "hipfft_callback sample disabled, requires hipcc or Clang++ build" ) 58 | endif() 59 | 60 | foreach( sample ${sample_list} ) 61 | 62 | add_executable( ${sample} ${sample}.cpp ) 63 | 64 | set_target_properties( ${sample} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) 65 | 66 | target_link_libraries( ${sample} PRIVATE hip::hipfft ) 67 | 68 | target_compile_options( ${sample} PRIVATE ${WARNING_FLAGS} ) 69 | 70 | if( NOT CMAKE_CXX_COMPILER MATCHES ".*/hipcc$" ) 71 | if( WIN32 ) 72 | find_package( HIP CONFIG REQUIRED ) 73 | else() 74 | find_package( HIP MODULE REQUIRED ) 75 | endif() 76 | if( NOT BUILD_WITH_LIB STREQUAL "CUDA" ) 77 | target_link_libraries( ${sample} PRIVATE hip::host hip::device ) 78 | else() 79 | target_compile_definitions( ${sample} PRIVATE __HIP_PLATFORM_NVIDIA__) 80 | target_include_directories( ${sample} PRIVATE ${HIP_INCLUDE_DIRS}) 81 | endif() 82 | endif() 83 | 84 | if ( BUILD_WITH_LIB STREQUAL "CUDA" ) 85 | if( CMAKE_CXX_COMPILER MATCHES ".*nvc\\+\\+$" ) 86 | target_compile_options( ${sample} PRIVATE -cuda -Xptxas=-w) 87 | target_link_options( ${sample} PRIVATE -cuda) 88 | else() 89 | target_compile_options( ${sample} PRIVATE -arch sm_53 -gencode=arch=compute_53,code=sm_53 -Xptxas=-w) 90 | endif() 91 | target_link_libraries( ${sample} PRIVATE ${CUDA_LIBRARIES} ) 92 | else() 93 | if( USE_HIPRAND AND NOT hiprand_FOUND ) 94 | find_package( hiprand REQUIRED ) 95 | endif() 96 | if ( USE_HIPRAND ) 97 | target_link_libraries( ${sample} PRIVATE hip::hiprand ) 98 | endif() 99 | endif() 100 | 101 | target_include_directories( ${sample} 102 | PRIVATE 103 | $ 104 | $ 105 | $ 106 | ${HIP_ROOT_DIR} 107 | ) 108 | 109 | set_target_properties( ${sample} PROPERTIES CXX_EXTENSIONS NO ) 110 | 111 | if( HIPFFT_BUILD_SCOPE ) 112 | set( SAMPLES_OUT_DIR "/../staging" ) 113 | elseif( HIPFFT_CLIENTS_BUILD_SCOPE ) 114 | set( SAMPLES_OUT_DIR "/../bin" ) 115 | else() 116 | set( SAMPLES_OUT_DIR "/bin" ) 117 | endif() 118 | string( CONCAT SAMPLES_OUT_DIR "${PROJECT_BINARY_DIR}" ${SAMPLES_OUT_DIR} ) 119 | 120 | set_target_properties( ${sample} 121 | PROPERTIES 122 | RUNTIME_OUTPUT_DIRECTORY 123 | ${SAMPLES_OUT_DIR} ) 124 | 125 | endforeach() 126 | 127 | # cuFFT callback code must be compiled with -dc to enable relocatable 128 | # device code 129 | if( BUILD_WITH_LIB STREQUAL "CUDA" AND hipfft_callback IN_LIST sample_list ) 130 | target_compile_options( hipfft_callback PRIVATE -dc ) 131 | endif() 132 | -------------------------------------------------------------------------------- /clients/samples/hipfft_1d_d2z.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 - 2022 Advanced Micro Devices, Inc. All rights 2 | // 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 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | DISABLE_WARNING_PUSH 29 | DISABLE_WARNING_DEPRECATED_DECLARATIONS 30 | DISABLE_WARNING_RETURN_TYPE 31 | #include 32 | DISABLE_WARNING_POP 33 | 34 | #include "../hipfft_params.h" 35 | 36 | int main() 37 | { 38 | std::cout << "hipfft 1D double-precision real-to-complex transform\n"; 39 | 40 | const size_t Nx = 8; 41 | 42 | const size_t Ncomplex = Nx / 2 + 1; 43 | 44 | std::vector rdata(Nx); 45 | size_t real_bytes = sizeof(decltype(rdata)::value_type) * rdata.size(); 46 | std::vector> cdata(Ncomplex); 47 | size_t complex_bytes = sizeof(std::complex) * cdata.size(); 48 | 49 | // Create HIP device object 50 | double* x; 51 | hipError_t hip_rt; 52 | hip_rt = hipMalloc(&x, complex_bytes); 53 | if(hip_rt != hipSuccess) 54 | throw std::runtime_error("hipMalloc failed"); 55 | 56 | // Inititalize the data 57 | for(size_t i = 0; i < Nx; i++) 58 | { 59 | rdata[i] = i; 60 | } 61 | std::cout << "input:\n"; 62 | for(size_t i = 0; i < rdata.size(); i++) 63 | { 64 | std::cout << rdata[i] << " "; 65 | } 66 | std::cout << std::endl; 67 | hip_rt = hipMemcpy(x, rdata.data(), real_bytes, hipMemcpyHostToDevice); 68 | if(hip_rt != hipSuccess) 69 | throw std::runtime_error("hipMemcpy failed"); 70 | 71 | // Create the plan 72 | hipfftHandle plan = hipfft_params::INVALID_PLAN_HANDLE; 73 | hipfftResult hipfft_rt = hipfftCreate(&plan); 74 | if(hipfft_rt != HIPFFT_SUCCESS) 75 | throw std::runtime_error("failed to create plan"); 76 | hipfft_rt = hipfftPlan1d(&plan, // plan handle 77 | Nx, // transform length 78 | HIPFFT_D2Z, // transform type (HIPFFT_R2C for single-precision) 79 | 1); // number of transforms (deprecated) 80 | if(hipfft_rt != HIPFFT_SUCCESS) 81 | throw std::runtime_error("hipfftPlan1d failed"); 82 | 83 | // Execute plan: 84 | // hipfftExecD2Z: double precision, hipfftExecR2C: for single-precision 85 | // Direction is implied by real-to-complex direction 86 | hipfft_rt = hipfftExecD2Z(plan, x, (hipfftDoubleComplex*)x); 87 | if(hipfft_rt != HIPFFT_SUCCESS) 88 | throw std::runtime_error("hipfftExecD2Z failed"); 89 | 90 | std::cout << "output:\n"; 91 | hip_rt = hipMemcpy(cdata.data(), x, complex_bytes, hipMemcpyDeviceToHost); 92 | if(hip_rt != hipSuccess) 93 | throw std::runtime_error("hipMemcpy failed"); 94 | for(size_t i = 0; i < cdata.size(); i++) 95 | { 96 | std::cout << cdata[i] << " "; 97 | } 98 | std::cout << std::endl; 99 | 100 | hipfftDestroy(plan); 101 | 102 | hip_rt = hipFree(x); 103 | if(hip_rt != hipSuccess) 104 | throw std::runtime_error("hipFree failed"); 105 | 106 | return 0; 107 | } 108 | -------------------------------------------------------------------------------- /clients/samples/hipfft_1d_z2z.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 - 2022 Advanced Micro Devices, Inc. All rights 2 | // 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 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | DISABLE_WARNING_PUSH 29 | DISABLE_WARNING_DEPRECATED_DECLARATIONS 30 | DISABLE_WARNING_RETURN_TYPE 31 | #include 32 | DISABLE_WARNING_POP 33 | 34 | #include "../hipfft_params.h" 35 | 36 | int main() 37 | { 38 | std::cout << "hipfft 1D double-precision complex-to-complex transform\n"; 39 | 40 | const int Nx = 8; 41 | int direction = HIPFFT_FORWARD; // forward=-1, backward=1 42 | 43 | std::vector> cdata(Nx); 44 | size_t complex_bytes = sizeof(decltype(cdata)::value_type) * cdata.size(); 45 | 46 | // Create HIP device object and copy data to device 47 | // Use hipfftComplex for single-precision 48 | hipError_t hip_rt; 49 | hipfftDoubleComplex* x; 50 | hip_rt = hipMalloc(&x, complex_bytes); 51 | if(hip_rt != hipSuccess) 52 | throw std::runtime_error("hipMalloc failed"); 53 | 54 | // Inititalize the data 55 | for(size_t i = 0; i < Nx; i++) 56 | { 57 | cdata[i] = i; 58 | } 59 | std::cout << "input:\n"; 60 | for(size_t i = 0; i < cdata.size(); i++) 61 | { 62 | std::cout << cdata[i] << " "; 63 | } 64 | std::cout << std::endl; 65 | hip_rt = hipMemcpy(x, cdata.data(), complex_bytes, hipMemcpyHostToDevice); 66 | if(hip_rt != hipSuccess) 67 | throw std::runtime_error("hipMemcpy failed"); 68 | 69 | // Create the plan 70 | hipfftHandle plan = hipfft_params::INVALID_PLAN_HANDLE; 71 | hipfftResult hipfft_rt = hipfftCreate(&plan); 72 | if(hipfft_rt != HIPFFT_SUCCESS) 73 | throw std::runtime_error("failed to create plan"); 74 | 75 | hipfft_rt = hipfftPlan1d(&plan, // plan handle 76 | Nx, // transform length 77 | HIPFFT_Z2Z, // transform type (HIPFFT_C2C for single-precision) 78 | 1); // number of transforms 79 | if(hipfft_rt != HIPFFT_SUCCESS) 80 | throw std::runtime_error("hipfftPlan1d failed"); 81 | 82 | // Execute plan: 83 | // hipfftExecZ2Z: double precision, hipfftExecC2C: for single-precision 84 | hipfft_rt = hipfftExecZ2Z(plan, x, x, direction); 85 | if(hipfft_rt != HIPFFT_SUCCESS) 86 | throw std::runtime_error("hipfftExecZ2Z failed"); 87 | 88 | std::cout << "output:\n"; 89 | hip_rt = hipMemcpy(cdata.data(), x, complex_bytes, hipMemcpyDeviceToHost); 90 | if(hip_rt != hipSuccess) 91 | throw std::runtime_error("hipMemcpy failed"); 92 | for(size_t i = 0; i < cdata.size(); i++) 93 | { 94 | std::cout << cdata[i] << " "; 95 | } 96 | std::cout << std::endl; 97 | 98 | hipfftDestroy(plan); 99 | 100 | hip_rt = hipFree(x); 101 | if(hip_rt != hipSuccess) 102 | throw std::runtime_error("hipFree failed"); 103 | 104 | return 0; 105 | } 106 | -------------------------------------------------------------------------------- /clients/samples/hipfft_2d_d2z.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 - 2022 Advanced Micro Devices, Inc. All rights 2 | // 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 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | DISABLE_WARNING_PUSH 29 | DISABLE_WARNING_DEPRECATED_DECLARATIONS 30 | DISABLE_WARNING_RETURN_TYPE 31 | #include 32 | DISABLE_WARNING_POP 33 | 34 | #include "../hipfft_params.h" 35 | 36 | int main() 37 | { 38 | std::cout << "hipfft 2D double-precision real-to-complex transform\n"; 39 | 40 | const size_t Nx = 4; 41 | const size_t Ny = 5; 42 | 43 | std::cout << "Nx: " << Nx << "\tNy: " << Ny << std::endl; 44 | 45 | const size_t Nycomplex = Ny / 2 + 1; 46 | const size_t rstride = Nycomplex * 2; // Ny for out-of-place 47 | 48 | std::cout << "Input:\n"; 49 | std::vector rdata(Nx * rstride); 50 | for(size_t i = 0; i < Nx * rstride; i++) 51 | { 52 | rdata[i] = i; 53 | } 54 | for(size_t i = 0; i < Nx; i++) 55 | { 56 | for(size_t j = 0; j < Ny; j++) 57 | { 58 | auto pos = i * rstride + j; 59 | std::cout << rdata[pos] << " "; 60 | } 61 | std::cout << "\n"; 62 | } 63 | std::cout << std::endl; 64 | 65 | double* x; 66 | hipError_t hip_rt; 67 | hip_rt = hipMalloc(&x, rdata.size() * sizeof(decltype(rdata)::value_type)); 68 | if(hip_rt != hipSuccess) 69 | throw std::runtime_error("hipMalloc failed"); 70 | 71 | hip_rt = hipMemcpy( 72 | x, rdata.data(), rdata.size() * sizeof(decltype(rdata)::value_type), hipMemcpyHostToDevice); 73 | if(hip_rt != hipSuccess) 74 | throw std::runtime_error("hipMemcpy failed"); 75 | 76 | // Create plan: 77 | hipfftHandle plan = hipfft_params::INVALID_PLAN_HANDLE; 78 | hipfftResult hipfft_rt = hipfftCreate(&plan); 79 | if(hipfft_rt != HIPFFT_SUCCESS) 80 | throw std::runtime_error("failed to create plan"); 81 | hipfft_rt = hipfftPlan2d(&plan, // plan handle 82 | Nx, // transform length 83 | Ny, // transform length 84 | HIPFFT_D2Z); // transform type (HIPFFT_R2C for single-precision) 85 | if(hipfft_rt != HIPFFT_SUCCESS) 86 | throw std::runtime_error("hipfftPlandd failed"); 87 | 88 | // Execute plan: 89 | // hipfftExecD2Z: double precision. hipfftExecR2C: single-precision 90 | hipfft_rt = hipfftExecD2Z(plan, x, (hipfftDoubleComplex*)x); 91 | if(hipfft_rt != HIPFFT_SUCCESS) 92 | throw std::runtime_error("hipfftExecD2Z failed"); 93 | 94 | // Copy the output data to the host: 95 | std::vector> cdata(Nx * Nycomplex); 96 | hip_rt = hipMemcpy( 97 | cdata.data(), x, cdata.size() * sizeof(decltype(cdata)::value_type), hipMemcpyDeviceToHost); 98 | if(hip_rt != hipSuccess) 99 | throw std::runtime_error("hipMemcpy failed"); 100 | 101 | std::cout << "Output:\n"; 102 | for(size_t i = 0; i < Nx; i++) 103 | { 104 | for(size_t j = 0; j < Nycomplex; j++) 105 | { 106 | auto pos = i * Nycomplex + j; 107 | std::cout << cdata[pos] << " "; 108 | } 109 | std::cout << "\n"; 110 | } 111 | std::cout << std::endl; 112 | 113 | hipfftDestroy(plan); 114 | 115 | hip_rt = hipFree(x); 116 | if(hip_rt != hipSuccess) 117 | throw std::runtime_error("hipFree failed"); 118 | 119 | return 0; 120 | } 121 | -------------------------------------------------------------------------------- /clients/samples/hipfft_2d_z2z.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 - 2022 Advanced Micro Devices, Inc. All rights 2 | // 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 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | DISABLE_WARNING_PUSH 29 | DISABLE_WARNING_DEPRECATED_DECLARATIONS 30 | DISABLE_WARNING_RETURN_TYPE 31 | #include 32 | DISABLE_WARNING_POP 33 | 34 | #include "../hipfft_params.h" 35 | 36 | int main() 37 | { 38 | std::cout << "hipfft 2D double-precision complex-to-complex transform\n"; 39 | 40 | const int Nx = 4; 41 | const int Ny = 4; 42 | int direction = HIPFFT_FORWARD; // forward=-1, backward=1 43 | 44 | std::vector> cdata(Nx * Ny); 45 | size_t complex_bytes = sizeof(decltype(cdata)::value_type) * cdata.size(); 46 | 47 | // Create HIP device object and copy data to device: 48 | // hipfftComplex for single-precision 49 | hipError_t hip_rt; 50 | hipfftDoubleComplex* x; 51 | hip_rt = hipMalloc(&x, complex_bytes); 52 | if(hip_rt != hipSuccess) 53 | throw std::runtime_error("hipMalloc failed"); 54 | 55 | // Inititalize the data 56 | for(size_t i = 0; i < Nx * Ny; i++) 57 | { 58 | cdata[i] = i; 59 | } 60 | std::cout << "input:\n"; 61 | for(int i = 0; i < Nx; i++) 62 | { 63 | for(int j = 0; j < Ny; j++) 64 | { 65 | int pos = i * Ny + j; 66 | std::cout << cdata[pos] << " "; 67 | } 68 | std::cout << "\n"; 69 | } 70 | std::cout << std::endl; 71 | hip_rt = hipMemcpy(x, cdata.data(), complex_bytes, hipMemcpyHostToDevice); 72 | if(hip_rt != hipSuccess) 73 | throw std::runtime_error("hipMemcpy failed"); 74 | 75 | // Create plan 76 | hipfftHandle plan = hipfft_params::INVALID_PLAN_HANDLE; 77 | hipfftResult hipfft_rt = hipfftCreate(&plan); 78 | if(hipfft_rt != HIPFFT_SUCCESS) 79 | throw std::runtime_error("failed to create plan"); 80 | 81 | hipfft_rt = hipfftPlan2d(&plan, // plan handle 82 | Nx, // transform length 83 | Ny, // transform length 84 | HIPFFT_Z2Z); // transform type (HIPFFT_C2C for single-precision) 85 | if(hipfft_rt != HIPFFT_SUCCESS) 86 | throw std::runtime_error("hipfftPlandd failed"); 87 | 88 | // Execute plan 89 | // hipfftExecZ2Z: double precision, hipfftExecC2C: for single-precision 90 | hipfft_rt = hipfftExecZ2Z(plan, x, x, direction); 91 | if(hipfft_rt != HIPFFT_SUCCESS) 92 | throw std::runtime_error("hipfftExecZ2Z failed"); 93 | 94 | std::cout << "output:\n"; 95 | hip_rt = hipMemcpy(cdata.data(), x, complex_bytes, hipMemcpyDeviceToHost); 96 | if(hip_rt != hipSuccess) 97 | throw std::runtime_error("hipMemcpy failed"); 98 | for(size_t i = 0; i < Nx; i++) 99 | { 100 | for(size_t j = 0; j < Ny; j++) 101 | { 102 | auto pos = i * Ny + j; 103 | std::cout << cdata[pos] << " "; 104 | } 105 | std::cout << "\n"; 106 | } 107 | std::cout << std::endl; 108 | 109 | hipfftDestroy(plan); 110 | 111 | hip_rt = hipFree(x); 112 | if(hip_rt != hipSuccess) 113 | throw std::runtime_error("hipFree failed"); 114 | 115 | return 0; 116 | } 117 | -------------------------------------------------------------------------------- /clients/samples/hipfft_3d_d2z.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 - 2022 Advanced Micro Devices, Inc. All rights 2 | // 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 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | DISABLE_WARNING_PUSH 29 | DISABLE_WARNING_DEPRECATED_DECLARATIONS 30 | DISABLE_WARNING_RETURN_TYPE 31 | #include 32 | DISABLE_WARNING_POP 33 | 34 | #include "../hipfft_params.h" 35 | 36 | int main() 37 | { 38 | std::cout << "hipfft 3D double-precision real-to-complex transform\n"; 39 | 40 | const size_t Nx = 4; 41 | const size_t Ny = 5; 42 | const size_t Nz = 6; 43 | 44 | std::cout << "Nx: " << Nx << "\tNy " << Ny << "\tNz " << Nz << std::endl; 45 | 46 | const size_t Nzcomplex = Nz / 2 + 1; 47 | const size_t rstride = Nzcomplex * 2; // Nz for out-of-place 48 | 49 | const size_t real_bytes = sizeof(double) * Nx * Ny * rstride; 50 | const size_t complex_bytes = 2 * sizeof(double) * Nx * Ny * Nzcomplex; 51 | 52 | double* x; 53 | hipError_t hip_rt; 54 | hip_rt = hipMalloc(&x, real_bytes); 55 | if(hip_rt != hipSuccess) 56 | throw std::runtime_error("hipMalloc failed"); 57 | 58 | // Inititalize the data 59 | std::vector rdata(Nx * Ny * rstride); 60 | for(size_t i = 0; i < Nx * Ny * rstride; i++) 61 | { 62 | rdata[i] = i; 63 | } 64 | std::cout << "input:\n"; 65 | for(size_t i = 0; i < Nx; i++) 66 | { 67 | for(size_t j = 0; j < Ny; j++) 68 | { 69 | for(size_t k = 0; k < rstride; k++) 70 | { 71 | auto pos = (i * Ny + j) * rstride + k; 72 | std::cout << rdata[pos] << " "; 73 | } 74 | std::cout << "\n"; 75 | } 76 | std::cout << "\n"; 77 | } 78 | std::cout << std::endl; 79 | hip_rt = hipMemcpy(x, rdata.data(), real_bytes, hipMemcpyHostToDevice); 80 | if(hip_rt != hipSuccess) 81 | throw std::runtime_error("hipMemcpy failed"); 82 | 83 | // Create plan: 84 | hipfftHandle plan = hipfft_params::INVALID_PLAN_HANDLE; 85 | hipfftResult hipfft_rt = hipfftCreate(&plan); 86 | if(hipfft_rt != HIPFFT_SUCCESS) 87 | throw std::runtime_error("failed to create plan"); 88 | hipfft_rt = hipfftPlan3d(&plan, // plan handle 89 | Nx, 90 | Ny, 91 | Nz, // transform lengths 92 | HIPFFT_D2Z); // transform type (HIPFFT_R2C for single-precision) 93 | if(hipfft_rt != HIPFFT_SUCCESS) 94 | throw std::runtime_error("hipfftPlan3d failed"); 95 | 96 | // Execute plan: 97 | // hipfftExecD2Z: double precision, hipfftExecR2C: single-precision 98 | hipfft_rt = hipfftExecD2Z(plan, x, (hipfftDoubleComplex*)x); 99 | if(hipfft_rt != HIPFFT_SUCCESS) 100 | throw std::runtime_error("hipfftExecD2Z failed"); 101 | 102 | std::cout << "output:\n"; 103 | std::vector> cdata(Nx * Ny * Nz); 104 | hip_rt = hipMemcpy(cdata.data(), x, complex_bytes, hipMemcpyDeviceToHost); 105 | if(hip_rt != hipSuccess) 106 | throw std::runtime_error("hipMemcpy failed"); 107 | for(size_t i = 0; i < Nx; i++) 108 | { 109 | for(size_t j = 0; j < Ny; j++) 110 | { 111 | for(size_t k = 0; k < Nzcomplex; k++) 112 | { 113 | auto pos = (i * Ny + j) * Nzcomplex + k; 114 | std::cout << cdata[pos] << " "; 115 | } 116 | std::cout << "\n"; 117 | } 118 | std::cout << "\n"; 119 | } 120 | std::cout << std::endl; 121 | 122 | hipfftDestroy(plan); 123 | 124 | hip_rt = hipFree(x); 125 | if(hip_rt != hipSuccess) 126 | throw std::runtime_error("hipFree failed"); 127 | 128 | return 0; 129 | } 130 | -------------------------------------------------------------------------------- /clients/samples/hipfft_3d_z2z.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 - 2022 Advanced Micro Devices, Inc. All rights 2 | // 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 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | DISABLE_WARNING_PUSH 29 | DISABLE_WARNING_DEPRECATED_DECLARATIONS 30 | DISABLE_WARNING_RETURN_TYPE 31 | #include 32 | DISABLE_WARNING_POP 33 | 34 | #include "../hipfft_params.h" 35 | 36 | int main() 37 | { 38 | std::cout << "hipfft 3D double-precision complex-to-complex transform\n"; 39 | 40 | const int Nx = 4; 41 | const int Ny = 4; 42 | const int Nz = 4; 43 | int direction = HIPFFT_FORWARD; // forward=-1, backward=1 44 | 45 | std::vector> cdata(Nx * Ny * Nz); 46 | size_t complex_bytes = sizeof(decltype(cdata)::value_type) * cdata.size(); 47 | 48 | // Create HIP device object and copy data to device: 49 | // hipfftComplex for single-precision 50 | hipError_t hip_rt; 51 | hipfftDoubleComplex* x; 52 | hip_rt = hipMalloc(&x, complex_bytes); 53 | if(hip_rt != hipSuccess) 54 | throw std::runtime_error("hipMalloc failed"); 55 | 56 | std::cout << "Input:\n"; 57 | for(size_t i = 0; i < Nx * Ny * Nz; i++) 58 | { 59 | cdata[i] = i; 60 | } 61 | for(int i = 0; i < Nx; i++) 62 | { 63 | for(int j = 0; j < Ny; j++) 64 | { 65 | for(int k = 0; k < Nz; k++) 66 | { 67 | int pos = (i * Ny + j) * Nz + k; 68 | std::cout << cdata[pos] << " "; 69 | } 70 | std::cout << "\n"; 71 | } 72 | std::cout << "\n"; 73 | } 74 | std::cout << std::endl; 75 | hip_rt = hipMemcpy(x, cdata.data(), complex_bytes, hipMemcpyHostToDevice); 76 | if(hip_rt != hipSuccess) 77 | throw std::runtime_error("hipMemcpy failed"); 78 | 79 | // Create plan 80 | hipfftHandle plan = hipfft_params::INVALID_PLAN_HANDLE; 81 | hipfftResult hipfft_rt = hipfftCreate(&plan); 82 | if(hipfft_rt != HIPFFT_SUCCESS) 83 | throw std::runtime_error("failed to create plan"); 84 | 85 | hipfft_rt = hipfftPlan3d(&plan, // plan handle 86 | Nx, // transform length 87 | Ny, // transform length 88 | Nz, // transform length 89 | HIPFFT_Z2Z); // transform type (HIPFFT_C2C for single-precision) 90 | if(hipfft_rt != HIPFFT_SUCCESS) 91 | throw std::runtime_error("hipfftPlan3d failed"); 92 | 93 | // Execute plan 94 | // hipfftExecZ2Z: double precision, hipfftExecC2C: for single-precision 95 | hipfft_rt = hipfftExecZ2Z(plan, x, x, direction); 96 | if(hipfft_rt != HIPFFT_SUCCESS) 97 | throw std::runtime_error("hipfftExecZ2Z failed"); 98 | 99 | std::cout << "output:\n"; 100 | hip_rt = hipMemcpy(cdata.data(), x, complex_bytes, hipMemcpyDeviceToHost); 101 | if(hip_rt != hipSuccess) 102 | throw std::runtime_error("hipMemcpy failed"); 103 | for(int i = 0; i < Nx; i++) 104 | { 105 | for(int j = 0; j < Ny; j++) 106 | { 107 | for(int k = 0; k < Nz; k++) 108 | { 109 | int pos = (i * Ny + j) * Nz + k; 110 | std::cout << cdata[pos] << " "; 111 | } 112 | std::cout << "\n"; 113 | } 114 | std::cout << "\n"; 115 | } 116 | std::cout << std::endl; 117 | 118 | hipfftDestroy(plan); 119 | 120 | hip_rt = hipFree(x); 121 | if(hip_rt != hipSuccess) 122 | throw std::runtime_error("hipFree failed"); 123 | 124 | return 0; 125 | } 126 | -------------------------------------------------------------------------------- /clients/samples/hipfft_multigpu_2d_z2z.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Advanced Micro Devices, Inc. All rights 2 | // 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 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | DISABLE_WARNING_PUSH 29 | DISABLE_WARNING_DEPRECATED_DECLARATIONS 30 | DISABLE_WARNING_RETURN_TYPE 31 | #include 32 | DISABLE_WARNING_POP 33 | 34 | #include "../hipfft_params.h" 35 | 36 | int main() 37 | { 38 | std::cout << "Multi-gpu hipFFT 2D double-precision complex-to-complex transform\n"; 39 | 40 | // 2D FFTs are encountered in diverse applications of image processing, 41 | // examples range from image denoising to RTM seismic imaging. 42 | // In this example we compare the 2D FFT computation using single vs multiple GPUs. 43 | 44 | // Note that when using cuFFTXt with two or more GPUs, its latest version requires 45 | // a minimum size per dimension greater or equal than 32 and less equal than 4096 46 | // for single precision, and 2048 for double precision. 47 | const int Nx = 512; 48 | const int Ny = 512; 49 | int direction = HIPFFT_FORWARD; // forward=-1, backward=1 50 | 51 | int verbose = 0; 52 | 53 | // Initialize reference data 54 | std::vector> cinput(Nx * Ny); 55 | for(size_t i = 0; i < Nx * Ny; i++) 56 | { 57 | cinput[i] = i; 58 | } 59 | 60 | if(verbose) 61 | { 62 | std::cout << "Input:\n"; 63 | for(int i = 0; i < Nx; i++) 64 | { 65 | for(int j = 0; j < Ny; j++) 66 | { 67 | int pos = i * Ny + j; 68 | std::cout << cinput[pos] << " "; 69 | } 70 | std::cout << "\n"; 71 | } 72 | std::cout << std::endl; 73 | } 74 | 75 | // Define list of GPUs to use 76 | std::array gpus = {0, 1}; 77 | 78 | // Create the multi-gpu plan 79 | hipLibXtDesc* desc; // input descriptor 80 | 81 | hipfftHandle plan = hipfft_params::INVALID_PLAN_HANDLE; 82 | if(hipfftCreate(&plan) != HIPFFT_SUCCESS) 83 | throw std::runtime_error("failed to create plan"); 84 | 85 | // Create a GPU stream and assign it to the plan 86 | hipStream_t stream{}; 87 | if(hipStreamCreate(&stream) != hipSuccess) 88 | throw std::runtime_error("hipStreamCreate failed."); 89 | if(hipfftSetStream(plan, stream) != HIPFFT_SUCCESS) 90 | throw std::runtime_error("hipfftSetStream failed."); 91 | 92 | // Assign GPUs to the plan 93 | hipfftResult hipfft_rt = hipfftXtSetGPUs(plan, gpus.size(), gpus.data()); 94 | if(hipfft_rt != HIPFFT_SUCCESS) 95 | throw std::runtime_error("hipfftXtSetGPUs failed."); 96 | 97 | // Make the 2D plan 98 | size_t workSize[gpus.size()]; 99 | hipfft_rt = hipfftMakePlan2d(plan, Nx, Ny, HIPFFT_Z2Z, workSize); 100 | if(hipfft_rt != HIPFFT_SUCCESS) 101 | throw std::runtime_error("hipfftMakePlan2d failed."); 102 | 103 | // Copy input data to GPUs 104 | hipfftXtSubFormat_t format = HIPFFT_XT_FORMAT_INPLACE_SHUFFLED; 105 | hipfft_rt = hipfftXtMalloc(plan, &desc, format); 106 | if(hipfft_rt != HIPFFT_SUCCESS) 107 | throw std::runtime_error("hipfftXtMalloc failed."); 108 | 109 | hipfft_rt = hipfftXtMemcpy(plan, 110 | reinterpret_cast(desc), 111 | reinterpret_cast(cinput.data()), 112 | HIPFFT_COPY_HOST_TO_DEVICE); 113 | if(hipfft_rt != HIPFFT_SUCCESS) 114 | throw std::runtime_error("hipfftXtMemcpy failed."); 115 | 116 | // Execute the plan 117 | hipfft_rt = hipfftXtExecDescriptor(plan, desc, desc, direction); 118 | if(hipfft_rt != HIPFFT_SUCCESS) 119 | throw std::runtime_error("hipfftXtMemcpy failed."); 120 | 121 | // Print output 122 | if(verbose) 123 | { 124 | // Move result to the host 125 | hipfft_rt = hipfftXtMemcpy(plan, 126 | reinterpret_cast(cinput.data()), 127 | reinterpret_cast(desc), 128 | HIPFFT_COPY_DEVICE_TO_HOST); 129 | if(hipfft_rt != HIPFFT_SUCCESS) 130 | throw std::runtime_error("hipfftXtMemcpy D2H failed."); 131 | 132 | std::cout << "Output:\n"; 133 | for(size_t i = 0; i < Nx; i++) 134 | { 135 | for(size_t j = 0; j < Ny; j++) 136 | { 137 | auto pos = i * Ny + j; 138 | std::cout << cinput[pos] << " "; 139 | } 140 | std::cout << "\n"; 141 | } 142 | std::cout << std::endl; 143 | } 144 | 145 | // Clean up 146 | if(hipfftXtFree(desc) != HIPFFT_SUCCESS) 147 | throw std::runtime_error("hipfftXtFree failed."); 148 | 149 | if(hipfftDestroy(plan) != HIPFFT_SUCCESS) 150 | throw std::runtime_error("hipfftDestroy failed."); 151 | 152 | if(hipStreamDestroy(stream) != hipSuccess) 153 | throw std::runtime_error("hipStreamDestroy failed."); 154 | 155 | return 0; 156 | } 157 | -------------------------------------------------------------------------------- /clients/samples/hipfft_planmany_2d_r2c.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 - 2022 Advanced Micro Devices, Inc. All rights 2 | // 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 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | DISABLE_WARNING_PUSH 28 | DISABLE_WARNING_DEPRECATED_DECLARATIONS 29 | DISABLE_WARNING_RETURN_TYPE 30 | #include 31 | DISABLE_WARNING_POP 32 | 33 | int main() 34 | { 35 | std::cout << "hipfft 2D single-precision real-to-complex transform using " 36 | "advanced interface\n"; 37 | 38 | int rank = 2; 39 | int n[2] = {4, 5}; 40 | int howmany = 3; // batch size 41 | 42 | int n1_complex_elements = n[1] / 2 + 1; 43 | int n1_padding_real_elements = n1_complex_elements * 2; 44 | 45 | int istride = 1; 46 | int ostride = istride; 47 | int inembed[2] = {istride * n[0], istride * n1_padding_real_elements}; 48 | int onembed[2] = {ostride * n[0], ostride * n1_complex_elements}; 49 | int idist = inembed[0] * inembed[1]; 50 | int odist = onembed[0] * onembed[1]; 51 | 52 | std::cout << "n: " << n[0] << " " << n[1] << "\n" 53 | << "howmany: " << howmany << "\n" 54 | << "istride: " << istride << "\tostride: " << ostride << "\n" 55 | << "inembed: " << inembed[0] << " " << inembed[1] << "\n" 56 | << "onembed: " << onembed[0] << " " << onembed[1] << "\n" 57 | << "idist: " << idist << "\todist: " << odist << "\n" 58 | << std::endl; 59 | 60 | std::vector data(howmany * idist); 61 | const auto total_bytes = data.size() * sizeof(decltype(data)::value_type); 62 | 63 | std::cout << "input:\n"; 64 | std::fill(data.begin(), data.end(), 0.0); 65 | for(int ibatch = 0; ibatch < howmany; ++ibatch) 66 | { 67 | for(int i = 0; i < n[0]; i++) 68 | { 69 | for(int j = 0; j < n[1]; j++) 70 | { 71 | const auto pos = ibatch * idist + istride * (i * inembed[1] + j); 72 | data[pos] = i + ibatch + j; 73 | } 74 | } 75 | } 76 | for(int ibatch = 0; ibatch < howmany; ++ibatch) 77 | { 78 | std::cout << "batch: " << ibatch << "\n"; 79 | for(int i = 0; i < inembed[0]; i++) 80 | { 81 | for(int j = 0; j < inembed[1]; j++) 82 | { 83 | const auto pos = ibatch * idist + i * inembed[1] + j; 84 | std::cout << data[pos] << " "; 85 | } 86 | std::cout << "\n"; 87 | } 88 | std::cout << "\n"; 89 | } 90 | std::cout << std::endl; 91 | 92 | hipfftHandle hipForwardPlan; 93 | hipfftResult hipfft_rt; 94 | hipfft_rt = hipfftPlanMany(&hipForwardPlan, 95 | rank, 96 | n, 97 | inembed, 98 | istride, 99 | idist, 100 | onembed, 101 | ostride, 102 | odist, 103 | HIPFFT_R2C, // Use HIPFFT_D2Z for double-precsion. 104 | howmany); 105 | if(hipfft_rt != HIPFFT_SUCCESS) 106 | throw std::runtime_error("failed to create plan"); 107 | 108 | hipfftReal* gpu_data; 109 | 110 | hipError_t hip_rt; 111 | hip_rt = hipMalloc((void**)&gpu_data, total_bytes); 112 | if(hip_rt != hipSuccess) 113 | throw std::runtime_error("hipMalloc failed"); 114 | 115 | hip_rt = hipMemcpy(gpu_data, (void*)data.data(), total_bytes, hipMemcpyHostToDevice); 116 | if(hip_rt != hipSuccess) 117 | throw std::runtime_error("hipMemcpy failed"); 118 | 119 | hipfft_rt = hipfftExecR2C(hipForwardPlan, gpu_data, (hipfftComplex*)gpu_data); 120 | if(hipfft_rt != HIPFFT_SUCCESS) 121 | throw std::runtime_error("failed to execute plan"); 122 | 123 | hip_rt = hipMemcpy((void*)data.data(), gpu_data, total_bytes, hipMemcpyDeviceToHost); 124 | if(hip_rt != hipSuccess) 125 | throw std::runtime_error("hipMemcpy failed"); 126 | 127 | std::cout << "output:\n"; 128 | const std::complex* output = (std::complex*)data.data(); 129 | for(int ibatch = 0; ibatch < howmany; ++ibatch) 130 | { 131 | std::cout << "batch: " << ibatch << "\n"; 132 | for(int i = 0; i < onembed[0]; i++) 133 | { 134 | for(int j = 0; j < onembed[1]; j++) 135 | { 136 | const auto pos = ibatch * odist + i * onembed[1] + j; 137 | std::cout << output[pos] << " "; 138 | } 139 | std::cout << "\n"; 140 | } 141 | std::cout << "\n"; 142 | } 143 | std::cout << std::endl; 144 | 145 | hipfftDestroy(hipForwardPlan); 146 | 147 | hip_rt = hipFree(gpu_data); 148 | if(hip_rt != hipSuccess) 149 | throw std::runtime_error("hipFree failed"); 150 | 151 | return 0; 152 | } 153 | -------------------------------------------------------------------------------- /clients/samples/hipfft_planmany_2d_z2z.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 - 2022 Advanced Micro Devices, Inc. All rights 2 | // 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 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | DISABLE_WARNING_PUSH 28 | DISABLE_WARNING_DEPRECATED_DECLARATIONS 29 | DISABLE_WARNING_RETURN_TYPE 30 | #include 31 | DISABLE_WARNING_POP 32 | 33 | int main() 34 | { 35 | std::cout << "hipfft 2D double-precision complex-to-complex transform using " 36 | "advanced interface\n"; 37 | 38 | int rank = 2; 39 | int n[2] = {4, 5}; 40 | int howmany = 3; 41 | 42 | // array is contiguous in memory 43 | int istride = 1; 44 | // in-place transforms require istride=ostride 45 | int ostride = istride; 46 | 47 | // we choose to have no padding around our data: 48 | int inembed[2] = {istride * n[0], istride * n[1]}; 49 | // in-place transforms require inembed=oneembed: 50 | int onembed[2] = {inembed[0], inembed[1]}; 51 | 52 | int idist = inembed[0] * inembed[1]; 53 | int odist = onembed[0] * onembed[1]; 54 | 55 | std::cout << "n: " << n[0] << " " << n[1] << "\n" 56 | << "howmany: " << howmany << "\n" 57 | << "istride: " << istride << "\tostride: " << ostride << "\n" 58 | << "inembed: " << inembed[0] << " " << inembed[1] << "\n" 59 | << "onembed: " << onembed[0] << " " << onembed[1] << "\n" 60 | << "idist: " << idist << "\todist: " << odist << "\n" 61 | << std::endl; 62 | 63 | std::vector> data(howmany * idist); 64 | const auto total_bytes = data.size() * sizeof(decltype(data)::value_type); 65 | 66 | std::cout << "input:\n"; 67 | std::fill(data.begin(), data.end(), 0.0); 68 | for(int ibatch = 0; ibatch < howmany; ++ibatch) 69 | { 70 | for(int i = 0; i < n[0]; i++) 71 | { 72 | for(int j = 0; j < n[1]; j++) 73 | { 74 | const auto pos = ibatch * idist + istride * (i * inembed[1] + j); 75 | data[pos] = std::complex(i + ibatch, j); 76 | } 77 | } 78 | } 79 | for(int ibatch = 0; ibatch < howmany; ++ibatch) 80 | { 81 | std::cout << "batch: " << ibatch << "\n"; 82 | for(int i = 0; i < inembed[0]; i++) 83 | { 84 | for(int j = 0; j < inembed[1]; j++) 85 | { 86 | const auto pos = ibatch * idist + i * inembed[1] + j; 87 | std::cout << data[pos] << " "; 88 | } 89 | std::cout << "\n"; 90 | } 91 | std::cout << "\n"; 92 | } 93 | std::cout << std::endl; 94 | 95 | hipfftHandle hipPlan; 96 | hipfftResult hipfft_rt; 97 | hipfft_rt = hipfftPlanMany( 98 | &hipPlan, rank, n, inembed, istride, idist, onembed, ostride, odist, HIPFFT_Z2Z, howmany); 99 | if(hipfft_rt != HIPFFT_SUCCESS) 100 | throw std::runtime_error("failed to create plan"); 101 | 102 | hipError_t hip_rt; 103 | hipfftDoubleComplex* d_in_out; 104 | hip_rt = hipMalloc((void**)&d_in_out, total_bytes); 105 | if(hip_rt != hipSuccess) 106 | throw std::runtime_error("hipMalloc failed"); 107 | hip_rt = hipMemcpy(d_in_out, (void*)data.data(), total_bytes, hipMemcpyHostToDevice); 108 | if(hip_rt != hipSuccess) 109 | throw std::runtime_error("hipMemcpy failed"); 110 | 111 | hipfft_rt = hipfftExecZ2Z(hipPlan, d_in_out, d_in_out, HIPFFT_FORWARD); 112 | if(hipfft_rt != HIPFFT_SUCCESS) 113 | throw std::runtime_error("failed to execute plan"); 114 | 115 | hip_rt = hipMemcpy((void*)data.data(), d_in_out, total_bytes, hipMemcpyDeviceToHost); 116 | if(hip_rt != hipSuccess) 117 | throw std::runtime_error("hipMemcpy failed"); 118 | 119 | std::cout << "output:\n"; 120 | for(int ibatch = 0; ibatch < howmany; ++ibatch) 121 | { 122 | std::cout << "batch: " << ibatch << "\n"; 123 | for(int i = 0; i < onembed[0]; i++) 124 | { 125 | for(int j = 0; j < onembed[1]; j++) 126 | { 127 | const auto pos = ibatch * odist + i * onembed[1] + j; 128 | std::cout << data[pos] << " "; 129 | } 130 | std::cout << "\n"; 131 | } 132 | std::cout << "\n"; 133 | } 134 | std::cout << std::endl; 135 | 136 | hip_rt = hipFree(d_in_out); 137 | if(hip_rt != hipSuccess) 138 | throw std::runtime_error("hipFree failed"); 139 | 140 | return 0; 141 | } 142 | -------------------------------------------------------------------------------- /clients/samples/hipfft_setworkarea.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 - 2022 Advanced Micro Devices, Inc. All rights 2 | // 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 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | DISABLE_WARNING_PUSH 28 | DISABLE_WARNING_DEPRECATED_DECLARATIONS 29 | DISABLE_WARNING_RETURN_TYPE 30 | #include 31 | DISABLE_WARNING_POP 32 | 33 | #include "../hipfft_params.h" 34 | 35 | int main() 36 | { 37 | std::cout << "hipfft 1D single-precision real-to-complex transform showing " 38 | "work memory usage\n"; 39 | 40 | int major_version; 41 | hipfftGetProperty(HIPFFT_MAJOR_VERSION, &major_version); 42 | std::cout << "hipFFT major_version " << major_version << std::endl; 43 | 44 | const size_t N = 9; 45 | const size_t Ncomplex = (N / 2 + 1); 46 | 47 | std::vector rdata(N); 48 | std::vector> cdata(Ncomplex); 49 | 50 | size_t real_bytes = sizeof(decltype(rdata)::value_type) * rdata.size(); 51 | size_t complex_bytes = sizeof(decltype(cdata)::value_type) * cdata.size(); 52 | 53 | hipError_t hip_rt = hipSuccess; 54 | hipfftResult hipfft_rt = HIPFFT_SUCCESS; 55 | 56 | std::cout << "input:\n"; 57 | for(size_t i = 0; i < N; i++) 58 | { 59 | rdata[i] = i; 60 | } 61 | for(size_t i = 0; i < N; i++) 62 | { 63 | std::cout << rdata[i] << " "; 64 | } 65 | std::cout << std::endl; 66 | 67 | // Create HIP device object. 68 | hipfftReal* x; 69 | hip_rt = hipMalloc(&x, real_bytes); 70 | if(hip_rt != hipSuccess) 71 | throw std::runtime_error("hipMalloc failed"); 72 | 73 | hipfftComplex* y; 74 | hip_rt = hipMalloc(&y, complex_bytes); 75 | if(hip_rt != hipSuccess) 76 | throw std::runtime_error("hipMalloc failed"); 77 | 78 | // Copy input data to device 79 | hip_rt = hipMemcpy(x, rdata.data(), real_bytes, hipMemcpyHostToDevice); 80 | if(hip_rt != hipSuccess) 81 | throw std::runtime_error("hipMemcpy failed"); 82 | 83 | size_t workSize; 84 | hipfft_rt = hipfftEstimate1d(N, HIPFFT_R2C, 1, &workSize); 85 | if(hipfft_rt != HIPFFT_SUCCESS) 86 | throw std::runtime_error("hipfftEstimate1d failed"); 87 | std::cout << "hipfftEstimate 1d workSize: " << workSize << std::endl; 88 | 89 | hipfftHandle plan = hipfft_params::INVALID_PLAN_HANDLE; 90 | hipfft_rt = hipfftCreate(&plan); 91 | if(hipfft_rt != HIPFFT_SUCCESS) 92 | throw std::runtime_error("hipfftCreate failed"); 93 | hipfft_rt = hipfftSetAutoAllocation(plan, 0); 94 | if(hipfft_rt != HIPFFT_SUCCESS) 95 | throw std::runtime_error("hipfftSetAutoAllocation failed"); 96 | hipfft_rt = hipfftMakePlan1d(plan, N, HIPFFT_R2C, 1, &workSize); 97 | if(hipfft_rt != HIPFFT_SUCCESS) 98 | throw std::runtime_error("hipfftMakePlan1d failed"); 99 | 100 | // Set work buffer 101 | hipfftComplex* workBuf; 102 | hip_rt = hipMalloc(&workBuf, workSize); 103 | if(hip_rt != hipSuccess) 104 | throw std::runtime_error("hipMalloc failed"); 105 | hipfft_rt = hipfftSetWorkArea(plan, workBuf); 106 | if(hipfft_rt != HIPFFT_SUCCESS) 107 | throw std::runtime_error("hipfftSetWorkArea failed"); 108 | hipfft_rt = hipfftGetSize(plan, &workSize); 109 | if(hipfft_rt != HIPFFT_SUCCESS) 110 | throw std::runtime_error("hipfftGetSize failed"); 111 | 112 | std::cout << "hipfftGetSize workSize: " << workSize << std::endl; 113 | 114 | // Execute plan 115 | hipfft_rt = hipfftExecR2C(plan, x, (hipfftComplex*)y); 116 | 117 | // Copy result back to host 118 | hip_rt = hipMemcpy(cdata.data(), y, complex_bytes, hipMemcpyDeviceToHost); 119 | if(hip_rt != hipSuccess) 120 | throw std::runtime_error("hipMemcpy failed"); 121 | 122 | std::cout << "output:\n"; 123 | for(size_t i = 0; i < Ncomplex; i++) 124 | { 125 | std::cout << cdata[i] << " "; 126 | } 127 | std::cout << std::endl; 128 | 129 | hipfftDestroy(plan); 130 | 131 | hip_rt = hipFree(x); 132 | if(hip_rt != hipSuccess) 133 | throw std::runtime_error("hipFree failed"); 134 | 135 | hip_rt = hipFree(workBuf); 136 | if(hip_rt != hipSuccess) 137 | throw std::runtime_error("hipFree failed"); 138 | 139 | return 0; 140 | } 141 | -------------------------------------------------------------------------------- /clients/tests/hipfft_accuracy_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #pragma once 22 | 23 | #ifndef ROCFFT_ACCURACY_TEST 24 | #define ROCFFT_ACCURACY_TEST 25 | 26 | #include "../../shared/accuracy_test.h" 27 | #include "../hipfft_params.h" 28 | 29 | void fft_vs_reference(hipfft_params& params, bool round_trip = false); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /clients/tests/hipfft_mpi_worker.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (C) 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 | #include "../../shared/mpi_worker.h" 24 | #include "../hipfft_params.h" 25 | 26 | int main(int argc, char* argv[]) 27 | { 28 | return mpi_worker_main, false>( 29 | "hipFFT MPI worker process", argc, argv, [](const std::vector& lib_strings) { 30 | return std::array(); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /clients/tests/hipfft_test_params.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 - 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #pragma once 22 | #ifndef TESTCONSTANTS_H 23 | #define TESTCONSTANTS_H 24 | 25 | #include "hipfft/hipfft.h" 26 | 27 | #include 28 | 29 | extern int verbose; 30 | extern size_t ramgb; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /cmake/dependencies.cmake: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2020 - 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 | # HIP 25 | if( NOT CMAKE_CXX_COMPILER MATCHES ".*/hipcc$" ) 26 | if( NOT BUILD_WITH_LIB STREQUAL "CUDA" ) 27 | if( WIN32 ) 28 | find_package( HIP CONFIG REQUIRED ) 29 | else() 30 | find_package( HIP REQUIRED ) 31 | endif() 32 | list( APPEND HIP_INCLUDE_DIRS "${HIP_ROOT_DIR}/include" ) 33 | endif() 34 | else() 35 | if( BUILD_WITH_LIB STREQUAL "CUDA" ) 36 | set(HIP_INCLUDE_DIRS "${HIP_ROOT_DIR}/include") 37 | else() 38 | if( WIN32 ) 39 | find_package( HIP CONFIG REQUIRED ) 40 | else() 41 | find_package( HIP REQUIRED ) 42 | endif() 43 | endif() 44 | endif() 45 | 46 | # Either rocfft or cufft is required 47 | if(NOT BUILD_WITH_LIB STREQUAL "CUDA") 48 | if( HIPFFT_MPI_ENABLE ) 49 | find_package( MPI REQUIRED ) 50 | endif() 51 | find_package(rocfft REQUIRED) 52 | else() 53 | # cufft may be in the HPC SDK or ordinary CUDA 54 | if( HIPFFT_MPI_ENABLE ) 55 | if( NOT BUILD_SHARED_LIBS ) 56 | message( FATAL_ERROR "cufftMp is shared-only, static build is not possible" ) 57 | endif() 58 | # MPI support is only in HPC SDK 59 | find_package(NVHPC REQUIRED COMPONENTS CUDA MATH MPI) 60 | else() 61 | find_package(NVHPC QUIET COMPONENTS CUDA MATH) 62 | endif() 63 | set(CUDA_USE_STATIC_CUDA_RUNTIME OFF) 64 | find_package(CUDAToolkit REQUIRED) 65 | endif() 66 | 67 | # ROCm 68 | find_package( ROCmCMakeBuildTools CONFIG PATHS /opt/rocm ) 69 | if(NOT ROCmCMakeBuildTools_FOUND) 70 | set( rocm_cmake_tag "develop" CACHE STRING "rocm-cmake tag to download" ) 71 | set( PROJECT_EXTERN_DIR "${CMAKE_CURRENT_BINARY_DIR}/extern" ) 72 | file( DOWNLOAD https://github.com/RadeonOpenCompute/rocm-cmake/archive/${rocm_cmake_tag}.zip 73 | ${PROJECT_EXTERN_DIR}/rocm-cmake-${rocm_cmake_tag}.zip STATUS status LOG log) 74 | 75 | list(GET status 0 status_code) 76 | list(GET status 1 status_string) 77 | 78 | if(NOT status_code EQUAL 0) 79 | message(WARNING "error: downloading 80 | 'https://github.com/RadeonOpenCompute/rocm-cmake/archive/${rocm_cmake_tag}.zip' failed 81 | status_code: ${status_code} 82 | status_string: ${status_string} 83 | log: ${log} 84 | ") 85 | else() 86 | message(STATUS "downloading... done") 87 | 88 | execute_process( COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PROJECT_EXTERN_DIR}/rocm-cmake-${rocm_cmake_tag}.zip 89 | WORKING_DIRECTORY ${PROJECT_EXTERN_DIR} ) 90 | execute_process( COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${PROJECT_EXTERN_DIR}/rocm-cmake . 91 | WORKING_DIRECTORY ${PROJECT_EXTERN_DIR}/rocm-cmake-${rocm_cmake_tag} ) 92 | execute_process( COMMAND ${CMAKE_COMMAND} --build rocm-cmake-${rocm_cmake_tag} --target install 93 | WORKING_DIRECTORY ${PROJECT_EXTERN_DIR}) 94 | 95 | find_package( ROCmCMakeBuildTools CONFIG PATHS ${PROJECT_EXTERN_DIR}/rocm-cmake ) 96 | endif() 97 | endif() 98 | if( ROCmCMakeBuildTools_FOUND ) 99 | message(STATUS "Found ROCm") 100 | include(ROCMSetupVersion) 101 | include(ROCMCreatePackage) 102 | include(ROCMInstallTargets) 103 | include(ROCMPackageConfigHelpers) 104 | include(ROCMInstallSymlinks) 105 | include(ROCMCheckTargetIds) 106 | include(ROCMClients) 107 | include(ROCMHeaderWrapper) 108 | else() 109 | message(WARNING "Could not find rocm-cmake, packaging will fail.") 110 | endif( ) 111 | -------------------------------------------------------------------------------- /cmake/get-cli-arguments.cmake: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2021 - 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 | 25 | # Attempt (best effort) to return a list of user specified parameters cmake was invoked with 26 | # NOTE: Even if the user specifies CMAKE_INSTALL_PREFIX on the command line, the parameter is 27 | # not returned because it does not have the matching helpstring 28 | 29 | function( append_cmake_cli_arguments initial_cli_args return_cli_args ) 30 | 31 | # Retrieves the contents of CMakeCache.txt 32 | get_cmake_property( cmake_properties CACHE_VARIABLES ) 33 | 34 | foreach( property ${cmake_properties} ) 35 | get_property(help_string CACHE ${property} PROPERTY HELPSTRING ) 36 | 37 | # Properties specified on the command line have boilerplate text 38 | if( help_string MATCHES "variable specified on the command line" ) 39 | # message( STATUS "property: ${property}") 40 | # message( STATUS "value: ${${property}}") 41 | 42 | list( APPEND cli_args "-D${property}=${${property}}") 43 | endif( ) 44 | endforeach( ) 45 | 46 | # message( STATUS "get_command_line_arguments: ${cli_args}") 47 | set( ${return_cli_args} ${${initial_cli_args}} ${cli_args} PARENT_SCOPE ) 48 | 49 | endfunction( ) -------------------------------------------------------------------------------- /cmake/package-functions.cmake: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2020 - 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 | # ######################################################################## 25 | # A helper function to generate packaging scripts to register libraries with system 26 | # ######################################################################## 27 | function( write_rocm_package_script_files scripts_write_dir library_name library_link_name ) 28 | 29 | set( ld_conf_file "/etc/ld.so.conf.d/${library_name}-dev.conf" ) 30 | 31 | file( WRITE ${scripts_write_dir}/postinst 32 | "#!/bin/bash 33 | 34 | set -e 35 | 36 | do_ldconfig() { 37 | echo ${CPACK_PACKAGING_INSTALL_PREFIX}/${LIB_INSTALL_DIR} > ${ld_conf_file} && ldconfig 38 | } 39 | 40 | case \"\$1\" in 41 | configure) 42 | do_ldconfig 43 | ;; 44 | abort-upgrade|abort-remove|abort-deconfigure) 45 | echo \"\$1\" 46 | ;; 47 | *) 48 | exit 0 49 | ;; 50 | esac 51 | " ) 52 | 53 | file( WRITE ${scripts_write_dir}/prerm 54 | "#!/bin/bash 55 | 56 | set -e 57 | 58 | rm_ldconfig() { 59 | rm -f ${ld_conf_file} && ldconfig 60 | } 61 | 62 | 63 | case \"\$1\" in 64 | remove|purge) 65 | rm_ldconfig 66 | ;; 67 | *) 68 | exit 0 69 | ;; 70 | esac 71 | " ) 72 | 73 | endfunction( ) 74 | -------------------------------------------------------------------------------- /cmake/verbose.cmake: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2020 - 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 | message(STATUS "hipfft_VERSION : ${hipfft_VERSION}") 25 | message(STATUS "\t==>CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}") 26 | message(STATUS "\t==>BUILD_SHARED_LIBS : ${BUILD_SHARED_LIBS}") 27 | message(STATUS "\t==>CMAKE_INSTALL_PREFIX link : ${CMAKE_INSTALL_PREFIX}") 28 | message(STATUS "\t==>CMAKE_MODULE_PATH link : ${CMAKE_MODULE_PATH}") 29 | message(STATUS "\t==>CMAKE_PREFIX_PATH link : ${CMAKE_PREFIX_PATH}") 30 | message(STATUS "==============") 31 | message(STATUS "\t==>CMAKE_SYSTEM_NAME : ${CMAKE_SYSTEM_NAME}") 32 | message(STATUS "\t>>=HIP_ROOT_DIR : ${HIP_ROOT_DIR}") 33 | message(STATUS "\t==>CMAKE_CXX_COMPILER : ${CMAKE_CXX_FLAGS}") 34 | message(STATUS "\t==>CMAKE_CXX_COMPILER_VERSION : ${CMAKE_CXX_COMPILER_VERSION}") 35 | message(STATUS "\t==>CMAKE_CXX_COMPILER debug : ${CMAKE_CXX_FLAGS_DEBUG}") 36 | message(STATUS "\t==>CMAKE_CXX_COMPILER release : ${CMAKE_CXX_FLAGS_RELEASE}") 37 | message(STATUS "\t==>CMAKE_CXX_COMPILER relwithdebinfo : ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") 38 | message(STATUS "\t==>CMAKE_EXE_LINKER_FLAGS : ${CMAKE_EXE_LINKER_FLAGS}") 39 | message(STATUS "\t==>CMAKE_EXE_LINKER_FLAGS_RELEASE : ${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 40 | message(STATUS "\t==>CMAKE_SHARED_LINKER_FLAGS : ${CMAKE_SHARED_LINKER_FLAGS}") 41 | message(STATUS "\t==>CMAKE_SHARED_LINKER_FLAGS_RELEASE : ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 42 | message(STATUS "==============" ) 43 | message(STATUS "\t==>CMAKE_SHARED_LIBRARY_C_FLAGS : ${CMAKE_SHARED_LIBRARY_C_FLAGS}") 44 | message(STATUS "\t==>CMAKE_SHARED_LIBRARY_CXX_FLAGS : ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") 45 | message(STATUS "\t==>CMAKE_SHARED_LINKER_FLAGS : ${CMAKE_SHARED_LINKER_FLAGS}") 46 | message(STATUS "\t==>CMAKE_SHARED_LINKER_FLAGS_DEBUG : ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") 47 | message(STATUS "\t==>CMAKE_SHARED_LINKER_FLAGS_RELEASE : ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") -------------------------------------------------------------------------------- /deps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2016 - 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 | # Helper cmake script to automate building dependencies for hipfft 24 | # This script can be invoked manually by the user with 'cmake -P' 25 | 26 | # The ROCm platform requires Ubuntu 16.04 or Fedora 24, which has cmake 3.5 27 | cmake_minimum_required( VERSION 3.5 ) 28 | 29 | list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake ) 30 | 31 | # Consider removing this in the future 32 | # It can be annoying for visual studio developers to build a project that tries to install into 'program files' 33 | if( WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) 34 | set( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories" FORCE ) 35 | endif( ) 36 | 37 | # This has to be initialized before the project() command appears 38 | # Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE 39 | if( NOT DEFINED CMAKE_CONFIGURATION_TYPES AND NOT DEFINED CMAKE_BUILD_TYPE ) 40 | set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." ) 41 | endif() 42 | 43 | # The superbuild does not build anything itself; all compiling is done in external projects 44 | project( hipfft-dependencies NONE ) 45 | 46 | option( BUILD_BOOST "Download and build boost library" ON ) 47 | option( BUILD_GTEST "Download and build googletest library" ON ) 48 | # option( BUILD_VERBOSE "Print helpful build debug information" OFF ) 49 | 50 | # if( BUILD_VERBOSE ) 51 | # message( STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}" ) 52 | # message( STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}" ) 53 | # message( STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}" ) 54 | # message( STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}" ) 55 | # message( STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}" ) 56 | # message( STATUS "CMAKE_CURRENT_LIST_DIR: ${CMAKE_CURRENT_LIST_DIR}" ) 57 | # message( STATUS "CMAKE_CURRENT_LIST_FILE: ${CMAKE_CURRENT_LIST_FILE}" ) 58 | # endif( ) 59 | 60 | # This module scrapes the CMakeCache.txt file and attempts to get all the cli options the user specified to cmake invocation 61 | include( get-cli-arguments ) 62 | 63 | # The following is a series of super-build projects; this cmake project will download and build 64 | if( BUILD_GTEST ) 65 | include( external-gtest ) 66 | 67 | list( APPEND hipfft_dependencies googletest ) 68 | set( gtest_custom_target COMMAND cd ${GTEST_BINARY_ROOT}$ ${CMAKE_COMMAND} --build . --target install ) 69 | endif( ) 70 | 71 | if( BUILD_BOOST ) 72 | include( external-boost ) 73 | 74 | list( APPEND hipfft_dependencies boost ) 75 | set( boost_custom_target COMMAND cd ${BOOST_BINARY_ROOT}$ ${Boost.Command} install ) 76 | endif( ) 77 | 78 | # POLICY CMP0037 - "Target names should not be reserved and should match a validity pattern" 79 | # Familiar target names like 'install' should be OK at the super-build level 80 | if( POLICY CMP0037 ) 81 | cmake_policy( SET CMP0037 OLD ) 82 | endif( ) 83 | 84 | add_custom_target( install 85 | ${boost_custom_target} 86 | ${gtest_custom_target} 87 | DEPENDS ${hipfft_dependencies} 88 | ) 89 | -------------------------------------------------------------------------------- /deps/external-gtest.cmake: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2016 - 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 | message( STATUS "Configuring gtest external dependency" ) 24 | include( ExternalProject ) 25 | 26 | # set( gtest_cmake_args -DCMAKE_INSTALL_PREFIX=/package ) 27 | set( PREFIX_GTEST ${CMAKE_INSTALL_PREFIX} CACHE PATH "Location where boost should install, defaults to /usr/local" ) 28 | set( gtest_cmake_args -DCMAKE_INSTALL_PREFIX=${PREFIX_GTEST} ) 29 | append_cmake_cli_arguments( gtest_cmake_args gtest_cmake_args ) 30 | 31 | set( gtest_git_repository "https://github.com/google/googletest.git" CACHE STRING "URL to download gtest from" ) 32 | set( gtest_git_tag "release-1.8.0" CACHE STRING "URL to download gtest from" ) 33 | 34 | if( MSVC ) 35 | list( APPEND gtest_cmake_args -Dgtest_force_shared_crt=ON -DCMAKE_DEBUG_POSTFIX=d ) 36 | # else( ) 37 | # GTEST_USE_OWN_TR1_TUPLE necessary to compile with hipcc 38 | # list( APPEND gtest_cmake_args -DGTEST_USE_OWN_TR1_TUPLE=1 ) 39 | endif( ) 40 | 41 | if( CMAKE_CONFIGURATION_TYPES ) 42 | set( gtest_make 43 | COMMAND ${CMAKE_COMMAND} --build --config Release 44 | COMMAND ${CMAKE_COMMAND} --build --config Debug 45 | ) 46 | else( ) 47 | # Add build thread in addition to the number of cores that we have 48 | include( ProcessorCount ) 49 | ProcessorCount( Cores ) 50 | 51 | # If we are not using an IDE, assume nmake with visual studio 52 | if( MSVC ) 53 | set( gtest_make "nmake" ) 54 | else( ) 55 | set( gtest_make "make" ) 56 | 57 | # The -j paramter does not work with nmake 58 | if( NOT Cores EQUAL 0 ) 59 | math( EXPR Cores "${Cores} + 1 " ) 60 | list( APPEND gtest_make -j ${Cores} ) 61 | else( ) 62 | # If we could not detect # of cores, assume 1 core and add an additional build thread 63 | list( APPEND gtest_make -j 2 ) 64 | endif( ) 65 | endif( ) 66 | 67 | message( STATUS "ExternalGmock using ( " ${Cores} " ) cores to build with" ) 68 | endif( ) 69 | 70 | # message( STATUS "gtest_make ( " ${gtest_make} " ) " ) 71 | # message( STATUS "gtest_cmake_args ( " ${gtest_cmake_args} " ) " ) 72 | 73 | # Master branch has a new structure that combines googletest with googlemock 74 | ExternalProject_Add( 75 | googletest 76 | PREFIX ${CMAKE_BINARY_DIR}/gtest 77 | GIT_REPOSITORY ${gtest_git_repository} 78 | GIT_TAG ${gtest_git_tag} 79 | CMAKE_ARGS ${gtest_cmake_args} 80 | BUILD_COMMAND ${gtest_make} 81 | LOG_BUILD 1 82 | INSTALL_COMMAND "" 83 | LOG_INSTALL 1 84 | ) 85 | 86 | ExternalProject_Get_Property( googletest source_dir ) 87 | 88 | # For visual studio, the path 'debug' is hardcoded because that is the default VS configuration for a build. 89 | # Doesn't matter if its the gtest or gtestd project above 90 | set( package_dir "${PREFIX_GTEST}" ) 91 | if( CMAKE_CONFIGURATION_TYPES ) 92 | # Create a package by bundling libraries and header files 93 | if( BUILD_64 ) 94 | set( LIB_DIR lib64 ) 95 | else( ) 96 | set( LIB_DIR lib ) 97 | endif( ) 98 | 99 | set( gtest_lib_dir "/${LIB_DIR}" ) 100 | ExternalProject_Add_Step( googletest createPackage 101 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${gtest_lib_dir}/Debug ${package_dir}/${LIB_DIR} 102 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${gtest_lib_dir}/Release ${package_dir}/${LIB_DIR} 103 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${gtest_lib_dir}/Debug ${package_dir}/${LIB_DIR} 104 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${gtest_lib_dir}/Release ${package_dir}/${LIB_DIR} 105 | COMMAND ${CMAKE_COMMAND} -E copy_directory /include ${package_dir}/include 106 | COMMAND ${CMAKE_COMMAND} -E copy_directory /gtest/include/gtest ${package_dir}/include/gtest 107 | DEPENDEES install 108 | ) 109 | endif( ) 110 | 111 | set_property( TARGET googletest PROPERTY FOLDER "extern") 112 | ExternalProject_Get_Property( googletest install_dir ) 113 | ExternalProject_Get_Property( googletest binary_dir ) 114 | 115 | # For use by the user of ExternalGtest.cmake 116 | set( GTEST_INSTALL_ROOT ${install_dir} ) 117 | set( GTEST_BINARY_ROOT ${binary_dir} ) 118 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _doxygen/ 2 | doxygen/html/ 3 | doxygen/rtf/ 4 | doxygen/xml/ 5 | -------------------------------------------------------------------------------- /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'set\( VERSION_STRING \"?([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"hipFFT {version_number} Documentation" 17 | 18 | # for PDF output on Read the Docs 19 | project = "hipFFT Documentation" 20 | author = "Advanced Micro Devices, Inc." 21 | copyright = "Copyright (c) 2025 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 = "hipfft" 32 | 33 | for sphinx_var in ROCmDocs.SPHINX_VARS: 34 | globals()[sphinx_var] = getattr(docs_core, sphinx_var) 35 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: hipFFT documentation and API reference library 3 | :keywords: FFT, hipFFT, rocFFT, ROCm, API, documentation 4 | 5 | .. _hipfft-docs-home: 6 | 7 | ******************************************************************** 8 | hipFFT documentation 9 | ******************************************************************** 10 | 11 | hipFFT is an FFT (fast Fourier transform) marshalling library. It supports either :doc:`rocFFT ` or 12 | NVIDIA CUDA cuFFT_ as the backend. hipFFT sits between the 13 | application and the backend FFT library, marshalling inputs into the 14 | backend and results back to the application. 15 | For more information, see the :ref:`hipfft-overview`. 16 | 17 | .. _rocFFT: https://rocm.docs.amd.com/projects/rocFFT/en/latest/index.html 18 | .. _cuFFT: https://developer.nvidia.com/cufft 19 | 20 | The hipFFT public repository is located at ``_. 21 | 22 | .. grid:: 2 23 | :gutter: 3 24 | 25 | .. grid-item-card:: Install 26 | 27 | * :doc:`Installation guide <./install/building-installing-hipfft>` 28 | 29 | .. grid-item-card:: Conceptual 30 | 31 | * :doc:`hipFFT overview <./conceptual/overview>` 32 | 33 | .. grid-item-card:: Examples 34 | 35 | * `hipFFT examples `_ 36 | 37 | .. grid-item-card:: API Reference 38 | 39 | * :doc:`API and usage notes <./reference/fft-api-usage>` 40 | * :ref:`API Index ` 41 | 42 | To contribute to the documentation, see `Contributing to ROCm `_. 43 | 44 | You can find licensing information on the `Licensing `_ page. -------------------------------------------------------------------------------- /docs/install/building-installing-hipfft.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: hipFFT documentation and API reference library 3 | :keywords: FFT, hipFFT, rocFFT, ROCm, API, documentation, build from source, installing 4 | 5 | .. _building-installing-hipfft: 6 | 7 | ******************************************************************** 8 | Building and installing hipFFT 9 | ******************************************************************** 10 | 11 | This topic explains how to install hipFFT from the prebuilt packages or build it from the source code. 12 | hipFTT requires a ROCm-enabled platform. For more information, 13 | see the :doc:`Linux system requirements `. 14 | 15 | Installing prebuilt packages 16 | ============================= 17 | 18 | For information on downloading and installing ROCm, see the 19 | :doc:`ROCm installation guide `. 20 | 21 | To install hipFFT, use the package manager for the Linux distribution, which 22 | handles all dependencies. 23 | This lets you run programs that use hipFFT, but not compile them. 24 | 25 | On the Ubuntu distribution, run the following command: 26 | 27 | .. code-block:: shell 28 | 29 | sudo apt update && sudo apt install hipfft 30 | 31 | .. note:: 32 | 33 | To compile programs, you must install the development package, which 34 | contains the header files and CMake infrastructure. 35 | This package is named ``hipfft-dev`` on Ubuntu/Debian systems and 36 | ``hipfft-devel`` on RHEL and related variants. 37 | 38 | Building hipFFT from source 39 | ============================= 40 | 41 | To build hipFFT from source, follow these steps: 42 | 43 | #. Install the library build dependencies: 44 | 45 | * On AMD platforms, install :doc:`rocFFT `. To build from source, 46 | rocFFT must be installed with the development headers. 47 | These headers can be added by installing the ``rocfft-dev`` or ``rocfft-devel`` package. If rocFFT was built from 48 | source, then these headers are already included. 49 | * On NVIDIA platforms, install CUDA cuFFT. 50 | cuFFT must be installed with the development headers. For more information, 51 | see `CUDA cuFFT `_. 52 | 53 | #. Install the client build dependencies for the clients: 54 | 55 | The clients that are included with the hipFFT source code, including samples and tests, 56 | depend on :doc:`hipRAND `, `FFTW `_, and GoogleTest. 57 | 58 | #. Build hipFFT: 59 | 60 | To show all build options, run these commands: 61 | 62 | .. code-block:: shell 63 | 64 | mkdir build && cd build 65 | cmake -LH .. 66 | 67 | Here are some CMake build examples: 68 | 69 | * For AMD GPUs 70 | 71 | * Building a project using :doc:`HIP language ` APIs and hipFFT with the standard host compiler: 72 | 73 | .. code-block:: shell 74 | 75 | cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -L .. 76 | 77 | * Building a project using HIP language APIs, hipFFT, and device kernels with HIP-Clang: 78 | 79 | .. code-block:: shell 80 | 81 | cmake -DCMAKE_CXX_COMPILER=amdclang++ -DCMAKE_BUILD_TYPE=Release -DBUILD_CLIENTS=ON -L .. 82 | 83 | * For NVIDIA GPUs 84 | 85 | * Building a project using HIP language APIs and hipFFT with the standard host compiler: 86 | 87 | .. code-block:: shell 88 | 89 | cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LIB=CUDA -L .. 90 | 91 | * Building a project using HIP language APIs, hipFFT, and device kernels with HIP-NVCC: 92 | 93 | .. code-block:: shell 94 | 95 | HIP_PLATFORM=nvidia cmake -DCMAKE_CXX_COMPILER=hipcc -DCMAKE_BUILD_TYPE=Release -DBUILD_CLIENTS=ON -L .. 96 | 97 | .. note:: 98 | 99 | The ``-DBUILD_CLIENTS=ON`` option is only allowed with the amdclang++ or HIPCC compilers. 100 | -------------------------------------------------------------------------------- /docs/license.md: -------------------------------------------------------------------------------- 1 | --- 2 | myst: 3 | html_meta: 4 | "description": "hipFFT licensing information" 5 | "keywords": "hipFFT, FFT, ROCm, API, documentation, license" 6 | --- 7 | 8 | # License 9 | 10 | ```{include} ../LICENSE.md 11 | ``` 12 | -------------------------------------------------------------------------------- /docs/sphinx/_toc.yml.in: -------------------------------------------------------------------------------- 1 | defaults: 2 | numbered: False 3 | root: index 4 | subtrees: 5 | 6 | - caption: Install 7 | entries: 8 | - file: install/building-installing-hipfft 9 | title: Installation guide 10 | 11 | - caption: Conceptual 12 | entries: 13 | - file: conceptual/overview 14 | title: hipFFT overview 15 | 16 | - caption: Examples 17 | entries: 18 | - url: https://github.com/ROCm/hipFFT/tree/develop/clients/samples 19 | title: hipFFT examples 20 | 21 | - caption: API reference 22 | entries: 23 | - file: reference/fft-api-usage 24 | title: API and usage notes 25 | 26 | - caption: About 27 | entries: 28 | - file: license 29 | title: License 30 | -------------------------------------------------------------------------------- /docs/sphinx/requirements.in: -------------------------------------------------------------------------------- 1 | rocm-docs-core==1.17.0 2 | -------------------------------------------------------------------------------- /docs/sphinx/requirements.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is autogenerated by pip-compile with Python 3.10 3 | # by the following command: 4 | # 5 | # pip-compile requirements.in 6 | # 7 | accessible-pygments==0.0.4 8 | # via pydata-sphinx-theme 9 | alabaster==0.7.16 10 | # via sphinx 11 | asttokens==3.0.0 12 | # via stack-data 13 | attrs==25.1.0 14 | # via 15 | # jsonschema 16 | # jupyter-cache 17 | # referencing 18 | babel==2.15.0 19 | # via 20 | # pydata-sphinx-theme 21 | # sphinx 22 | beautifulsoup4==4.12.3 23 | # via pydata-sphinx-theme 24 | breathe==4.35.0 25 | # via rocm-docs-core 26 | certifi==2024.2.2 27 | # via requests 28 | cffi==1.16.0 29 | # via 30 | # cryptography 31 | # pynacl 32 | charset-normalizer==3.3.2 33 | # via requests 34 | click==8.1.7 35 | # via 36 | # jupyter-cache 37 | # sphinx-external-toc 38 | comm==0.2.2 39 | # via ipykernel 40 | cryptography==42.0.7 41 | # via pyjwt 42 | debugpy==1.8.12 43 | # via ipykernel 44 | decorator==5.1.1 45 | # via ipython 46 | deprecated==1.2.14 47 | # via pygithub 48 | docutils==0.21.2 49 | # via 50 | # breathe 51 | # myst-parser 52 | # pydata-sphinx-theme 53 | # sphinx 54 | exceptiongroup==1.2.2 55 | # via ipython 56 | executing==2.2.0 57 | # via stack-data 58 | fastjsonschema==2.19.1 59 | # via 60 | # nbformat 61 | # rocm-docs-core 62 | gitdb==4.0.11 63 | # via gitpython 64 | gitpython==3.1.43 65 | # via rocm-docs-core 66 | greenlet==3.1.1 67 | # via sqlalchemy 68 | idna==3.7 69 | # via requests 70 | imagesize==1.4.1 71 | # via sphinx 72 | importlib-metadata==8.6.1 73 | # via 74 | # jupyter-cache 75 | # myst-nb 76 | ipykernel==6.29.5 77 | # via myst-nb 78 | ipython==8.32.0 79 | # via 80 | # ipykernel 81 | # myst-nb 82 | jedi==0.19.2 83 | # via ipython 84 | jinja2==3.1.4 85 | # via 86 | # myst-parser 87 | # sphinx 88 | jsonschema==4.23.0 89 | # via nbformat 90 | jsonschema-specifications==2024.10.1 91 | # via jsonschema 92 | jupyter-cache==1.0.1 93 | # via myst-nb 94 | jupyter-client==8.6.3 95 | # via 96 | # ipykernel 97 | # nbclient 98 | jupyter-core==5.7.2 99 | # via 100 | # ipykernel 101 | # jupyter-client 102 | # nbclient 103 | # nbformat 104 | markdown-it-py==3.0.0 105 | # via 106 | # mdit-py-plugins 107 | # myst-parser 108 | markupsafe==2.1.5 109 | # via jinja2 110 | matplotlib-inline==0.1.7 111 | # via 112 | # ipykernel 113 | # ipython 114 | mdit-py-plugins==0.4.0 115 | # via myst-parser 116 | mdurl==0.1.2 117 | # via markdown-it-py 118 | myst-nb==1.1.2 119 | # via rocm-docs-core 120 | myst-parser==3.0.1 121 | # via myst-nb 122 | nbclient==0.10.2 123 | # via 124 | # jupyter-cache 125 | # myst-nb 126 | nbformat==5.10.4 127 | # via 128 | # jupyter-cache 129 | # myst-nb 130 | # nbclient 131 | nest-asyncio==1.6.0 132 | # via ipykernel 133 | packaging==24.0 134 | # via 135 | # ipykernel 136 | # pydata-sphinx-theme 137 | # sphinx 138 | parso==0.8.4 139 | # via jedi 140 | pexpect==4.9.0 141 | # via ipython 142 | platformdirs==4.3.6 143 | # via jupyter-core 144 | prompt-toolkit==3.0.50 145 | # via ipython 146 | psutil==6.1.1 147 | # via ipykernel 148 | ptyprocess==0.7.0 149 | # via pexpect 150 | pure-eval==0.2.3 151 | # via stack-data 152 | pycparser==2.22 153 | # via cffi 154 | pydata-sphinx-theme==0.15.2 155 | # via 156 | # rocm-docs-core 157 | # sphinx-book-theme 158 | pygithub==2.3.0 159 | # via rocm-docs-core 160 | pygments==2.18.0 161 | # via 162 | # accessible-pygments 163 | # ipython 164 | # pydata-sphinx-theme 165 | # sphinx 166 | pyjwt[crypto]==2.8.0 167 | # via pygithub 168 | pynacl==1.5.0 169 | # via pygithub 170 | python-dateutil==2.9.0.post0 171 | # via jupyter-client 172 | pyyaml==6.0.1 173 | # via 174 | # jupyter-cache 175 | # myst-nb 176 | # myst-parser 177 | # rocm-docs-core 178 | # sphinx-external-toc 179 | pyzmq==26.2.1 180 | # via 181 | # ipykernel 182 | # jupyter-client 183 | referencing==0.36.2 184 | # via 185 | # jsonschema 186 | # jsonschema-specifications 187 | requests==2.31.0 188 | # via 189 | # pygithub 190 | # sphinx 191 | rocm-docs-core==1.17.0 192 | # via -r requirements.in 193 | rpds-py==0.22.3 194 | # via 195 | # jsonschema 196 | # referencing 197 | six==1.17.0 198 | # via python-dateutil 199 | smmap==5.0.1 200 | # via gitdb 201 | snowballstemmer==2.2.0 202 | # via sphinx 203 | soupsieve==2.5 204 | # via beautifulsoup4 205 | sphinx==7.3.7 206 | # via 207 | # breathe 208 | # myst-nb 209 | # myst-parser 210 | # pydata-sphinx-theme 211 | # rocm-docs-core 212 | # sphinx-book-theme 213 | # sphinx-copybutton 214 | # sphinx-design 215 | # sphinx-external-toc 216 | # sphinx-notfound-page 217 | sphinx-book-theme==1.1.2 218 | # via rocm-docs-core 219 | sphinx-copybutton==0.5.2 220 | # via rocm-docs-core 221 | sphinx-design==0.5.0 222 | # via rocm-docs-core 223 | sphinx-external-toc==1.0.1 224 | # via rocm-docs-core 225 | sphinx-notfound-page==1.0.0 226 | # via rocm-docs-core 227 | sphinxcontrib-applehelp==1.0.8 228 | # via sphinx 229 | sphinxcontrib-devhelp==1.0.6 230 | # via sphinx 231 | sphinxcontrib-htmlhelp==2.0.5 232 | # via sphinx 233 | sphinxcontrib-jsmath==1.0.1 234 | # via sphinx 235 | sphinxcontrib-qthelp==1.0.7 236 | # via sphinx 237 | sphinxcontrib-serializinghtml==1.1.10 238 | # via sphinx 239 | sqlalchemy==2.0.37 240 | # via jupyter-cache 241 | stack-data==0.6.3 242 | # via ipython 243 | tabulate==0.9.0 244 | # via jupyter-cache 245 | tomli==2.0.1 246 | # via sphinx 247 | tornado==6.4.2 248 | # via 249 | # ipykernel 250 | # jupyter-client 251 | traitlets==5.14.3 252 | # via 253 | # comm 254 | # ipykernel 255 | # ipython 256 | # jupyter-client 257 | # jupyter-core 258 | # matplotlib-inline 259 | # nbclient 260 | # nbformat 261 | typing-extensions==4.11.0 262 | # via 263 | # ipython 264 | # myst-nb 265 | # pydata-sphinx-theme 266 | # pygithub 267 | # referencing 268 | # sqlalchemy 269 | urllib3==2.2.1 270 | # via 271 | # pygithub 272 | # requests 273 | wcwidth==0.2.13 274 | # via prompt-toolkit 275 | wrapt==1.16.0 276 | # via deprecated 277 | zipp==3.21.0 278 | # via importlib-metadata 279 | -------------------------------------------------------------------------------- /library/include/hipfft/hipfft-version.h.in: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 - 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | // the configured version and settings 22 | 23 | #ifndef HIPFFT_VERSION_H_ 24 | #define HIPFFT_VERSION_H_ 25 | 26 | // clang-format off 27 | #define hipfftVersionMajor @hipfft_VERSION_MAJOR@ 28 | #define hipfftVersionMinor @hipfft_VERSION_MINOR@ 29 | #define hipfftVersionPatch @hipfft_VERSION_PATCH@ 30 | #define hipfftVersionTweak @hipfft_VERSION_TWEAK@ 31 | // clang-format on 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /library/include/hipfft/hiplibxt.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights 3 | * 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 | #ifndef HIPLIBXT_H_ 25 | #define HIPLIBXT_H_ 26 | 27 | #define MAX_HIP_DESCRIPTOR_GPUS 64 28 | 29 | /*! @struct hipXtDesc_t 30 | * @brief Struct for single-process multi-GPU transform 31 | * 32 | * This struct holds pointers to device memory, including the device 33 | * the memory resides on and the size of each block of memory. 34 | * 35 | * @warning Experimental 36 | */ 37 | typedef struct hipXtDesc_t 38 | { 39 | int version; 40 | // Count of GPUs 41 | int nGPUs; 42 | // Device IDs 43 | int GPUs[MAX_HIP_DESCRIPTOR_GPUS]; 44 | // Data pointers for each GPU 45 | void* data[MAX_HIP_DESCRIPTOR_GPUS]; 46 | // Size of data pointed to, for each GPU 47 | size_t size[MAX_HIP_DESCRIPTOR_GPUS]; 48 | // Internal state 49 | void* hipXtState; 50 | } hipXtDesc; 51 | 52 | typedef enum hiplibFormat_t 53 | { 54 | HIPLIB_FORMAT_HIPFFT = 0x0, 55 | HIPLIB_FORMAT_UNDEFINED = 0x1 56 | } hiplibFormat; 57 | 58 | /*! @struct hipLibXtDesc_t 59 | * @brief Struct for single-process multi-GPU transform 60 | * 61 | * This struct holds \ref hipXtDesc_t structures that define blocks 62 | * of memory for use in a transform. 63 | * 64 | * @warning Experimental 65 | */ 66 | typedef struct hipLibXtDesc_t 67 | { 68 | int version; 69 | // Descriptor of memory layout 70 | hipXtDesc* descriptor; 71 | // Which library is using this format 72 | hiplibFormat library; 73 | // Additional format information specific to the library 74 | int subFormat; 75 | // Other information specific to the library 76 | void* libDescriptor; 77 | } hipLibXtDesc; 78 | 79 | typedef enum hipfftXtCopyType_t 80 | { 81 | HIPFFT_COPY_HOST_TO_DEVICE = 0x00, 82 | HIPFFT_COPY_DEVICE_TO_HOST = 0x01, 83 | HIPFFT_COPY_DEVICE_TO_DEVICE = 0x02, 84 | HIPFFT_COPY_UNDEFINED = 0x03 85 | } hipfftXtCopyType; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /library/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2020 - 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 | if(NOT BUILD_WITH_LIB STREQUAL "CUDA") 24 | # hipFFT source 25 | set(hipfft_source src/amd_detail/hipfft.cpp) 26 | else() 27 | # hipFFT CUDA source 28 | set(hipfft_source src/nvidia_detail/hipfft.cpp) 29 | endif() 30 | -------------------------------------------------------------------------------- /library/src/hipfft-config.cmake.in: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2020 - 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 | # Configure hipfft package to be used in another cmake project. 24 | # 25 | # Defines the following variables: 26 | # 27 | # hipfft_INCLUDE_DIRS - include directories for hipfft 28 | # 29 | # Also defines the library variables below as normal 30 | # variables. These contain debug/optimized keywords when 31 | # a debugging library is found. 32 | # 33 | # Accepts the following variables as input: 34 | # 35 | #----------------------- 36 | # Example Usage: 37 | # 38 | # find_package( hipfft REQUIRED CONFIG 39 | # HINTS /package ) 40 | # 41 | # add_executable( foo foo.cc ) 42 | 43 | # # uses imported targets from package, including setting header paths 44 | # target_link_libraries( foo hipfft ) 45 | # 46 | #----------------------- 47 | 48 | @PACKAGE_INIT@ 49 | 50 | set_and_check( hipfft_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" ) 51 | set_and_check( hipfft_INCLUDE_DIRS "${hipfft_INCLUDE_DIR}" ) 52 | set_and_check( hipfft_LIB_INSTALL_DIR "@PACKAGE_LIB_INSTALL_DIR@" ) 53 | 54 | include( "${CMAKE_CURRENT_LIST_DIR}/hipfft-targets.cmake" ) 55 | -------------------------------------------------------------------------------- /rtest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 0.1 5 | hipfft-test --gtest_color=yes --gtest_output=xml 6 | 7 | {COMMAND}:output_psdb.xml --gtest_filter=-*multi_gpu* --precompile=rocfft-test-precompile.db 8 | 9 | 10 | {COMMAND}:output_osdb.xml --gtest_filter=-*multi_gpu* --precompile=rocfft-test-precompile.db 11 | 12 | 13 | {COMMAND}:output_custom.xml --gtest_filter=-*multi_gpu* 14 | 15 | 16 | -------------------------------------------------------------------------------- /shared/arithmetic.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (C) 2021 - 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 26 | #include 27 | #include 28 | 29 | // arithmetic helper functions 30 | 31 | static inline bool IsPo2(size_t u) 32 | { 33 | return (u != 0) && (0 == (u & (u - 1))); 34 | } 35 | 36 | // help function: Find the smallest power of 2 that is >= n; return its 37 | // power of 2 factor 38 | // e.g., CeilPo2 (7) returns 3 : (2^3 >= 7) 39 | static inline size_t CeilPo2(size_t n) 40 | { 41 | size_t v = 1, t = 0; 42 | while(v < n) 43 | { 44 | v <<= 1; 45 | t++; 46 | } 47 | 48 | return t; 49 | } 50 | 51 | template 52 | static inline T DivRoundingUp(T a, T b) 53 | { 54 | return (a + (b - 1)) / b; 55 | } 56 | 57 | template 58 | typename Titer::value_type product(Titer begin, Titer end) 59 | { 60 | return std::accumulate( 61 | begin, end, typename Titer::value_type(1), std::multiplies()); 62 | } 63 | 64 | // count the number of total iterations for 1-, 2-, and 3-D dimensions 65 | template 66 | static inline size_t count_iters(const T1& i) 67 | { 68 | return i; 69 | } 70 | template 71 | static inline size_t count_iters(const std::tuple& i) 72 | { 73 | return std::get<0>(i) * std::get<1>(i); 74 | } 75 | template 76 | static inline size_t count_iters(const std::tuple& i) 77 | { 78 | return std::get<0>(i) * std::get<1>(i) * std::get<2>(i); 79 | } 80 | -------------------------------------------------------------------------------- /shared/array_predicate.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ROCFFT_ARRAY_PREDICATE_H 22 | #define ROCFFT_ARRAY_PREDICATE_H 23 | 24 | #include "rocfft/rocfft.h" 25 | 26 | namespace 27 | { 28 | bool array_type_is_complex(rocfft_array_type type) 29 | { 30 | return type == rocfft_array_type_complex_interleaved 31 | || type == rocfft_array_type_complex_planar 32 | || type == rocfft_array_type_hermitian_interleaved 33 | || type == rocfft_array_type_hermitian_planar; 34 | } 35 | bool array_type_is_interleaved(rocfft_array_type type) 36 | { 37 | return type == rocfft_array_type_complex_interleaved 38 | || type == rocfft_array_type_hermitian_interleaved; 39 | } 40 | bool array_type_is_planar(rocfft_array_type type) 41 | { 42 | return type == rocfft_array_type_complex_planar 43 | || type == rocfft_array_type_hermitian_planar; 44 | } 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /shared/array_validator.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ARRAY_VALIDATOR_H 22 | #define ARRAY_VALIDATOR_H 23 | 24 | #include 25 | 26 | // Checks whether the array with given length and stride has multi-index collisions. 27 | bool array_valid(const std::vector& length, 28 | const std::vector& stride, 29 | const int verbose = 0); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /shared/client_except.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ROCFFT_CLIENT_EXCEPT_H 22 | #define ROCFFT_CLIENT_EXCEPT_H 23 | 24 | #include 25 | 26 | // exception type to throw when we want to skip a problem 27 | struct ROCFFT_SKIP 28 | { 29 | const std::string msg; 30 | ROCFFT_SKIP(std::string&& s) 31 | : msg(std::move(s)) 32 | { 33 | } 34 | ROCFFT_SKIP(const std::string& s) 35 | : msg(s) 36 | { 37 | } 38 | }; 39 | 40 | // exception type to throw when we want to consider a problem failed 41 | struct ROCFFT_FAIL 42 | { 43 | const std::string msg; 44 | ROCFFT_FAIL(std::string&& s) 45 | : msg(std::move(s)) 46 | { 47 | } 48 | ROCFFT_FAIL(const std::string& s) 49 | : msg(s) 50 | { 51 | } 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /shared/concurrency.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #ifndef WIN32 26 | #include 27 | #endif 28 | 29 | // work out how many parallel tasks to run, based on available 30 | // resources. on Linux, this will look at the cpu affinity mask (if 31 | // available) which might be restricted in a container. otherwise, 32 | // return std::thread::hardware_concurrency(). 33 | static unsigned int rocfft_concurrency() 34 | { 35 | #ifndef WIN32 36 | cpu_set_t cpuset; 37 | if(sched_getaffinity(0, sizeof(cpuset), &cpuset) == 0) 38 | return CPU_COUNT(&cpuset); 39 | #endif 40 | return std::thread::hardware_concurrency(); 41 | } 42 | -------------------------------------------------------------------------------- /shared/device_properties.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ROCFFT_DEVICE_PROPS_H 22 | #define ROCFFT_DEVICE_PROPS_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | // get device properties 29 | static hipDeviceProp_t get_curr_device_prop() 30 | { 31 | hipDeviceProp_t prop; 32 | int deviceId = 0; 33 | if(hipGetDevice(&deviceId) != hipSuccess) 34 | throw std::runtime_error("hipGetDevice failed."); 35 | 36 | if(hipGetDeviceProperties(&prop, deviceId) != hipSuccess) 37 | throw std::runtime_error("hipGetDeviceProperties failed for deviceId " 38 | + std::to_string(deviceId)); 39 | 40 | return prop; 41 | } 42 | 43 | // check that the given grid/block dims will fit into the limits in 44 | // the device properties. throws std::runtime_error if the limits 45 | // are exceeded. 46 | static void launch_limits_check(const std::string& kernel_name, 47 | const dim3 gridDim, 48 | const dim3 blockDim, 49 | const hipDeviceProp_t& deviceProp) 50 | { 51 | // Need lots of casting here because dim3 is unsigned but device 52 | // props are signed. Cast direct comparisons to fix signedness 53 | // issues. Promote types to 64-bit when multiplying to try to 54 | // avoid overflow. 55 | 56 | // Block limits along each dimension 57 | if(blockDim.x > static_cast(deviceProp.maxThreadsDim[0]) 58 | || blockDim.y > static_cast(deviceProp.maxThreadsDim[1]) 59 | || blockDim.z > static_cast(deviceProp.maxThreadsDim[2])) 60 | throw std::runtime_error("max threads per dim exceeded: " + kernel_name); 61 | 62 | // Total threads for the whole block 63 | if(static_cast(blockDim.x) * blockDim.y * blockDim.z 64 | > static_cast(deviceProp.maxThreadsPerBlock)) 65 | throw std::runtime_error("max threads per block exceeded: " + kernel_name); 66 | 67 | // Grid dimension limits 68 | if(gridDim.x > static_cast(deviceProp.maxGridSize[0]) 69 | || gridDim.y > static_cast(deviceProp.maxGridSize[1]) 70 | || gridDim.z > static_cast(deviceProp.maxGridSize[2])) 71 | throw std::runtime_error("max grid size exceeded: " + kernel_name); 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /shared/enum_to_string.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ENUM_TO_STRING_H 22 | #define ENUM_TO_STRING_H 23 | 24 | #include "fft_params.h" 25 | 26 | // Return the string of the hipError code. 27 | static std::string hipError_to_string(const hipError_t ret) 28 | { 29 | switch(ret) 30 | { 31 | case hipSuccess: 32 | return "hipSuccess"; 33 | case hipErrorInvalidContext: 34 | return "hipErrorInvalidContext"; 35 | case hipErrorInvalidKernelFile: 36 | return "hipErrorInvalidKernelFile"; 37 | case hipErrorMemoryAllocation: 38 | return "hipErrorMemoryAllocation"; 39 | case hipErrorInitializationError: 40 | return "hipErrorInitializationError"; 41 | case hipErrorLaunchFailure: 42 | return "hipErrorLaunchFailure"; 43 | case hipErrorLaunchOutOfResources: 44 | return "hipErrorLaunchOutOfResources"; 45 | case hipErrorInvalidDevice: 46 | return "hipErrorInvalidDevice"; 47 | case hipErrorInvalidValue: 48 | return "hipErrorInvalidValue"; 49 | case hipErrorInvalidDevicePointer: 50 | return "hipErrorInvalidDevicePointer"; 51 | case hipErrorInvalidMemcpyDirection: 52 | return "hipErrorInvalidMemcpyDirection"; 53 | case hipErrorUnknown: 54 | return "hipErrorUnknown"; 55 | case hipErrorInvalidResourceHandle: 56 | return "hipErrorInvalidResourceHandle"; 57 | case hipErrorNotReady: 58 | return "hipErrorNotReady"; 59 | case hipErrorNoDevice: 60 | return "hipErrorNoDevice"; 61 | case hipErrorPeerAccessAlreadyEnabled: 62 | return "hipErrorPeerAccessAlreadyEnabled"; 63 | case hipErrorPeerAccessNotEnabled: 64 | return "hipErrorPeerAccessNotEnabled"; 65 | case hipErrorRuntimeMemory: 66 | return "hipErrorRuntimeMemory"; 67 | case hipErrorRuntimeOther: 68 | return "hipErrorRuntimeOther"; 69 | case hipErrorHostMemoryAlreadyRegistered: 70 | return "hipErrorHostMemoryAlreadyRegistered"; 71 | case hipErrorHostMemoryNotRegistered: 72 | return "hipErrorHostMemoryNotRegistered"; 73 | case hipErrorMapBufferObjectFailed: 74 | return "hipErrorMapBufferObjectFailed"; 75 | case hipErrorTbd: 76 | return "hipErrorTbd"; 77 | default: 78 | throw std::runtime_error("unknown hipError"); 79 | } 80 | } 81 | #endif 82 | -------------------------------------------------------------------------------- /shared/environment.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | // wrappers around environment variable routines 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | // Windows provides "getenv" and "_putenv", but those modify the 28 | // runtime's copy of the environment. The actual environment in the 29 | // process control block is accessed using GetEnvironmentVariable and 30 | // SetEnvironmentVariable. 31 | 32 | #ifdef WIN32 33 | #include 34 | static void rocfft_setenv(const char* var, const char* value) 35 | { 36 | SetEnvironmentVariable(var, value); 37 | } 38 | static void rocfft_unsetenv(const char* var) 39 | { 40 | SetEnvironmentVariable(var, nullptr); 41 | } 42 | static std::string rocfft_getenv(const char* var) 43 | { 44 | DWORD size = GetEnvironmentVariable(var, nullptr, 0); 45 | std::string ret; 46 | if(size) 47 | { 48 | ret.resize(size); 49 | GetEnvironmentVariable(var, ret.data(), size); 50 | // GetEnvironmentVariable counts the terminating null, so remove it 51 | while(!ret.empty() && ret.back() == 0) 52 | ret.pop_back(); 53 | } 54 | return ret; 55 | } 56 | 57 | #else 58 | 59 | #include 60 | 61 | static void rocfft_setenv(const char* var, const char* value) 62 | { 63 | setenv(var, value, 1); 64 | } 65 | static void rocfft_unsetenv(const char* var) 66 | { 67 | unsetenv(var); 68 | } 69 | static std::string rocfft_getenv(const char* var) 70 | { 71 | auto value = getenv(var); 72 | return value ? value : ""; 73 | } 74 | #endif 75 | 76 | // RAII object to set an environment variable and restore it to its 77 | // previous value on destruction 78 | struct EnvironmentSetTemp 79 | { 80 | EnvironmentSetTemp(const char* _var, const char* val) 81 | : var(_var) 82 | { 83 | auto val_ptr = rocfft_getenv(_var); 84 | if(!val_ptr.empty()) 85 | oldvalue = val_ptr; 86 | rocfft_setenv(_var, val); 87 | } 88 | ~EnvironmentSetTemp() 89 | { 90 | if(oldvalue.empty()) 91 | rocfft_unsetenv(var.c_str()); 92 | else 93 | rocfft_setenv(var.c_str(), oldvalue.c_str()); 94 | } 95 | std::string var; 96 | std::string oldvalue; 97 | }; 98 | -------------------------------------------------------------------------------- /shared/gpubuf.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 - 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ROCFFT_GPUBUF_H 22 | #define ROCFFT_GPUBUF_H 23 | 24 | #include "rocfft_hip.h" 25 | #include 26 | 27 | // Simple RAII class for GPU buffers. T is the type of pointer that 28 | // data() returns 29 | template 30 | class gpubuf_t 31 | { 32 | public: 33 | gpubuf_t() {} 34 | // buffers are movable but not copyable 35 | gpubuf_t(gpubuf_t&& other) 36 | { 37 | std::swap(buf, other.buf); 38 | std::swap(owned, other.owned); 39 | std::swap(bsize, other.bsize); 40 | std::swap(device, other.device); 41 | } 42 | gpubuf_t& operator=(gpubuf_t&& other) 43 | { 44 | std::swap(buf, other.buf); 45 | std::swap(owned, other.owned); 46 | std::swap(bsize, other.bsize); 47 | std::swap(device, other.device); 48 | return *this; 49 | } 50 | gpubuf_t(const gpubuf_t&) = delete; 51 | gpubuf_t& operator=(const gpubuf_t&) = delete; 52 | 53 | static gpubuf_t make_nonowned(T* p, size_t size_bytes = 0) 54 | { 55 | gpubuf_t ret; 56 | ret.owned = false; 57 | ret.buf = p; 58 | ret.bsize = size_bytes; 59 | return ret; 60 | } 61 | 62 | ~gpubuf_t() 63 | { 64 | free(); 65 | } 66 | 67 | static bool use_alloc_managed() 68 | { 69 | return std::getenv("ROCFFT_MALLOC_MANAGED"); 70 | } 71 | 72 | hipError_t alloc(const size_t size) 73 | { 74 | // remember the device that was current as of alloc, so we can 75 | // free on the correct device 76 | auto ret = hipGetDevice(&device); 77 | if(ret != hipSuccess) 78 | return ret; 79 | 80 | bsize = size; 81 | static bool alloc_managed = use_alloc_managed(); 82 | free(); 83 | ret = alloc_managed ? hipMallocManaged(&buf, bsize) : hipMalloc(&buf, bsize); 84 | if(ret != hipSuccess) 85 | { 86 | buf = nullptr; 87 | bsize = 0; 88 | } 89 | return ret; 90 | } 91 | 92 | size_t size() const 93 | { 94 | return bsize; 95 | } 96 | 97 | void free() 98 | { 99 | if(buf != nullptr) 100 | { 101 | if(owned) 102 | { 103 | // free on the device we allocated on 104 | rocfft_scoped_device dev(device); 105 | (void)hipFree(buf); 106 | } 107 | buf = nullptr; 108 | bsize = 0; 109 | } 110 | owned = true; 111 | } 112 | 113 | // return a pointer to the allocated memory, offset by the 114 | // specified number of bytes 115 | T* data_offset(size_t offset_bytes = 0) const 116 | { 117 | void* ptr = static_cast(buf) + offset_bytes; 118 | return static_cast(ptr); 119 | } 120 | 121 | T* data() const 122 | { 123 | return static_cast(buf); 124 | } 125 | 126 | // equality/bool tests 127 | bool operator==(std::nullptr_t n) const 128 | { 129 | return buf == n; 130 | } 131 | bool operator!=(std::nullptr_t n) const 132 | { 133 | return buf != n; 134 | } 135 | operator bool() const 136 | { 137 | return buf; 138 | } 139 | 140 | private: 141 | // The GPU buffer 142 | void* buf = nullptr; 143 | // whether this object owns the 'buf' pointer (and hence needs to 144 | // free it) 145 | bool owned = true; 146 | size_t bsize = 0; 147 | int device = 0; 148 | }; 149 | 150 | // default gpubuf that gives out void* pointers 151 | typedef gpubuf_t<> gpubuf; 152 | #endif 153 | -------------------------------------------------------------------------------- /shared/hip_object_wrapper.h: -------------------------------------------------------------------------------- 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 | #ifndef ROCFFT_HIP_OBJ_WRAPPER_H 24 | #define ROCFFT_HIP_OBJ_WRAPPER_H 25 | 26 | #include "rocfft_hip.h" 27 | 28 | // RAII wrapper around HIP objects 29 | template 30 | struct hip_object_wrapper_t 31 | { 32 | hip_object_wrapper_t() 33 | : obj(nullptr) 34 | { 35 | } 36 | 37 | void alloc() 38 | { 39 | if(obj == nullptr && TCreate(&obj) != hipSuccess) 40 | throw std::runtime_error("hip create failure"); 41 | } 42 | 43 | void free() 44 | { 45 | if(obj) 46 | { 47 | (void)TDestroy(obj); 48 | obj = nullptr; 49 | } 50 | } 51 | 52 | operator const T&() const 53 | { 54 | return obj; 55 | } 56 | operator T&() 57 | { 58 | return obj; 59 | } 60 | 61 | operator bool() const 62 | { 63 | return obj != nullptr; 64 | } 65 | 66 | ~hip_object_wrapper_t() 67 | { 68 | free(); 69 | } 70 | 71 | hip_object_wrapper_t(const hip_object_wrapper_t&) = delete; 72 | hip_object_wrapper_t& operator=(const hip_object_wrapper_t&) = delete; 73 | hip_object_wrapper_t(hip_object_wrapper_t&& other) 74 | : obj(other.obj) 75 | { 76 | other.obj = nullptr; 77 | } 78 | 79 | private: 80 | T obj; 81 | }; 82 | 83 | typedef hip_object_wrapper_t hipStream_wrapper_t; 84 | typedef hip_object_wrapper_t hipEvent_wrapper_t; 85 | 86 | #endif // ROCFFT_HIP_OBJ_WRAPPER_H 87 | -------------------------------------------------------------------------------- /shared/hipfft_brick.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef HIPFFT_BRICK_H 22 | #define HIPFFT_BRICK_H 23 | 24 | #include "ptrdiff.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | // column-major ordering on indexes + strides, since these get passed 32 | // directly to rocFFT 33 | struct hipfft_brick 34 | { 35 | // device that the brick lives on 36 | int device = 0; 37 | 38 | std::vector field_lower; 39 | std::vector field_upper; 40 | std::vector brick_stride; 41 | 42 | size_t min_size = 0; 43 | 44 | // compute the length of this brick 45 | std::vector length() const 46 | { 47 | std::vector ret; 48 | for(size_t i = 0; i < field_lower.size(); ++i) 49 | ret.push_back(field_upper[i] - field_lower[i]); 50 | return ret; 51 | } 52 | 53 | // given a (column-major) brick index, return the offset in the field 54 | size_t field_offset(const std::vector& brick_idx, 55 | const std::vector& field_stride) const 56 | { 57 | // find the index in the field 58 | std::vector field_idx; 59 | for(size_t i = 0; i < brick_idx.size(); ++i) 60 | field_idx.push_back(brick_idx[i] + field_lower[i]); 61 | 62 | // based on the field's strides, return offset 63 | return std::inner_product(field_idx.begin(), field_idx.end(), field_stride.begin(), 0); 64 | } 65 | 66 | // given a (column-major) brick index, return the offset in this brick 67 | size_t brick_offset(const std::vector& brick_idx) const 68 | { 69 | // based on the brick's strides, return offset 70 | return std::inner_product(brick_idx.begin(), brick_idx.end(), brick_stride.begin(), 0); 71 | } 72 | 73 | // set contiguous strides on this brick 74 | void set_contiguous_stride() 75 | { 76 | brick_stride = {1}; 77 | auto len = length(); 78 | for(size_t i = 0; i < len.size() - 1; ++i) 79 | brick_stride.push_back(brick_stride[i] * len[i]); 80 | } 81 | }; 82 | 83 | // lengths include batch dimension (col-major), split_dim is counted with 0 = fastest dim. 84 | static void set_bricks(const std::vector& length, 85 | std::vector& bricks, 86 | const size_t split_dim) 87 | { 88 | const size_t dim = length.size(); 89 | 90 | for(size_t i = 0; i < bricks.size(); ++i) 91 | { 92 | auto& brick = bricks[i]; 93 | 94 | // lower idx starts at origin, upper is one-past-the-end 95 | brick.field_lower.resize(dim); 96 | std::fill(brick.field_lower.begin(), brick.field_lower.end(), 0); 97 | brick.field_upper = length; 98 | 99 | // length of the brick along the split dimension 100 | size_t split_len = length[split_dim] / bricks.size(); 101 | brick.field_lower[split_dim] = split_len * i; 102 | if(i != bricks.size() - 1) 103 | brick.field_upper[split_dim] = brick.field_lower[split_dim] + split_len; 104 | brick.set_contiguous_stride(); 105 | 106 | // work out how big a buffer we need to allocate 107 | std::vector brick_len(dim); 108 | for(size_t d = 0; d < dim; ++d) 109 | brick_len[d] = brick.field_upper[d] - brick.field_lower[d]; 110 | brick.min_size 111 | = std::max(brick.min_size, compute_ptrdiff(brick_len, brick.brick_stride, 0, 0)); 112 | } 113 | } 114 | 115 | // length/strides are column-major. in/out brick vectors are 116 | // allocated by caller, but coordinates/strides of those bricks are 117 | // filled in by this function 118 | static void set_io_bricks(const std::vector& inLength, 119 | const std::vector& outLength, 120 | size_t batch, 121 | std::vector& inBricks, 122 | std::vector& outBricks) 123 | { 124 | std::vector inLengthWithBatch = inLength; 125 | inLengthWithBatch.push_back(batch); 126 | std::vector outLengthWithBatch = outLength; 127 | outLengthWithBatch.push_back(batch); 128 | 129 | // for batched FFT, split input on batch, otherwise split input 130 | // on fastest FFT dim and output on slowest FFT dim 131 | const size_t in_split_dim 132 | = batch > 1 ? inLengthWithBatch.size() - 1 : inLengthWithBatch.size() - 2; 133 | const size_t out_split_dim 134 | = batch > 1 ? outLengthWithBatch.size() - 1 : outLengthWithBatch.size() - 2; 135 | 136 | set_bricks(inLengthWithBatch, inBricks, in_split_dim); 137 | set_bricks(outLengthWithBatch, outBricks, out_split_dim); 138 | } 139 | 140 | #endif 141 | -------------------------------------------------------------------------------- /shared/increment.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ROCFFT_INCREMENT_H 22 | #define ROCFFT_INCREMENT_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | // Helper functions to iterate over a buffer in row-major order. 29 | // Indexes may be given as either a tuple or vector of sizes. They 30 | // return true if the index was successfully incremented to move to 31 | // the next element in the buffer. 32 | 33 | template 34 | static bool increment_base(T1& index, const T2& length) 35 | { 36 | static_assert(std::is_integral::value, "Integral required."); 37 | static_assert(std::is_integral::value, "Integral required."); 38 | if(index < length - 1) 39 | { 40 | ++index; 41 | return true; 42 | } 43 | index = 0; 44 | return false; 45 | } 46 | 47 | // Increment the index (row-major) for looping over 1, 2, and 3 dimensions length. 48 | template 49 | static bool increment_rowmajor(T1& index, const T2& length) 50 | { 51 | static_assert(std::is_integral::value, "Integral required."); 52 | static_assert(std::is_integral::value, "Integral required."); 53 | return increment_base(index, length); 54 | } 55 | 56 | template 57 | static bool increment_rowmajor(std::tuple& index, const std::tuple& length) 58 | { 59 | if(increment_base(std::get<1>(index), std::get<1>(length))) 60 | // we incremented ok, nothing further to do 61 | return true; 62 | // otherwise, we rolled over 63 | return increment_base(std::get<0>(index), std::get<0>(length)); 64 | } 65 | 66 | template 67 | static bool increment_rowmajor(std::tuple& index, const std::tuple& length) 68 | { 69 | if(increment_base(std::get<2>(index), std::get<2>(length))) 70 | // we incremented ok, nothing further to do 71 | return true; 72 | if(increment_base(std::get<1>(index), std::get<1>(length))) 73 | // we incremented ok, nothing further to do 74 | return true; 75 | // otherwise, we rolled over 76 | return increment_base(std::get<0>(index), std::get<0>(length)); 77 | } 78 | 79 | // Increment row-major index over arbitrary dimension length 80 | template 81 | bool increment_rowmajor(std::vector& index, const std::vector& length) 82 | { 83 | for(int idim = length.size(); idim-- > 0;) 84 | { 85 | if(index[idim] < length[idim]) 86 | { 87 | if((++index[idim]) == length[idim]) 88 | { 89 | index[idim] = 0; 90 | continue; 91 | } 92 | // we know we were able to increment something and didn't hit the end 93 | return true; 94 | } 95 | } 96 | // End the loop when we get back to the start: 97 | return !std::all_of(index.begin(), index.end(), [](int i) { return i == 0; }); 98 | } 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /shared/precision_type.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ROCFFT_PRECISION_TYPE_H 22 | #define ROCFFT_PRECISION_TYPE_H 23 | 24 | #include "array_predicate.h" 25 | #include "rocfft/rocfft.h" 26 | 27 | static size_t real_type_size(rocfft_precision precision) 28 | { 29 | switch(precision) 30 | { 31 | case rocfft_precision_half: 32 | return 2; 33 | case rocfft_precision_single: 34 | return 4; 35 | case rocfft_precision_double: 36 | return 8; 37 | } 38 | } 39 | 40 | static size_t complex_type_size(rocfft_precision precision) 41 | { 42 | return real_type_size(precision) * 2; 43 | } 44 | 45 | static const char* precision_name(rocfft_precision precision) 46 | { 47 | switch(precision) 48 | { 49 | case rocfft_precision_half: 50 | return "half"; 51 | case rocfft_precision_single: 52 | return "single"; 53 | case rocfft_precision_double: 54 | return "double"; 55 | } 56 | } 57 | 58 | static size_t element_size(rocfft_precision precision, rocfft_array_type array_type) 59 | { 60 | return array_type_is_complex(array_type) ? complex_type_size(precision) 61 | : real_type_size(precision); 62 | } 63 | 64 | // offset a pointer by a number of elements, given the elements' 65 | // precision and type (complex or not) 66 | static void* ptr_offset(void* p, size_t elems, rocfft_precision precision, rocfft_array_type type) 67 | { 68 | return static_cast(p) + elems * element_size(precision, type); 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /shared/printbuffer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 - 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef PRINTBUFFER_H 22 | #define PRINTBUFFER_H 23 | 24 | #include "hostbuf.h" 25 | #include "increment.h" 26 | #include 27 | #include 28 | 29 | // Output a formatted general-dimensional array with given length and stride in batches 30 | // separated by dist. 31 | template 32 | inline void printbuffer(const Toutput* output, 33 | const std::vector& length, 34 | const std::vector& stride, 35 | const Tsize nbatch, 36 | const Tsize dist, 37 | const size_t offset, 38 | Tstream& stream) 39 | { 40 | auto i_base = 0; 41 | for(unsigned int b = 0; b < nbatch; b++, i_base += dist) 42 | { 43 | std::vector index(length.size()); 44 | std::fill(index.begin(), index.end(), 0); 45 | do 46 | { 47 | const int i 48 | = std::inner_product(index.begin(), index.end(), stride.begin(), i_base + offset); 49 | stream << output[i] << " "; 50 | for(int li = index.size(); li-- > 0;) 51 | { 52 | if(index[li] == (length[li] - 1)) 53 | { 54 | stream << "\n"; 55 | } 56 | else 57 | { 58 | break; 59 | } 60 | } 61 | } while(increment_rowmajor(index, length)); 62 | stream << std::endl; 63 | } 64 | } 65 | 66 | template 67 | class buffer_printer 68 | { 69 | // The scalar versions might be part of a planar format. 70 | public: 71 | template 72 | static void print_buffer(const std::vector& buf, 73 | const std::vector& length, 74 | const std::vector& stride, 75 | const Tsize nbatch, 76 | const Tsize dist, 77 | const std::vector& offset, 78 | Tstream& stream = std::cout) 79 | { 80 | for(const auto& vec : buf) 81 | { 82 | printbuffer(reinterpret_cast(vec.data()), 83 | length, 84 | stride, 85 | nbatch, 86 | dist, 87 | offset[0], 88 | stream); 89 | } 90 | }; 91 | template 92 | static void print_buffer_flat(const std::vector& buf, 93 | const std::vector& size, 94 | const std::vector& offset, 95 | Tstream& stream = std::cout) 96 | { 97 | for(const auto& vec : buf) 98 | { 99 | auto data = reinterpret_cast(vec.data()); 100 | stream << "idx " << 0; 101 | for(size_t i = 0; i < size[0]; ++i) 102 | stream << " " << data[i]; 103 | stream << std::endl; 104 | } 105 | }; 106 | }; 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /shared/ptrdiff.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | // Compute the farthest point from the original pointer. 26 | static size_t compute_ptrdiff(const std::vector& length, 27 | const std::vector& stride, 28 | const size_t nbatch, 29 | const size_t dist) 30 | { 31 | size_t val = 0; 32 | if(!length.empty()) 33 | { 34 | val = 1; 35 | for(unsigned int i = 0; i < length.size(); ++i) 36 | { 37 | val += (length[i] - 1) * stride[i]; 38 | } 39 | val += (nbatch - 1) * dist; 40 | } 41 | return val; 42 | } 43 | -------------------------------------------------------------------------------- /shared/rocfft_accuracy_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 - 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ROCFFT_ACCURACY_TEST 22 | #define ROCFFT_ACCURACY_TEST 23 | 24 | #include "accuracy_test.h" 25 | #include "rocfft_params.h" 26 | 27 | void fft_vs_reference(rocfft_params& params, bool round_trip = false); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /shared/rocfft_hip.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef __ROCFFT_HIP_H__ 22 | #define __ROCFFT_HIP_H__ 23 | 24 | #include 25 | #include 26 | 27 | class rocfft_scoped_device 28 | { 29 | public: 30 | rocfft_scoped_device(int device) 31 | { 32 | if(hipGetDevice(&orig_device) != hipSuccess) 33 | throw std::runtime_error("hipGetDevice failure"); 34 | 35 | if(hipSetDevice(device) != hipSuccess) 36 | throw std::runtime_error("hipSetDevice failure"); 37 | } 38 | ~rocfft_scoped_device() 39 | { 40 | (void)hipSetDevice(orig_device); 41 | } 42 | 43 | // not copyable or movable 44 | rocfft_scoped_device(const rocfft_scoped_device&) = delete; 45 | rocfft_scoped_device(rocfft_scoped_device&&) = delete; 46 | rocfft_scoped_device& operator=(const rocfft_scoped_device&) = delete; 47 | 48 | private: 49 | int orig_device; 50 | }; 51 | 52 | #endif // __ROCFFT_HIP_H__ 53 | -------------------------------------------------------------------------------- /shared/sys_mem.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef SYSMEM_H 22 | #define SYSMEM_H 23 | 24 | #include 25 | #include 26 | 27 | #include "device_properties.h" 28 | 29 | #ifdef WIN32 30 | #include 31 | #else 32 | #include 33 | #endif 34 | 35 | static constexpr size_t ONE_GiB = 1 << 30; 36 | 37 | inline size_t bytes_to_GiB(const size_t bytes) 38 | { 39 | return bytes == 0 ? 0 : (bytes - 1 + ONE_GiB) / ONE_GiB; 40 | } 41 | 42 | struct host_memory 43 | { 44 | public: 45 | // acquire a reference to a singleton of this struct 46 | static host_memory& singleton() 47 | { 48 | static host_memory mem; 49 | return mem; 50 | } 51 | 52 | size_t get_total_bytes() 53 | { 54 | return total_bytes; 55 | } 56 | 57 | size_t get_total_gbytes() 58 | { 59 | return bytes_to_GiB(get_total_bytes()); 60 | } 61 | 62 | void set_limit_bytes(size_t limit_bytes_) 63 | { 64 | // Don't let limit use the total available memory, leave at 65 | // least a 1GiB buffer, otherwise process may get OOM killed. 66 | limit_bytes 67 | = limit_bytes_ > (total_bytes - ONE_GiB) ? (total_bytes - ONE_GiB) : limit_bytes_; 68 | } 69 | 70 | void set_limit_gbytes(size_t limit_gbytes_) 71 | { 72 | set_limit_bytes(limit_gbytes_ * ONE_GiB); 73 | } 74 | 75 | size_t get_usable_bytes() 76 | { 77 | update(); 78 | 79 | // Limit the amount of usable memory. If we are too aggressive 80 | // with host memory usage, the host process may get OOM killed 81 | // on systems with little or no swap space. 82 | auto usable_bytes = free_bytes < ONE_GiB ? 0 : free_bytes; 83 | usable_bytes = usable_bytes > limit_bytes ? limit_bytes : usable_bytes; 84 | 85 | return usable_bytes; 86 | } 87 | 88 | size_t get_usable_gbytes() 89 | { 90 | return bytes_to_GiB(get_usable_bytes()); 91 | } 92 | 93 | private: 94 | size_t total_bytes = 0; 95 | size_t free_bytes = 0; 96 | size_t limit_bytes = 0; 97 | 98 | host_memory() 99 | { 100 | update(); 101 | set_limit_bytes(total_bytes); 102 | } 103 | 104 | void update() 105 | { 106 | #ifdef WIN32 107 | MEMORYSTATUSEX info; 108 | info.dwLength = sizeof(info); 109 | if(!GlobalMemoryStatusEx(&info)) 110 | return; 111 | total_bytes = info.ullTotalPhys; 112 | free_bytes = info.ullAvailPhys; 113 | #else 114 | struct sysinfo info; 115 | if(sysinfo(&info) != 0) 116 | return; 117 | total_bytes = info.totalram * info.mem_unit; 118 | free_bytes = info.freeram * info.mem_unit; 119 | 120 | // top-level memory cgroup may restrict this further 121 | 122 | // check cgroup v1 123 | std::ifstream memcg1_limit_file("/sys/fs/cgroup/memory/memory.limit_in_bytes"); 124 | std::ifstream memcg1_usage_file("/sys/fs/cgroup/memory/memory.usage_in_bytes"); 125 | size_t memcg1_limit_bytes; 126 | size_t memcg1_usage_bytes; 127 | // use cgroupv1 limit if we can read the cgroup files and it's 128 | // smaller 129 | if((memcg1_limit_file >> memcg1_limit_bytes) && (memcg1_usage_file >> memcg1_usage_bytes)) 130 | { 131 | total_bytes = std::min(total_bytes, memcg1_limit_bytes); 132 | free_bytes = total_bytes - memcg1_usage_bytes; 133 | } 134 | 135 | // check cgroup v2 136 | std::ifstream memcg2_max_file("/sys/fs/cgroup/memory.max"); 137 | std::ifstream memcg2_current_file("/sys/fs/cgroup/memory.current"); 138 | size_t memcg2_max_bytes; 139 | size_t memcg2_current_bytes; 140 | // use cgroupv2 limit if we can read the cgroup files and it's 141 | // smaller 142 | if((memcg2_max_file >> memcg2_max_bytes) && (memcg2_current_file >> memcg2_current_bytes)) 143 | { 144 | total_bytes = std::min(total_bytes, memcg2_max_bytes); 145 | free_bytes = total_bytes - memcg2_current_bytes; 146 | } 147 | 148 | #endif 149 | 150 | try 151 | { 152 | auto deviceProp = get_curr_device_prop(); 153 | // on integrated APU, we can't expect to reuse "device" memory 154 | // for "host" things. 155 | if(deviceProp.integrated) 156 | { 157 | total_bytes -= deviceProp.totalGlobalMem; 158 | } 159 | } 160 | catch(std::runtime_error&) 161 | { 162 | // assume we're not on APU, can use full host memory 163 | } 164 | } 165 | }; 166 | 167 | #endif // SYSMEM_H 168 | -------------------------------------------------------------------------------- /shared/test_params.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 - 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #pragma once 22 | #ifndef TESTCONSTANTS_H 23 | #define TESTCONSTANTS_H 24 | 25 | #include 26 | 27 | extern int verbose; 28 | extern size_t ramgb; 29 | extern size_t vramgb; 30 | 31 | extern size_t n_random_tests; 32 | 33 | extern size_t random_seed; 34 | extern double test_prob; 35 | extern double emulation_prob; 36 | extern double complex_interleaved_prob_factor; 37 | extern double real_prob_factor; 38 | extern double complex_planar_prob_factor; 39 | extern double callback_prob_factor; 40 | 41 | extern double half_epsilon; 42 | extern double single_epsilon; 43 | extern double double_epsilon; 44 | extern bool skip_runtime_fails; 45 | 46 | extern double max_linf_eps_double; 47 | extern double max_l2_eps_double; 48 | extern double max_linf_eps_single; 49 | extern double max_l2_eps_single; 50 | extern double max_linf_eps_half; 51 | extern double max_l2_eps_half; 52 | 53 | extern int n_hip_failures; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /shared/work_queue.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include 26 | template 27 | struct WorkQueue 28 | { 29 | void push(_WorkItem&& i) 30 | { 31 | std::unique_lock lock(queueMutex); 32 | items.emplace(std::move(i)); 33 | emptyWait.notify_all(); 34 | } 35 | _WorkItem pop() 36 | { 37 | std::unique_lock lock(queueMutex); 38 | while(items.empty()) 39 | emptyWait.wait(lock); 40 | _WorkItem item(items.front()); 41 | items.pop(); 42 | return item; 43 | } 44 | 45 | private: 46 | std::queue<_WorkItem> items; 47 | std::mutex queueMutex; 48 | std::condition_variable emptyWait; 49 | }; 50 | -------------------------------------------------------------------------------- /toolchain-linux.cmake: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2021 - 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 | if (DEFINED ENV{ROCM_PATH}) 24 | set(rocm_bin "$ENV{ROCM_PATH}/bin") 25 | else() 26 | set(rocm_bin "/opt/rocm/bin") 27 | set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to the ROCm installation.") 28 | endif() 29 | 30 | if (NOT DEFINED ENV{CXX}) 31 | set(CMAKE_CXX_COMPILER "${rocm_bin}/amdclang++") 32 | else() 33 | set(CMAKE_CXX_COMPILER "$ENV{CXX}") 34 | endif() 35 | -------------------------------------------------------------------------------- /toolchain-windows.cmake: -------------------------------------------------------------------------------- 1 | # ############################################################################# 2 | # Copyright (C) 2021 - 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 | if (DEFINED ENV{HIP_PATH}) 24 | file(TO_CMAKE_PATH "$ENV{HIP_PATH}" HIP_DIR) 25 | set(rocm_bin "${HIP_DIR}/bin") 26 | elseif (DEFINED ENV{HIP_DIR}) 27 | file(TO_CMAKE_PATH "$ENV{HIP_DIR}" HIP_DIR) 28 | set(rocm_bin "${HIP_DIR}/bin") 29 | else() 30 | set(HIP_DIR "C:/hip") 31 | set(rocm_bin "C:/hip/bin") 32 | endif() 33 | 34 | set(CMAKE_CXX_COMPILER "${rocm_bin}/clang++.exe") 35 | set(CMAKE_C_COMPILER "${rocm_bin}/clang.exe") 36 | 37 | # our usage flags 38 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32 -D_CRT_SECURE_NO_WARNINGS") 39 | 40 | # flags for clang direct use 41 | 42 | # -Wno-ignored-attributes to avoid warning: __declspec attribute 'dllexport' is not supported [-Wignored-attributes] which is used by msvc compiler 43 | # -Wno-unknown-attributes to avoid warning: unknown attribute '__dllimport__' ignored [-Wunknown-attributes], in boost 44 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-attributes -Wno-unknown-attributes") 45 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHIP_CLANG_HCC_COMPAT_MODE=1 -DBOOST_USE_WINDOWS_H -DNOMINMAX") 46 | 47 | # args also in hipcc.bat 48 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions -fms-compatibility -D__HIP_ROCclr__=1 -D__HIP_PLATFORM_AMD__=1") 49 | 50 | if (DEFINED ENV{VCPKG_PATH}) 51 | file(TO_CMAKE_PATH "$ENV{VCPKG_PATH}" VCPKG_PATH) 52 | else() 53 | set(VCPKG_PATH "C:/github/vcpkg") 54 | endif() 55 | include("${VCPKG_PATH}/scripts/buildsystems/vcpkg.cmake") 56 | 57 | set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") 58 | set(CMAKE_STATIC_LIBRARY_PREFIX "static_") 59 | set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") 60 | set(CMAKE_SHARED_LIBRARY_PREFIX "") 61 | --------------------------------------------------------------------------------