Skip to content

Commit

Permalink
add gpsvInterleavedBatch example
Browse files Browse the repository at this point in the history
  • Loading branch information
mnicely committed Dec 21, 2021
1 parent d5b77ce commit f56bc18
Show file tree
Hide file tree
Showing 5 changed files with 594 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cuSPARSE/coosort/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ This sample demonstrates the usage of `cusparseXcoosortByRow` to perform sorting
## Prerequisites

* [CUDA 11.0 toolkit](https://developer.nvidia.com/cuda-downloads) (or above) and compatible driver (see [CUDA Driver Release Notes](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#cuda-major-component-versions)).
* [CMake 3.9](https://cmake.org/download/) or above on Windows
* [CMake 3.18](https://cmake.org/download/) or above on Windows
110 changes: 110 additions & 0 deletions cuSPARSE/gpsvInterleavedBatch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright 1993-2021 NVIDIA Corporation. All rights reserved.
#
# NOTICE TO LICENSEE:
#
# This source code and/or documentation ("Licensed Deliverables") are
# subject to NVIDIA intellectual property rights under U.S. and
# international Copyright laws.
#
# These Licensed Deliverables contained herein is PROPRIETARY and
# CONFIDENTIAL to NVIDIA and is being provided under the terms and
# conditions of a form of NVIDIA software license agreement by and
# between NVIDIA and Licensee ("License Agreement") or electronically
# accepted by Licensee. Notwithstanding any terms or conditions to
# the contrary in the License Agreement, reproduction or disclosure
# of the Licensed Deliverables to any third party without the express
# written consent of NVIDIA is prohibited.
#
# NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
# LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
# SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
# PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
# NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
# DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
# NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
# NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
# LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
# SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THESE LICENSED DELIVERABLES.
#
# U.S. Government End Users. These Licensed Deliverables are a
# "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
# 1995), consisting of "commercial computer software" and "commercial
# computer software documentation" as such terms are used in 48
# C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
# only as a commercial end item. Consistent with 48 C.F.R.12.212 and
# 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
# U.S. Government End Users acquire the Licensed Deliverables with
# only those rights set forth herein.
#
# Any use of the Licensed Deliverables in individual and commercial
# software must include, in the user documentation and internal
# comments to the code, the above Disclaimer and U.S. Government End
# Users Notice.
cmake_minimum_required(VERSION 3.18)

set(ROUTINE gpsvInterleavedBatch)

project("${ROUTINE}_example"
DESCRIPTION "GPU-Accelerated Sparse Linear Algebra"
HOMEPAGE_URL "https://docs.nvidia.com/cuda/cusparse/index.html"
LANGUAGES C CXX CUDA)

find_package(CUDAToolkit REQUIRED)

# ##########################################
# cusparse_examples build mode
# ##########################################

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "" "Debug" "Release")
else()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif()

# ##########################################
# cusparse_examples building flags
# ##########################################

# Global CXX/CUDA flags
if(CMAKE_CUDA_ARCHITECTURES LESS 60)
set(CMAKE_CUDA_ARCHITECTURES 60 70 75 80 86)
endif()

# Global CXX flags/options
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Global CUDA CXX flags/options
set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_EXTENSIONS OFF)

# Debug options
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS} -O0 -g -lineinfo")

# ##########################################
# cusparse_examples target
# ##########################################

add_executable(${ROUTINE}_example)

target_sources(${ROUTINE}_example
PUBLIC ${PROJECT_SOURCE_DIR}/${ROUTINE}_example.cu
)

target_include_directories(${ROUTINE}_example
PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)

target_link_libraries(${ROUTINE}_example
PUBLIC CUDA::cudart CUDA::cusparse CUDA::cublas
)
63 changes: 63 additions & 0 deletions cuSPARSE/gpsvInterleavedBatch/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 1993-2021 NVIDIA Corporation. All rights reserved.
#
# NOTICE TO LICENSEE:
#
# This source code and/or documentation ("Licensed Deliverables") are
# subject to NVIDIA intellectual property rights under U.S. and
# international Copyright laws.
#
# These Licensed Deliverables contained herein is PROPRIETARY and
# CONFIDENTIAL to NVIDIA and is being provided under the terms and
# conditions of a form of NVIDIA software license agreement by and
# between NVIDIA and Licensee ("License Agreement") or electronically
# accepted by Licensee. Notwithstanding any terms or conditions to
# the contrary in the License Agreement, reproduction or disclosure
# of the Licensed Deliverables to any third party without the express
# written consent of NVIDIA is prohibited.
#
# NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
# LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
# SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
# PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
# NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
# DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
# NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
# NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
# LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
# SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THESE LICENSED DELIVERABLES.
#
# U.S. Government End Users. These Licensed Deliverables are a
# "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
# 1995), consisting of "commercial computer software" and "commercial
# computer software documentation" as such terms are used in 48
# C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
# only as a commercial end item. Consistent with 48 C.F.R.12.212 and
# 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
# U.S. Government End Users acquire the Licensed Deliverables with
# only those rights set forth herein.
#
# Any use of the Licensed Deliverables in individual and commercial
# software must include, in the user documentation and internal
# comments to the code, the above Disclaimer and U.S. Government End
# Users Notice.
CUDA_TOOLKIT := $(shell dirname $$(command -v nvcc))/..
INC := -I$(CUDA_TOOLKIT)/include
LIBS := -lcudart -lcusparse -lcublas

all: gpsvInterleavedBatch_example

gpsvInterleavedBatch_example: gpsvInterleavedBatch_example.cu
nvcc $(INC) gpsvInterleavedBatch_example.cu -o gpsvInterleavedBatch_example $(LIBS)

clean:
rm -f gpsvInterleavedBatch_example

test:
@echo "\n==== Axpby Test ====\n"
./gpsvInterleavedBatch_example

.PHONY: clean all test
61 changes: 61 additions & 0 deletions cuSPARSE/gpsvInterleavedBatch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# cuSPARSE APIs - `cusparseSgpsvInterleavedBatch`

## Description

The example solves two penta-diagonal systems and assumes data layout is NOT interleaved format. Before calling `gpsvInterleavedBatch`, `cublasXgeam` is used to transform the data layout, from aggregate format to interleaved format. If the user can prepare interleaved format, no need to transpose the data.

[cusparseSgpsvInterleavedBatch Documentation](https://docs.nvidia.com/cuda/cusparse/index.html#gpsvInterleavedBatch)

## Building

* Linux
```bash
make
```

* Windows/Linux
```bash
mkdir build
cd build
cmake ..
make
```
On Windows, instead of running the last build step, open the Visual Studio Solution that was created and build.

## Support

* **Supported SM Architectures:** SM 3.5, SM 3.7, SM 5.0, SM 5.2, SM 5.3, SM 6.0, SM 6.1, SM 6.2, SM 7.0, SM 7.2, SM 7.5, SM 8.0, SM 8.6
* **Supported OSes:** Linux, Windows, QNX, Android
* **Supported CPU Architectures**: x86_64, ppc64le, arm64
* **Supported Compilers**: gcc, clang, Intel icc, IBM xlc, Microsoft msvc, Nvidia HPC SDK nvc
* **Language**: `C++11`

## Prerequisites

* [CUDA 11.0 toolkit](https://developer.nvidia.com/cuda-downloads) (or above) and compatible driver (see [CUDA Driver Release Notes](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#cuda-major-component-versions)).
* [CMake 3.18](https://cmake.org/download/) or above on Windows

## Usage

```
$ ./gpsvInterleavedBatch_example
```
Sample example output:
```
lworkInBytes = 64
==== x1 = inv(A1)*b1
x1[0] = -0.059152
x1[1] = 0.342773
x1[2] = -0.129464
x1[3] = 0.198242
|b1 - A1*x1| = 7.152557E-07

==== x2 = inv(A2)*b2
x2[0] = -0.001203
x2[1] = 0.279155
x2[2] = -0.041607
x2[3] = 0.089761
|b2 - A2*x2| = 4.768372E-07
```
Loading

0 comments on commit f56bc18

Please sign in to comment.