diff --git a/projects/hipsparselt/docs/index.rst b/projects/hipsparselt/docs/index.rst index ae9577326ae..5cd4804863e 100644 --- a/projects/hipsparselt/docs/index.rst +++ b/projects/hipsparselt/docs/index.rst @@ -8,8 +8,6 @@ hipSPARSELt documentation ******************************************************************** -FILE EDITS - hipSPARSELt is a SPARSE marshalling library that presents a common interface for multiple supported backends. For more information, see :doc:`What is hipSPARSELt? <./what-is-hipsparselt>` diff --git a/projects/hipsparselt/docs/package/CMakeLists.txt b/projects/hipsparselt/docs/package/CMakeLists.txt deleted file mode 100644 index f35b3874e4e..00000000000 --- a/projects/hipsparselt/docs/package/CMakeLists.txt +++ /dev/null @@ -1,158 +0,0 @@ -# MIT License -# -# Copyright (c) 2022-2024 Advanced Micro Devices, Inc. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -# Package test -cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR) - -if(DEFINED ENV{ROCM_PATH}) - set (ROCM_PATH "$ENV{ROCM_PATH}" CACHE PATH "The path to the ROCm installation.") -endif() -set (ROCM_PATH "/opt/rocm" CACHE PATH "The path to the ROCm installation.") - -project(hiprand_package_test CXX) - -# CMake modules -list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH} ${ROCM_PATH}/hip) -list(APPEND CMAKE_MODULE_PATH - ${HIP_DIR}/cmake ${ROCM_PATH}/hip/cmake # FindHIP.cmake -) - -# Find HIP -if (BUILD_WITH_LIB STREQUAL "CUDA") - find_package(hip QUIET CONFIG PATHS ${ROCM_PATH}) - if(NOT hip_FOUND) - find_package(HIP REQUIRED) - endif() -else() - find_package(hip REQUIRED CONFIG PATHS ${ROCM_PATH}) -endif() - -if (NOT DEFINED CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) -endif() -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HIP_CPP_CONFIG}") - -if (CMAKE_CXX_STANDARD EQUAL 14) - message(WARNING "C++14 will be deprecated in the next major release") -elseif(NOT CMAKE_CXX_STANDARD EQUAL 17) - message(FATAL_ERROR "Only C++14 and C++17 are supported") -endif() - -# CUDA -if (BUILD_WITH_LIB STREQUAL "CUDA") - set(CUDA_USE_STATIC_CUDA_RUNTIME OFF) - find_package(CUDA REQUIRED) -endif() - -# Find hipRAND -find_package(hiprand REQUIRED CONFIG HINTS ${hiprand_DIR} PATHS "${ROCM_PATH}/hiprand") - -# TODO: Fix fortran wrapper -# Check if Fortran wrapper is installed -#if(NOT EXISTS "${hiprand_FORTRAN_SRC_DIRS}/hiprand_m.f90") -# message(FATAL_ERROR "${rocrand_FORTRAN_SRC_DIRS}/hiprand_m.f90 does not exist") -#endif() -#if(NOT EXISTS "${hiprand_FORTRAN_SRC_DIRS}/hip_m.f90") -# message(FATAL_ERROR "${hiprand_FORTRAN_SRC_DIRS}/hip_m.f90 does not exist") -#endif() -#if(NOT EXISTS "${rocrand_FORTRAN_SRC_DIRS}/rocrand_m.f90") -# message(FATAL_ERROR "${rocrand_FORTRAN_SRC_DIRS}/rocrand_m.f90 does not exist") -#endif() -#if(NOT EXISTS "${rocrand_FORTRAN_SRC_DIRS}/hip_m.f90") -# message(FATAL_ERROR "${rocrand_FORTRAN_SRC_DIRS}/hip_m.f90 does not exist") -#endif() - -# Get sources -file(GLOB hiprand_pkg_TEST_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/test_hiprand*.cpp) - -# Enable testing (ctest) -enable_testing() - -function(add_relative_test test_name test_target) - get_target_property(EXE_PATH ${test_target} RUNTIME_OUTPUT_DIRECTORY) - if(EXE_PATH STREQUAL "EXE_PATH-NOTFOUND") - set(EXE_PATH ".") - endif() - get_filename_component(EXE_PATH "${EXE_PATH}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") - get_target_property(EXE_NAME ${test_target} RUNTIME_OUTPUT_NAME) - if(EXE_NAME STREQUAL "EXE_NAME-NOTFOUND") - get_target_property(EXE_NAME ${test_target} OUTPUT_NAME) - if(EXE_NAME STREQUAL "EXE_NAME-NOTFOUND") - set(EXE_NAME "${test_target}") - endif() - endif() - file(RELATIVE_PATH rel_path "${CMAKE_CURRENT_BINARY_DIR}" "${EXE_PATH}/${EXE_NAME}") - add_test(NAME "${test_name}" COMMAND "./${rel_path}") -endfunction() - -# Build -foreach(test_src ${hiprand_pkg_TEST_SRCS}) - get_filename_component(test_name ${test_src} NAME_WE) - add_executable(${test_name} "${test_src}") - if(HIP_COMPILER STREQUAL "clang") - target_link_libraries(${test_name} - PRIVATE - hip::hiprand - hip::host - ) - if(WIN32) - target_compile_options(${test_name} PRIVATE "-xhip") - endif() - else() - target_link_libraries(${test_name} - PRIVATE - hip::hiprand - ${CUDA_curand_LIBRARY} - ${CUDA_LIBRARIES} - ) - # Get HIP options - execute_process( - COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --cpp_config - OUTPUT_VARIABLE HIP_CPP_CONFIG - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_STRIP_TRAILING_WHITESPACE - ) - separate_arguments(HIP_CPP_CONFIG UNIX_COMMAND "${HIP_CPP_CONFIG}") - target_compile_options(${test_name} PRIVATE ${HIP_CPP_CONFIG}) - endif() - set_target_properties(${TEST_TARGET} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test" - ) - add_relative_test(${test_name} ${test_name}) - if (WIN32 AND NOT DEFINED DLLS_COPIED) - set(DLLS_COPIED "YES") - set(DLLS_COPIED ${DLLS_COPIED} PARENT_SCOPE) - # for now adding in all .dll as dependency chain is not cmake based on win32 - file( GLOB third_party_dlls - LIST_DIRECTORIES ON - CONFIGURE_DEPENDS - ${HIP_DIR}/bin/*.dll - ${CMAKE_SOURCE_DIR}/rtest.* - ) - foreach( file_i ${third_party_dlls}) - add_custom_command( TARGET ${test_name} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${file_i} ${PROJECT_BINARY_DIR}/test/package ) - endforeach( file_i ) - endif() -endforeach() diff --git a/projects/hipsparselt/docs/package/test_hiprand.cpp b/projects/hipsparselt/docs/package/test_hiprand.cpp deleted file mode 100644 index f08698d4b94..00000000000 --- a/projects/hipsparselt/docs/package/test_hiprand.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#include - -#include -#include - -#define HIP_CHECK(condition) \ - { \ - hipError_t error = condition; \ - if(error != hipSuccess){ \ - std::cout << error << std::endl; \ - exit(error); \ - } \ - } - -#define HIPRAND_CHECK(condition) \ - { \ - hiprandStatus_t status = condition; \ - if(status != HIPRAND_STATUS_SUCCESS) { \ - std::cout << status << std::endl; \ - exit(status); \ - } \ - } - -int main(int argc, char *argv[]) -{ - hiprandGenerator_t generator; - HIPRAND_CHECK(hiprandCreateGenerator(&generator, HIPRAND_RNG_PSEUDO_DEFAULT)); - - const size_t size = 128; - unsigned int * data = NULL; - HIP_CHECK(hipMalloc(&data, size * sizeof(unsigned int))); - HIPRAND_CHECK(hiprandGenerate(generator, (unsigned int *) data, size)); - HIP_CHECK(hipDeviceSynchronize()); - - HIPRAND_CHECK(hiprandDestroyGenerator(generator)); - HIP_CHECK(hipFree(data)); - - if(HIPRAND_VERSION < 0) exit(1); - - return 0; -} diff --git a/projects/hipsparselt/docs/sphinx/_toc.yml.in b/projects/hipsparselt/docs/sphinx/_toc.yml.in new file mode 100644 index 00000000000..57ccf5dc303 --- /dev/null +++ b/projects/hipsparselt/docs/sphinx/_toc.yml.in @@ -0,0 +1,50 @@ +# Anywhere {branch} is used, the branch name will be substituted. +# These comments will also be removed. +defaults: + numbered: False + maxdepth: 7 +root: index +subtrees: +- entries: + - file: what-is-hipsparselt + title: What is hipSPARSELt? + +- caption: Install + entries: + - file: install/quick-start-install + title: Quick start installation guide + - file: install/install-hipsparselt + title: Detailed installation guide + +- caption: Conceptual + entries: + - file: conceptual/storage-format + title: Storage formats + - file: conceptual/mi300-features + title: MI300 features + +- caption: How to + entries: + - file: how-to/device-stream-management + title: Manage devices and streams + - file: how-to/porting + title: Port from NVIDIA CUDA + +- caption: Examples + entries: + - url: https://github.com/ROCm/hipSPARSELt/tree/develop/clients/samples + title: Client samples + +- caption: API Reference + entries: + - file: reference/supported-functions.rst + title: Supported functions + - file: reference/data-type-support.rst + title: Data type support + - file: doxygen/html/index + title: API library + +- caption: About + entries: + - file: license.md + title: License diff --git a/projects/hipsparselt/docs/sphinx/requirements.in b/projects/hipsparselt/docs/sphinx/requirements.in new file mode 100644 index 00000000000..56547425678 --- /dev/null +++ b/projects/hipsparselt/docs/sphinx/requirements.in @@ -0,0 +1 @@ +rocm-docs-core[api_reference]==1.12.0 diff --git a/projects/hipsparselt/docs/sphinx/requirements.txt b/projects/hipsparselt/docs/sphinx/requirements.txt new file mode 100644 index 00000000000..5e63078cd87 --- /dev/null +++ b/projects/hipsparselt/docs/sphinx/requirements.txt @@ -0,0 +1,167 @@ +# +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: +# +# pip-compile requirements.in +# +accessible-pygments==0.0.5 + # via pydata-sphinx-theme +alabaster==1.0.0 + # via sphinx +babel==2.16.0 + # via + # pydata-sphinx-theme + # sphinx +beautifulsoup4==4.12.3 + # via pydata-sphinx-theme +breathe==4.35.0 + # via rocm-docs-core +certifi==2024.7.4 + # via requests +cffi==1.17.0 + # via + # cryptography + # pynacl +charset-normalizer==3.3.2 + # via requests +click==8.1.7 + # via + # click-log + # doxysphinx + # sphinx-external-toc +click-log==0.4.0 + # via doxysphinx +cryptography==43.0.0 + # via pyjwt +deprecated==1.2.14 + # via pygithub +docutils==0.21.2 + # via + # breathe + # myst-parser + # pydata-sphinx-theme + # sphinx +doxysphinx==3.3.10 + # via rocm-docs-core +fastjsonschema==2.20.0 + # via rocm-docs-core +gitdb==4.0.11 + # via gitpython +gitpython==3.1.43 + # via rocm-docs-core +idna==3.7 + # via requests +imagesize==1.4.1 + # via sphinx +jinja2==3.1.4 + # via + # myst-parser + # sphinx +libsass==0.22.0 + # via doxysphinx +lxml==4.9.4 + # via doxysphinx +markdown-it-py==3.0.0 + # via + # mdit-py-plugins + # myst-parser +markupsafe==2.1.5 + # via jinja2 +mdit-py-plugins==0.4.1 + # via myst-parser +mdurl==0.1.2 + # via markdown-it-py +mpire==2.10.2 + # via doxysphinx +myst-parser==4.0.0 + # via rocm-docs-core +numpy==1.26.4 + # via doxysphinx +packaging==24.1 + # via + # pydata-sphinx-theme + # sphinx +pycparser==2.22 + # via cffi +pydata-sphinx-theme==0.15.4 + # via + # rocm-docs-core + # sphinx-book-theme +pygithub==2.3.0 + # via rocm-docs-core +pygments==2.18.0 + # via + # accessible-pygments + # mpire + # pydata-sphinx-theme + # sphinx +pyjson5==1.6.6 + # via doxysphinx +pyjwt[crypto]==2.9.0 + # via pygithub +pynacl==1.5.0 + # via pygithub +pyparsing==3.1.2 + # via doxysphinx +pyyaml==6.0.2 + # via + # myst-parser + # rocm-docs-core + # sphinx-external-toc +requests==2.32.3 + # via + # pygithub + # sphinx +rocm-docs-core[api-reference]==1.12.0 + # via -r requirements.in +smmap==5.0.1 + # via gitdb +snowballstemmer==2.2.0 + # via sphinx +soupsieve==2.5 + # via beautifulsoup4 +sphinx==8.0.2 + # via + # breathe + # myst-parser + # pydata-sphinx-theme + # rocm-docs-core + # sphinx-book-theme + # sphinx-copybutton + # sphinx-design + # sphinx-external-toc + # sphinx-notfound-page +sphinx-book-theme==1.1.3 + # via rocm-docs-core +sphinx-copybutton==0.5.2 + # via rocm-docs-core +sphinx-design==0.6.1 + # via rocm-docs-core +sphinx-external-toc==1.0.1 + # via rocm-docs-core +sphinx-notfound-page==1.0.4 + # via rocm-docs-core +sphinxcontrib-applehelp==2.0.0 + # via sphinx +sphinxcontrib-devhelp==2.0.0 + # via sphinx +sphinxcontrib-htmlhelp==2.1.0 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==2.0.0 + # via sphinx +sphinxcontrib-serializinghtml==2.0.0 + # via sphinx +tqdm==4.66.5 + # via mpire +typing-extensions==4.12.2 + # via + # pydata-sphinx-theme + # pygithub +urllib3==2.2.2 + # via + # pygithub + # requests +wrapt==1.16.0 + # via deprecated diff --git a/projects/rocprim/CHANGELOG.md b/projects/rocprim/CHANGELOG.md index e5d4b74a72e..f405848e979 100644 --- a/projects/rocprim/CHANGELOG.md +++ b/projects/rocprim/CHANGELOG.md @@ -2,8 +2,6 @@ Full documentation for rocPRIM is available at [https://rocm.docs.amd.com/projects/rocPRIM/en/latest/](https://rocm.docs.amd.com/projects/rocPRIM/en/latest/). -File edits - ## rocPRIM 3.6.0 for ROCm 7.0 ### Changed diff --git a/projects/rocprim/benchmark/package/CMakeLists.txt b/projects/rocprim/benchmark/package/CMakeLists.txt deleted file mode 100644 index f35b3874e4e..00000000000 --- a/projects/rocprim/benchmark/package/CMakeLists.txt +++ /dev/null @@ -1,158 +0,0 @@ -# MIT License -# -# Copyright (c) 2022-2024 Advanced Micro Devices, Inc. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -# Package test -cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR) - -if(DEFINED ENV{ROCM_PATH}) - set (ROCM_PATH "$ENV{ROCM_PATH}" CACHE PATH "The path to the ROCm installation.") -endif() -set (ROCM_PATH "/opt/rocm" CACHE PATH "The path to the ROCm installation.") - -project(hiprand_package_test CXX) - -# CMake modules -list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH} ${ROCM_PATH}/hip) -list(APPEND CMAKE_MODULE_PATH - ${HIP_DIR}/cmake ${ROCM_PATH}/hip/cmake # FindHIP.cmake -) - -# Find HIP -if (BUILD_WITH_LIB STREQUAL "CUDA") - find_package(hip QUIET CONFIG PATHS ${ROCM_PATH}) - if(NOT hip_FOUND) - find_package(HIP REQUIRED) - endif() -else() - find_package(hip REQUIRED CONFIG PATHS ${ROCM_PATH}) -endif() - -if (NOT DEFINED CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) -endif() -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HIP_CPP_CONFIG}") - -if (CMAKE_CXX_STANDARD EQUAL 14) - message(WARNING "C++14 will be deprecated in the next major release") -elseif(NOT CMAKE_CXX_STANDARD EQUAL 17) - message(FATAL_ERROR "Only C++14 and C++17 are supported") -endif() - -# CUDA -if (BUILD_WITH_LIB STREQUAL "CUDA") - set(CUDA_USE_STATIC_CUDA_RUNTIME OFF) - find_package(CUDA REQUIRED) -endif() - -# Find hipRAND -find_package(hiprand REQUIRED CONFIG HINTS ${hiprand_DIR} PATHS "${ROCM_PATH}/hiprand") - -# TODO: Fix fortran wrapper -# Check if Fortran wrapper is installed -#if(NOT EXISTS "${hiprand_FORTRAN_SRC_DIRS}/hiprand_m.f90") -# message(FATAL_ERROR "${rocrand_FORTRAN_SRC_DIRS}/hiprand_m.f90 does not exist") -#endif() -#if(NOT EXISTS "${hiprand_FORTRAN_SRC_DIRS}/hip_m.f90") -# message(FATAL_ERROR "${hiprand_FORTRAN_SRC_DIRS}/hip_m.f90 does not exist") -#endif() -#if(NOT EXISTS "${rocrand_FORTRAN_SRC_DIRS}/rocrand_m.f90") -# message(FATAL_ERROR "${rocrand_FORTRAN_SRC_DIRS}/rocrand_m.f90 does not exist") -#endif() -#if(NOT EXISTS "${rocrand_FORTRAN_SRC_DIRS}/hip_m.f90") -# message(FATAL_ERROR "${rocrand_FORTRAN_SRC_DIRS}/hip_m.f90 does not exist") -#endif() - -# Get sources -file(GLOB hiprand_pkg_TEST_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/test_hiprand*.cpp) - -# Enable testing (ctest) -enable_testing() - -function(add_relative_test test_name test_target) - get_target_property(EXE_PATH ${test_target} RUNTIME_OUTPUT_DIRECTORY) - if(EXE_PATH STREQUAL "EXE_PATH-NOTFOUND") - set(EXE_PATH ".") - endif() - get_filename_component(EXE_PATH "${EXE_PATH}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") - get_target_property(EXE_NAME ${test_target} RUNTIME_OUTPUT_NAME) - if(EXE_NAME STREQUAL "EXE_NAME-NOTFOUND") - get_target_property(EXE_NAME ${test_target} OUTPUT_NAME) - if(EXE_NAME STREQUAL "EXE_NAME-NOTFOUND") - set(EXE_NAME "${test_target}") - endif() - endif() - file(RELATIVE_PATH rel_path "${CMAKE_CURRENT_BINARY_DIR}" "${EXE_PATH}/${EXE_NAME}") - add_test(NAME "${test_name}" COMMAND "./${rel_path}") -endfunction() - -# Build -foreach(test_src ${hiprand_pkg_TEST_SRCS}) - get_filename_component(test_name ${test_src} NAME_WE) - add_executable(${test_name} "${test_src}") - if(HIP_COMPILER STREQUAL "clang") - target_link_libraries(${test_name} - PRIVATE - hip::hiprand - hip::host - ) - if(WIN32) - target_compile_options(${test_name} PRIVATE "-xhip") - endif() - else() - target_link_libraries(${test_name} - PRIVATE - hip::hiprand - ${CUDA_curand_LIBRARY} - ${CUDA_LIBRARIES} - ) - # Get HIP options - execute_process( - COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --cpp_config - OUTPUT_VARIABLE HIP_CPP_CONFIG - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_STRIP_TRAILING_WHITESPACE - ) - separate_arguments(HIP_CPP_CONFIG UNIX_COMMAND "${HIP_CPP_CONFIG}") - target_compile_options(${test_name} PRIVATE ${HIP_CPP_CONFIG}) - endif() - set_target_properties(${TEST_TARGET} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test" - ) - add_relative_test(${test_name} ${test_name}) - if (WIN32 AND NOT DEFINED DLLS_COPIED) - set(DLLS_COPIED "YES") - set(DLLS_COPIED ${DLLS_COPIED} PARENT_SCOPE) - # for now adding in all .dll as dependency chain is not cmake based on win32 - file( GLOB third_party_dlls - LIST_DIRECTORIES ON - CONFIGURE_DEPENDS - ${HIP_DIR}/bin/*.dll - ${CMAKE_SOURCE_DIR}/rtest.* - ) - foreach( file_i ${third_party_dlls}) - add_custom_command( TARGET ${test_name} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${file_i} ${PROJECT_BINARY_DIR}/test/package ) - endforeach( file_i ) - endif() -endforeach() diff --git a/projects/rocprim/benchmark/package/test_hiprand.cpp b/projects/rocprim/benchmark/package/test_hiprand.cpp deleted file mode 100644 index f08698d4b94..00000000000 --- a/projects/rocprim/benchmark/package/test_hiprand.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#include - -#include -#include - -#define HIP_CHECK(condition) \ - { \ - hipError_t error = condition; \ - if(error != hipSuccess){ \ - std::cout << error << std::endl; \ - exit(error); \ - } \ - } - -#define HIPRAND_CHECK(condition) \ - { \ - hiprandStatus_t status = condition; \ - if(status != HIPRAND_STATUS_SUCCESS) { \ - std::cout << status << std::endl; \ - exit(status); \ - } \ - } - -int main(int argc, char *argv[]) -{ - hiprandGenerator_t generator; - HIPRAND_CHECK(hiprandCreateGenerator(&generator, HIPRAND_RNG_PSEUDO_DEFAULT)); - - const size_t size = 128; - unsigned int * data = NULL; - HIP_CHECK(hipMalloc(&data, size * sizeof(unsigned int))); - HIPRAND_CHECK(hiprandGenerate(generator, (unsigned int *) data, size)); - HIP_CHECK(hipDeviceSynchronize()); - - HIPRAND_CHECK(hiprandDestroyGenerator(generator)); - HIP_CHECK(hipFree(data)); - - if(HIPRAND_VERSION < 0) exit(1); - - return 0; -} diff --git a/projects/rocprim/scripts/copyright-date/check-copyright.sh b/projects/rocprim/scripts/copyright-date/check-copyright.sh new file mode 100755 index 00000000000..fccbdb9ac48 --- /dev/null +++ b/projects/rocprim/scripts/copyright-date/check-copyright.sh @@ -0,0 +1,221 @@ +#!/usr/bin/env bash + +# Start of configuration +preamble="Copyright +(\([cC]\) +)?" +postamble=",? +Advanced +Micro +Devices, +Inc\." +find_pattern="$preamble([0-9]{4}-)?[0-9]{4}$postamble" +# printf format string, receives the current year as a parameter +uptodate_pattern="$preamble([0-9]{4}-)?%d$postamble" +# / interpreted with sed syntax, also passed to printf +# printf interprets '\' escape sequences so they must be escaped +# The capture groups are as follows: +# - \1 is the whole preamble text +# - \3 is the start year, \2 is skipped because it is used for an optional part of the preamble +# - \5 is the end of the copyright statement after the end year, \4 would be the original end year +# as written in the file, it is replaced by the current year instead. +replace_pattern="($preamble)([0-9]{4})(-[0-9]{4})?($postamble)/\\\1\\\3-%d\\\5" +# End of configuration + +print_help() { printf -- \ +"\033[36musuage\033[0m: \033[33mcheck_year.sh [-h] [-u] [-a] [-d ] [-k] [-v]\033[0m +\033[36mdescription\033[0m: Checks for if the copyright year in the staged files is up to date and displays the files with out-of-date copyright statements. Exits with '0' if successful and with '1' if something is out of date. +\033[36moptions\033[0m: + \033[34m-h\033[0m Displays this message. + \033[34m-u\033[0m Automatically updates the copyright year + \033[34m-a\033[0m Automatically applies applies the changes to current staging environment. Implies '-u' and '-c'. + \033[34m-c\033[0m Compare files to the index instead of the working tree. + \033[34m-d \033[0m Compare using the diff of a hash. + \033[34m-k\033[0m Compare using the fork point: where this branch and 'remotes/origin/HEAD' diverge. + \033[34m-q\033[0m Suppress updates about progress. + \033[34m-v\033[0m Verbose output. +Use '\033[33mgit config --local hooks.updateCopyright \033[0m' to automatically apply copyright changes on commit. +" +} + +# argument parsing +apply=false +update=false +verbose=false +forkdiff=false +quiet=false +cached=false + +while getopts "auhvkqcd:" arg; do + case $arg in + a) update=true;apply=true;cached=true;; + u) update=true;; + v) verbose=true;; + k) forkdiff=true;; + q) quiet=true;; + c) cached=true;; + d) diff_hash=${OPTARG};; + h) print_help; exit;; + *) print help; exit 1;; + esac +done + +# If set, check all files changed since the fork point +if $forkdiff; then + branch="$(git rev-parse --abbrev-ref HEAD)" + remote="$(git config --local --get "branch.$branch.remote" || echo 'origin')" + source_commit="remotes/$remote/HEAD" + + # don't use fork-point for finding fork point (lol) + diff_hash="$(git merge-base "$source_commit" "$branch")" +fi + +if [ -n "${diff_hash}" ]; then + $verbose && printf -- "Using base commit: %s\n" "${diff_hash}" +else + diff_hash="HEAD" +fi + +# Current year +year="$(date +%Y)" + +# Enable rename detection with full matches only, this skips copyright checks for file name only +# changes. +diff_opts=(-z --name-only '--diff-filter=MA' '--find-renames=100%') +git_grep_opts=(-z --extended-regexp --ignore-case --no-recursive -I) +if $cached; then + diff_opts+=(--cached) + git_grep_opts+=(--cached) +fi + +! $quiet && printf -- "Checking if copyright statements are up-to-date... " +mapfile -d $'\0' changed_files < <(git diff-index "${diff_opts[@]}" "$diff_hash" | LANG=C.UTF-8 sort -z) + +if ! (( ${#changed_files[@]} )); then + ! $quiet && printf -- "\033[32mDone!\033[0m\n" + $verbose && printf -- "\033[36mNo changed files found.\033[0m\n" + exit 0 +fi; + +mapfile -d $'\0' found_copyright < <( \ + git grep "${git_grep_opts[@]}" --files-with-matches -e "$find_pattern" \ + -- "${changed_files[@]}" | \ + LANG=C.UTF-8 sort -z) + +outdated_copyright=() +if (( ${#found_copyright[@]} )); then + # uptodate_pattern variable holds the format string using it as such is intentional + # shellcheck disable=SC2059 + printf -v uptodate_pattern -- "$uptodate_pattern" "$year" + mapfile -d $'\0' outdated_copyright < <( \ + git grep "${git_grep_opts[@]}" --files-without-match -e "$uptodate_pattern" \ + -- "${found_copyright[@]}" | \ + LANG=C.UTF-8 sort -z) +fi + +! $quiet && printf -- "\033[32mDone!\033[0m\n" +if $verbose; then + # Compute the files that don't have a copyright as the set difference of + # `changed_files and `found_copyright` + mapfile -d $'\0' notfound_copyright < <( \ + printf -- '%s\0' "${changed_files[@]}" | \ + LANG=C.UTF-8 comm -z -23 - <(printf -- '%s\0' "${found_copyright[@]}")) + + if (( ${#notfound_copyright[@]} )); then + printf -- "\033[36mCouldn't find a copyright statement in %d file(s):\033[0m\n" \ + "${#notfound_copyright[@]}" + printf -- ' - %q\n' "${notfound_copyright[@]}" + fi + + # Similarly the up-to-date files are the difference of `found_copyright` and `outdated_copyright` + mapfile -d $'\0' uptodate_copyright < <( \ + printf -- '%s\0' "${found_copyright[@]}" | \ + LANG=C.UTF-8 comm -z -23 - <(printf -- '%s\0' "${outdated_copyright[@]}")) + + if (( ${#uptodate_copyright[@]} )); then + printf -- "\033[36mThe copyright statement was already up to date in %d file(s):\033[0m\n" \ + "${#uptodate_copyright[@]}" + printf -- ' - %q\n' "${uptodate_copyright[@]}" + fi +fi + +if ! (( ${#outdated_copyright[@]} )); then + exit 0 +fi + +printf -- \ +"\033[31m==== COPYRIGHT OUT OF DATE ====\033[0m +\033[36m%d file(s) need(s) to be updated:\033[0m\n" "${#outdated_copyright[@]}" +printf -- ' - %q\n' "${outdated_copyright[@]}" + +# If we don't need to update, we early exit. +if ! $update; then + printf -- \ +"\nRun '\033[33mscripts/copyright-date/check-copyright.sh -u\033[0m' to update the copyright statement(s). See '-h' for more info, +or set '\033[33mgit config --local hooks.updateCopyright true\033[0m' to automatically update copyrights when committing.\n" + exit 1 +fi + +if $apply; then + ! $quiet && printf -- "Updating copyrights and staging changes... " +else + ! $quiet && printf -- "Updating copyrights... " +fi + +# replace_pattern variable holds a format string, using it as such is intentional +# shellcheck disable=SC2059 +printf -v replace_pattern -- "$replace_pattern" "$year" +# Just update the files in place if only touching the working-tree +if ! $apply; then + sed --regexp-extended --separate "s/$replace_pattern/g" -i "${outdated_copyright[@]}" + printf -- "\033[32mDone!\033[0m\n" + exit 0 +fi + +generate_patch() { + # Sed command to create a hunk for a copyright statement fix + # expects input to be line number then copyright statement on the next line + to_hunk_cmd="{# Print hunk header, move to the next line + s/.+/@@ -&,1 +&,1 @@/;n + # Print removed line by prepending '-' to it + ;s/^/-/;p + # Print added line, replace the '-' with '+' and replace the copyright statement + s/^-/+/;s/$replace_pattern/g}" + + # Run file-names through git ls-files, just to get a (possibly) quoted name for each + mapfile -t -d $'\n' quoted_files < <(git ls-files --cached -- "${outdated_copyright[@]}") + for ((i = 0;i < ${#outdated_copyright[@]}; i++)); do + file="${outdated_copyright["$i"]}" + quoted="${quoted_files["$i"]}" + # Drop the quote from the start and end (to avoid quoting twice) + escaped="${quoted#\"}"; escaped="${escaped%\"}" + a="\"a/$escaped\"" + b="\"b/$escaped\"" + + printf -- "diff --git %s %s\n--- %s\n+++ %s\n" "$a" "$b" "$a" "$b" + + # Print line number and line for each line with a copyright statement + git cat-file blob ":$file" | \ + sed --quiet --regexp-extended "/$find_pattern/{=;p}" | \ + sed --regexp-extended "$to_hunk_cmd" + done +} + +patch_file="$(git rev-parse --git-dir)/copyright-fix.patch" +generate_patch > "$patch_file" + +# Cleanup patch file when the script exits +finish () { + rm -f "$patch_file" +} +# The trap will be invoked whenever the script exits, even due to a signal, this is a bash only +# feature +trap finish EXIT + +if ! git apply --unidiff-zero < "$patch_file"; then + printf -- "\033[31mFailed to apply changes to working tree. +Perhaps the fix is already applied, but not yet staged?\n\033[0m" + exit 1 +fi + +if ! git apply --cached --unidiff-zero < "$patch_file"; then + printf -- "\033[31mFailed to apply change to the index.\n\033[0m" + exit 1 +fi + +! $quiet && printf -- "\033[32mDone!\033[0m\n" +exit 0