Skip to content

Commit c408c5b

Browse files
committed
Minor Changes and Version Number Fixes
1 parent ebd1bae commit c408c5b

File tree

9 files changed

+46
-137
lines changed

9 files changed

+46
-137
lines changed

Common/include/linear_algebra/CMatrixVectorProduct.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@
5050
* handle the different types of matrix-vector products and still be
5151
* passed to a single implementation of the Krylov solvers.
5252
* This abstraction may also be used to define matrix-free products.
53-
*
54-
* There is also the use of a dummy class being made to select the
55-
* correct function as defined by the user while deciding between
56-
* CPU or GPU execution. This dummy class calls the correct member
57-
* functions from its derived classes to map the suitable path of
58-
* execution - CPU or GPU.
5953
*/
6054

6155
template <class ScalarType>
@@ -101,14 +95,20 @@ class CSysMatrixVectorProduct final : public CMatrixVectorProduct<ScalarType> {
10195
* \param[out] v - CSysVector that is the result of the product
10296
*/
10397
inline void operator()(const CSysVector<ScalarType>& u, CSysVector<ScalarType>& v) const override {
104-
#ifdef HAVE_CUDA
10598
if (config->GetCUDA()) {
106-
matrix.GPUMatrixVectorProduct(u, v, geometry, config);
107-
} else {
99+
#ifdef HAVE_CUDA
100+
matrix.GPUMatrixVectorProduct(u, v, geometry, config);
101+
#else
102+
SU2_MPI::Error(
103+
"\nError in launching Matrix-Vector Product Function\nENABLE_CUDA is set to YES\nPlease compile with CUDA "
104+
"options enabled in Meson to access GPU Functions",
105+
CURRENT_FUNCTION);
106+
#endif
107+
}
108+
else
109+
{
108110
matrix.MatrixVectorProduct(u, v, geometry, config);
109111
}
110-
#else
111-
matrix.MatrixVectorProduct(u, v, geometry, config);
112-
#endif
112+
113113
}
114-
};
114+
};

Common/include/linear_algebra/CSysMatrix.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,6 @@ class CSysMatrix {
855855
* \param[in] config - Definition of the particular problem.
856856
* \param[out] prod - Result of the product.
857857
*/
858-
859858
void GPUMatrixVectorProduct(const CSysVector<ScalarType>& vec, CSysVector<ScalarType>& prod, CGeometry* geometry,
860859
const CConfig* config) const;
861860

@@ -866,7 +865,6 @@ class CSysMatrix {
866865
* \param[in] config - Definition of the particular problem.
867866
* \param[out] prod - Result of the product.
868867
*/
869-
870868
void GPUFirstSymmetricIteration(ScalarType& vec, ScalarType& prod, CGeometry* geometry, const CConfig* config) const;
871869

872870
/*!
@@ -875,7 +873,6 @@ class CSysMatrix {
875873
* \param[in] config - Definition of the particular problem.
876874
* \param[out] prod - Result of the product.
877875
*/
878-
879876
void GPUSecondSymmetricIteration(ScalarType& prod, CGeometry* geometry, const CConfig* config) const;
880877

881878
/*!
@@ -884,7 +881,6 @@ class CSysMatrix {
884881
* \param[in] config - Definition of the particular problem.
885882
* \param[out] prod - Result of the product.
886883
*/
887-
888884
void GPUGaussElimination(ScalarType& prod, CGeometry* geometry, const CConfig* config) const;
889885

890886
/*!

Common/include/linear_algebra/CSysVector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class CSysVector : public VecExpr::CVecExpr<CSysVector<ScalarType>, ScalarType>
217217
void GPUSetVal(ScalarType val, bool trigger = true) const;
218218

219219
/*!
220-
* \brief return the number of local elements in the CSysVector
220+
* \brief return device pointer that points to the CSysVector values in GPU memory
221221
*/
222222
inline ScalarType* GetDevicePointer() const { return d_vec_val; }
223223

Common/include/linear_algebra/GPUComms.cuh

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
\file GPUComms.cuh
33
* \brief Header file containing universal functions that provide basic and essential utilities for other GPU processes
44
* \author A. Raj
5-
* \version 8.1.0 "Harrier"
5+
* \version 8.2.0 "Harrier"
66
*
77
* SU2 Project Website: https://su2code.github.io
88
*
@@ -26,27 +26,25 @@
2626
*/
2727

2828
#include<cuda_runtime.h>
29-
#include"iostream"
29+
#include<iostream>
3030

3131
namespace KernelParameters{
3232

33-
inline constexpr int round_up_division(const int multiple, int x) { return ((x + multiple - 1) / multiple); }
33+
inline constexpr int round_up_division(const int multiple, int x) { return ((x + multiple - 1) / multiple); }
3434

35-
const int MVP_BLOCK_SIZE = 1024;
36-
const int MVP_WARP_SIZE = 32;
35+
static constexpr int MVP_BLOCK_SIZE = 1024;
36+
static constexpr int MVP_WARP_SIZE = 32;
3737
}
3838
/*!
39-
* \brief assert style function that reads return codes after intercepting CUDA API calls.
40-
* It returns the result code and its location if the call is unsuccessful.
41-
* \param[in] code - result code of CUDA function
42-
* \param[in] file - name of file holding the function
43-
* \param[in] line - line containing the function
44-
*/
39+
* \brief assert style function that reads return codes after intercepting CUDA API calls.
40+
* It returns the result code and its location if the call is unsuccessful.
41+
* \param[in] code - result code of CUDA function
42+
* \param[in] file - name of file holding the function
43+
* \param[in] line - line containing the function
44+
*/
4545

46-
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
47-
{
48-
if (code != cudaSuccess)
49-
{
46+
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true){
47+
if (code != cudaSuccess){
5048
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
5149
if (abort) exit(code);
5250
}

Common/include/toolboxes/allocation_toolbox.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,12 @@ inline void gpu_free(T* ptr) noexcept {
132132
* \return Pointer to memory, always use gpu_free to deallocate.
133133
*/
134134
template <class T>
135-
inline T* gpu_alloc_cpy(T* src_ptr, size_t size) noexcept {
135+
inline T* gpu_alloc_cpy(const T* src_ptr, size_t size) noexcept {
136136
void* ptr = nullptr;
137137

138138
#ifdef HAVE_CUDA
139139
gpuErrChk(cudaMalloc((void**)(&ptr), size));
140140
gpuErrChk(cudaMemcpy((void*)(ptr), (void*)src_ptr, size, cudaMemcpyHostToDevice));
141-
;
142-
#else
143-
return 0;
144141
#endif
145142

146143
return static_cast<T*>(ptr);

Common/src/linear_algebra/CSysMatrix.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,25 @@ void CSysMatrix<ScalarType>::Initialize(unsigned long npoint, unsigned long npoi
140140
ptr = MemoryAllocation::aligned_alloc<ScalarType, true>(64, num * sizeof(ScalarType));
141141
};
142142

143-
allocAndInit(matrix, nnz * nVar * nEqn);
144143

145-
auto GPUAllocAndInit = [](ScalarType*& ptr, unsigned long num) {
146-
ptr = GPUMemoryAllocation::gpu_alloc<ScalarType, true>(num * sizeof(ScalarType));
147-
};
144+
if(config->GetCUDA())
145+
{
146+
/*--- Allocate GPU data. ---*/
147+
allocAndInit(matrix, nnz * nVar * nEqn);
148148

149-
auto GPUAllocAndCopy = [](const unsigned long*& ptr, const unsigned long*& src_ptr, unsigned long num) {
150-
ptr = GPUMemoryAllocation::gpu_alloc_cpy<const unsigned long>(src_ptr, num * sizeof(const unsigned long));
151-
};
149+
auto GPUAllocAndInit = [](ScalarType*& ptr, unsigned long num) {
150+
ptr = GPUMemoryAllocation::gpu_alloc<ScalarType, true>(num * sizeof(ScalarType));
151+
};
152152

153-
GPUAllocAndInit(d_matrix, nnz * nVar * nEqn);
154-
GPUAllocAndCopy(d_row_ptr, row_ptr, (nPointDomain + 1.0));
155-
GPUAllocAndCopy(d_col_ind, col_ind, nnz);
153+
auto GPUAllocAndCopy = [](const unsigned long*& ptr, const unsigned long*& src_ptr, unsigned long num) {
154+
ptr = GPUMemoryAllocation::gpu_alloc_cpy<const unsigned long>(src_ptr, num * sizeof(const unsigned long));
155+
};
156+
157+
GPUAllocAndInit(d_matrix, nnz * nVar * nEqn);
158+
GPUAllocAndCopy(d_row_ptr, row_ptr, (nPointDomain + 1.0));
159+
GPUAllocAndCopy(d_col_ind, col_ind, nnz);
160+
}
161+
156162

157163
if (needTranspPtr) col_ptr = geometry->GetTransposeSparsePatternMap(type).data();
158164

Common/src/linear_algebra/CSysMatrixGPU.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* \file CSysMatrixGPU.cu
33
* \brief Implementations of Kernels and Functions for Matrix Operations on the GPU
44
* \author A. Raj
5-
* \version 8.1.0 "Harrier"
5+
* \version 8.2.0 "Harrier"
66
*
77
* SU2 Project Website: https://su2code.github.io
88
*

Common/src/linear_algebra/CSysVectorGPU.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* \file CSysVectorGPU.cu
33
* \brief Implementations of Kernels and Functions for Vector Operations on the GPU
44
* \author A. Raj
5-
* \version 8.1.0 "Harrier"
5+
* \version 8.2.0 "Harrier"
66
*
77
* SU2 Project Website: https://su2code.github.io
88
*

TestCases/gpu/flatplate/lam_flatplate.cfg

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)