Skip to content

Commit

Permalink
12 v 11 test with backward interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ameli committed Sep 14, 2023
1 parent b4fa794 commit 8b5b3c9
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: Jimver/[email protected]
id: cuda-toolkit
with:
cuda: '12.1.0'
cuda: '11.7.0'

- name: Install package and dependencies (CPython)
if: (!contains(matrix.python-version, 'pypy')) && (matrix.python-version != '3.10') && (matrix.python-version != '3.11')
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jobs:
# pip3 install numpy
# - name: Install CUDA
# uses: Jimver/[email protected].8
# uses: Jimver/[email protected].11
# id: cuda-toolkit
# with:
# cuda: '11.7.0'
# cuda: '12.1.0'

- name: Install package and dependencies
if: (matrix.python-version != '3.10') && (matrix.python-version != '3.11')
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: deploy-docs

on:
# push:
# branches:
# - main
push:
branches:
- main
pull_request:
branches:
- main
Expand Down
34 changes: 17 additions & 17 deletions docs/source/gpu/gpu_compile_source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,37 +101,37 @@ If CUDA Toolkit is installed, skip this part. Otherwise, Make sure the CUDA comp
.. prompt:: bash

sudo apt install -y \
cuda-nvcc-11-7 \
libcublas-11-7 \
libcublas-dev-11-7 \
libcusparse-11-7 -y \
libcusparse-dev-11-7
cuda-nvcc-12-2 \
libcublas-12-2 \
libcublas-dev-12-2 \
libcusparse-12-2 -y \
libcusparse-dev-12-2

.. tab-item:: CentOS 7
:sync: centos

.. prompt:: bash

sudo yum install --setopt=obsoletes=0 -y \
cuda-nvcc-11-7.x86_64 \
cuda-cudart-devel-11-7.x86_64 \
libcublas-11-7.x86_64 \
libcublas-devel-11-7.x86_64 \
libcusparse-11-7.x86_64 \
libcusparse-devel-11-7.x86_64
cuda-nvcc-12-2.x86_64 \
cuda-cudart-devel-12-2.x86_64 \
libcublas-12-2.x86_64 \
libcublas-devel-12-2.x86_64 \
libcusparse-12-2.x86_64 \
libcusparse-devel-12-2.x86_64

.. tab-item:: RHEL 9
:sync: rhel

.. prompt:: bash

sudo dnf install --setopt=obsoletes=0 -y \
cuda-nvcc-11-7.x86_64 \
cuda-cudart-devel-11-7.x86_64 \
libcublas-11-7.x86_64 \
libcublas-devel-11-7.x86_64 \
libcusparse-11-7.x86_64 \
libcusparse-devel-11-7.x86_64
cuda-nvcc-12-2.x86_64 \
cuda-cudart-devel-12-2.x86_64 \
libcublas-12-2.x86_64 \
libcublas-devel-12-2.x86_64 \
libcusparse-12-2.x86_64 \
libcusparse-devel-12-2.x86_64

Update ``PATH`` with the CUDA installation location by

Expand Down
14 changes: 7 additions & 7 deletions docs/source/gpu/gpu_install_cuda.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,27 @@ It is not required to install the entire CUDA Toolkit (2.6GB). Rather, only the

.. prompt:: bash

sudo apt install cuda-cudart-11-7 libcublas-11-7 libcusparse-11-7 -y
sudo apt install cuda-cudart-12-2 libcublas-12-2 libcusparse-12-2 -y

.. tab-item:: CentOS 7
:sync: centos

.. prompt:: bash

sudo yum install --setopt=obsoletes=0 -y \
cuda-nvcc-11-7.x86_64 \
libcublas-11-7.x86_64 \
libcusparse-11-7.x86_64
cuda-nvcc-12-2.x86_64 \
libcublas-12-2.x86_64 \
libcusparse-12-2.x86_64

.. tab-item:: RHEL 9
:sync: rhel

.. prompt:: bash

sudo dnf install --setopt=obsoletes=0 -y \
cuda-nvcc-11-7.x86_64 \
libcublas-11-7.x86_64 \
libcusparse-11-7.x86_64
cuda-nvcc-12-2.x86_64 \
libcublas-12-2.x86_64 \
libcusparse-12-2.x86_64

Update ``PATH`` with the CUDA installation location by

Expand Down
34 changes: 17 additions & 17 deletions docs/source/install/compile_source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,37 +235,37 @@ It is not required to install the entire CUDA Toolkit. Install only the CUDA com
.. prompt:: bash

sudo apt install -y \
cuda-nvcc-11-7 \
libcublas-11-7 \
libcublas-dev-11-7 \
libcusparse-11-7 -y \
libcusparse-dev-11-7
cuda-nvcc-12-2 \
libcublas-12-2 \
libcublas-dev-12-2 \
libcusparse-12-2 -y \
libcusparse-dev-12-2

.. tab-item:: CentOS 7
:sync: centos

.. prompt:: bash

sudo yum install --setopt=obsoletes=0 -y \
cuda-nvcc-11-7.x86_64 \
cuda-cudart-devel-11-7.x86_64 \
libcublas-11-7.x86_64 \
libcublas-devel-11-7.x86_64 \
libcusparse-11-7.x86_64 \
libcusparse-devel-11-7.x86_64
cuda-nvcc-12-2.x86_64 \
cuda-cudart-devel-12-2.x86_64 \
libcublas-12-2.x86_64 \
libcublas-devel-12-2.x86_64 \
libcusparse-12-2.x86_64 \
libcusparse-devel-12-2.x86_64

.. tab-item:: RHEL 9
:sync: rhel

.. prompt:: bash

sudo dnf install --setopt=obsoletes=0 -y \
cuda-nvcc-11-7.x86_64 \
cuda-cudart-devel-11-7.x86_64 \
libcublas-11-7.x86_64 \
libcublas-devel-11-7.x86_64 \
libcusparse-11-7.x86_64 \
libcusparse-devel-11-7.x86_64
cuda-nvcc-12-2.x86_64 \
cuda-cudart-devel-12-2.x86_64 \
libcublas-12-2.x86_64 \
libcublas-devel-12-2.x86_64 \
libcusparse-12-2.x86_64 \
libcusparse-devel-12-2.x86_64

Update ``PATH`` with the CUDA installation location by

Expand Down
7 changes: 7 additions & 0 deletions imate/_c_trace_estimator/special_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
// Headers
// =======

// Before including cmath, define _USE_MATH_DEFINES. This is only required to
// define the math constants like M_PI, etc, in win32 operating system.
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && \
!defined(__CYGWIN__)
#define _USE_MATH_DEFINES
#endif

#include <cmath> // sqrt, log, exp, erf, INFINITY, M_PI
#include "./special_functions.h"

Expand Down
8 changes: 4 additions & 4 deletions imate/_cu_linear_operator/cu_csc_matrix.cu
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void cuCSCMatrix<DataType>::dot(

// Using transpose operation since we treat CSC matrix as CSR
cusparseOperation_t cusparse_operation = CUSPARSE_OPERATION_TRANSPOSE;
cusparseSpMVAlg_t algorithm = CUSPARSE_MV_ALG_DEFAULT;
cusparseSpMVAlg_t algorithm = CUSPARSE_SPMV_ALG_DEFAULT;

// Get device id
int device_id = CudaInterface<DataType>::get_device();
Expand Down Expand Up @@ -357,7 +357,7 @@ void cuCSCMatrix<DataType>::dot_plus(

// Using transpose operation since we treat CSC matrix as CSR
cusparseOperation_t cusparse_operation = CUSPARSE_OPERATION_TRANSPOSE;
cusparseSpMVAlg_t algorithm = CUSPARSE_MV_ALG_DEFAULT;
cusparseSpMVAlg_t algorithm = CUSPARSE_SPMV_ALG_DEFAULT;

// Get device id
int device_id = CudaInterface<DataType>::get_device();
Expand Down Expand Up @@ -407,7 +407,7 @@ void cuCSCMatrix<DataType>::transpose_dot(

// Using non-transpose operation since we treat CSC matrix as CSR
cusparseOperation_t cusparse_operation = CUSPARSE_OPERATION_NON_TRANSPOSE;
cusparseSpMVAlg_t algorithm = CUSPARSE_MV_ALG_DEFAULT;
cusparseSpMVAlg_t algorithm = CUSPARSE_SPMV_ALG_DEFAULT;

// Get device id
int device_id = CudaInterface<DataType>::get_device();
Expand Down Expand Up @@ -457,7 +457,7 @@ void cuCSCMatrix<DataType>::transpose_dot_plus(

// Using non-transpose operation since we treat CSC matrix as CSR
cusparseOperation_t cusparse_operation = CUSPARSE_OPERATION_NON_TRANSPOSE;
cusparseSpMVAlg_t algorithm = CUSPARSE_MV_ALG_DEFAULT;
cusparseSpMVAlg_t algorithm = CUSPARSE_SPMV_ALG_DEFAULT;

// Get device id
int device_id = CudaInterface<DataType>::get_device();
Expand Down
8 changes: 4 additions & 4 deletions imate/_cu_linear_operator/cu_csr_matrix.cu
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void cuCSRMatrix<DataType>::dot(
DataType alpha = 1.0;
DataType beta = 0.0;
cusparseOperation_t cusparse_operation = CUSPARSE_OPERATION_NON_TRANSPOSE;
cusparseSpMVAlg_t algorithm = CUSPARSE_MV_ALG_DEFAULT;
cusparseSpMVAlg_t algorithm = CUSPARSE_SPMV_ALG_DEFAULT;

// Get device id
int device_id = CudaInterface<DataType>::get_device();
Expand Down Expand Up @@ -344,7 +344,7 @@ void cuCSRMatrix<DataType>::dot_plus(
// Matrix vector settings
DataType beta = 1.0;
cusparseOperation_t cusparse_operation = CUSPARSE_OPERATION_NON_TRANSPOSE;
cusparseSpMVAlg_t algorithm = CUSPARSE_MV_ALG_DEFAULT;
cusparseSpMVAlg_t algorithm = CUSPARSE_SPMV_ALG_DEFAULT;

// Get device id
int device_id = CudaInterface<DataType>::get_device();
Expand Down Expand Up @@ -392,7 +392,7 @@ void cuCSRMatrix<DataType>::transpose_dot(
DataType alpha = 1.0;
DataType beta = 0.0;
cusparseOperation_t cusparse_operation = CUSPARSE_OPERATION_TRANSPOSE;
cusparseSpMVAlg_t algorithm = CUSPARSE_MV_ALG_DEFAULT;
cusparseSpMVAlg_t algorithm = CUSPARSE_SPMV_ALG_DEFAULT;

// Get device id
int device_id = CudaInterface<DataType>::get_device();
Expand Down Expand Up @@ -440,7 +440,7 @@ void cuCSRMatrix<DataType>::transpose_dot_plus(
// Matrix vector settings
DataType beta = 1.0;
cusparseOperation_t cusparse_operation = CUSPARSE_OPERATION_TRANSPOSE;
cusparseSpMVAlg_t algorithm = CUSPARSE_MV_ALG_DEFAULT;
cusparseSpMVAlg_t algorithm = CUSPARSE_SPMV_ALG_DEFAULT;

// Get device id
int device_id = CudaInterface<DataType>::get_device();
Expand Down
14 changes: 7 additions & 7 deletions imate/_cuda_dynamic_loading/cusparse_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ cusparseStatus_t cusparseCreateDnVec(
/// dynamically loaded cublas library.

cusparseStatus_t cusparseDestroySpMat(
cusparseSpMatDescr_t spMatDescr)
cusparseConstSpMatDescr_t spMatDescr)
{
if (cusparseSymbols::cusparseDestroySpMat == NULL)
{
Expand All @@ -229,7 +229,7 @@ cusparseStatus_t cusparseDestroySpMat(
/// dynamically loaded cublas library.

cusparseStatus_t cusparseDestroyDnVec(
cusparseDnVecDescr_t dnVecDescr)
cusparseConstDnVecDescr_t dnVecDescr)
{
if (cusparseSymbols::cusparseDestroyDnVec == NULL)
{
Expand All @@ -250,15 +250,15 @@ cusparseStatus_t cusparseDestroyDnVec(
// cusparseSpMV_bufferSize
// =======================

/// \brief Definition of CUDA's \c cusparseSmMV_bufferSize function using
/// \brief Definition of CUDA's \c cusparseSpMV_bufferSize function using
/// dynamically loaded cublas library.

cusparseStatus_t cusparseSpMV_bufferSize(
cusparseHandle_t handle,
cusparseOperation_t opA,
const void* alpha,
cusparseSpMatDescr_t matA,
cusparseDnVecDescr_t vecX,
cusparseConstSpMatDescr_t matA,
cusparseConstDnVecDescr_t vecX,
const void* beta,
cusparseDnVecDescr_t vecY,
cudaDataType computeType,
Expand Down Expand Up @@ -293,8 +293,8 @@ cusparseStatus_t cusparseSpMV(
cusparseHandle_t handle,
cusparseOperation_t opA,
const void* alpha,
cusparseSpMatDescr_t matA,
cusparseDnVecDescr_t vecX,
cusparseConstSpMatDescr_t matA,
cusparseConstDnVecDescr_t vecX,
const void* beta,
cusparseDnVecDescr_t vecY,
cudaDataType computeType,
Expand Down
25 changes: 18 additions & 7 deletions imate/_cuda_dynamic_loading/cusparse_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,25 @@
// Headers
// =======

#include <cusparse.h> // cusparseSpMatDescr_t, cusparseDnVecDescr_t,
#include <cusparse.h> // cusparseSpMatDescr_t, cusparseConstSpMatDescr_t,
// cusparseDnVecDescr_t, cusparseConstDnVecDescr_t,
// CusparseStatus_t, CUSPARSE_STATUS_SUCCESS,
// cusparseCreateCsr, cusparseCreateDnVec,
// cusparseDestroySpMat, cusparseDestroyDnVec,
// CUDA_R_32F, CUDA_R_64F, CUSPARSE_INDEX_32I,
// CUSPARSE_INDEX_BASE_ZERO, cusparseHandle_t,
// cusparseSpMVAlg_t, cusparseSpMV_buffer_size

// CUDA Version Considerations
#if CUSPARSE_VER_MAJOR < 12
// These types were defined n cusparse version 12, but do not exist in
// earlier versions.
#define CUSPARSE_SPMV_ALG_DEFAULT CUSPARSE_MV_ALG_DEFAULT
#define cusparseConstSpMatDescr_t cusparseSpMatDescr_t
#define cusparseConstDnVecDescr_t cusparseDnVecDescr_t
#endif


// =====
// Types
// =====
Expand Down Expand Up @@ -57,19 +68,19 @@ typedef cusparseStatus_t (*cusparseCreateDnVec_type)(

// cusparseDestroySpMat
typedef cusparseStatus_t (*cusparseDestroySpMat_type)(
cusparseSpMatDescr_t spMatDescr);
cusparseConstSpMatDescr_t spMatDescr);

// cusparseDestroyDnVec
typedef cusparseStatus_t (*cusparseDestroyDnVec_type)(
cusparseDnVecDescr_t dnVecDescr);
cusparseConstDnVecDescr_t dnVecDescr);

// cusparseSpMV_buffer_size
typedef cusparseStatus_t (*cusparseSpMV_bufferSize_type)(
cusparseHandle_t handle,
cusparseOperation_t opA,
const void* alpha,
cusparseSpMatDescr_t matA,
cusparseDnVecDescr_t vecX,
cusparseConstSpMatDescr_t matA,
cusparseConstDnVecDescr_t vecX,
const void* beta,
cusparseDnVecDescr_t vecY,
cudaDataType computeType,
Expand All @@ -81,8 +92,8 @@ typedef cusparseStatus_t (*cusparseSpMV_type)(
cusparseHandle_t handle,
cusparseOperation_t opA,
const void* alpha,
cusparseSpMatDescr_t matA,
cusparseDnVecDescr_t vecX,
cusparseConstSpMatDescr_t matA,
cusparseConstDnVecDescr_t vecX,
const void* beta,
cusparseDnVecDescr_t vecY,
cudaDataType computeType,
Expand Down
Loading

0 comments on commit 8b5b3c9

Please sign in to comment.